Browse Source

[uaccess] Add memcmp_user()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
fffd98bd37

+ 7
- 0
src/arch/i386/include/librm.h View File

88
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
88
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
89
 }
89
 }
90
 
90
 
91
+static inline __always_inline int
92
+UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off,
93
+					userptr_t second, off_t second_off,
94
+					size_t len ) {
95
+	return trivial_memcmp_user ( first, first_off, second, second_off, len);
96
+}
97
+
91
 static inline __always_inline void
98
 static inline __always_inline void
92
 UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
99
 UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
93
 					int c, size_t len ) {
100
 					int c, size_t len ) {

+ 7
- 0
src/include/ipxe/efi/efi_uaccess.h View File

76
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
76
 	trivial_memmove_user ( dest, dest_off, src, src_off, len );
77
 }
77
 }
78
 
78
 
79
+static inline __always_inline int
80
+UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off,
81
+				      userptr_t second, off_t second_off,
82
+				      size_t len ) {
83
+	return trivial_memcmp_user ( first, first_off, second, second_off, len);
84
+}
85
+
79
 static inline __always_inline void
86
 static inline __always_inline void
80
 UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset,
87
 UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset,
81
 					int c, size_t len ) {
88
 					int c, size_t len ) {

+ 6
- 0
src/include/ipxe/linux/linux_uaccess.h View File

89
 	trivial_memmove_user(dest, dest_off, src, src_off, len);
89
 	trivial_memmove_user(dest, dest_off, src, src_off, len);
90
 }
90
 }
91
 
91
 
92
+static inline __always_inline int
93
+UACCESS_INLINE(linux, memcmp_user)(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
94
+{
95
+	return trivial_memcmp_user(first, first_off, second, second_off, len);
96
+}
97
+
92
 static inline __always_inline void
98
 static inline __always_inline void
93
 UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len)
99
 UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len)
94
 {
100
 {

+ 30
- 0
src/include/ipxe/uaccess.h View File

126
 		  ( ( void * ) src + src_off ), len );
126
 		  ( ( void * ) src + src_off ), len );
127
 }
127
 }
128
 
128
 
129
+/**
130
+ * Compare data between user buffers
131
+ *
132
+ * @v first		First buffer
133
+ * @v first_off		First buffer offset
134
+ * @v second		Second buffer
135
+ * @v second_off	Second buffer offset
136
+ * @v len		Length
137
+ * @ret diff		Difference
138
+ */
139
+static inline __always_inline int
140
+trivial_memcmp_user ( userptr_t first, off_t first_off,
141
+		      userptr_t second, off_t second_off, size_t len ) {
142
+	return memcmp ( ( ( void * ) first + first_off ),
143
+			( ( void * ) second + second_off ), len );
144
+}
145
+
129
 /**
146
 /**
130
  * Fill user buffer with a constant byte
147
  * Fill user buffer with a constant byte
131
  *
148
  *
333
 void memmove_user ( userptr_t dest, off_t dest_off,
350
 void memmove_user ( userptr_t dest, off_t dest_off,
334
 		    userptr_t src, off_t src_off, size_t len );
351
 		    userptr_t src, off_t src_off, size_t len );
335
 
352
 
353
+/**
354
+ * Compare data between user buffers
355
+ *
356
+ * @v first		First buffer
357
+ * @v first_off		First buffer offset
358
+ * @v second		Second buffer
359
+ * @v second_off	Second buffer offset
360
+ * @v len		Length
361
+ * @ret diff		Difference
362
+ */
363
+int memcmp_user ( userptr_t first, off_t first_off,
364
+		  userptr_t second, off_t second_off, size_t len );
365
+
336
 /**
366
 /**
337
  * Fill user buffer with a constant byte
367
  * Fill user buffer with a constant byte
338
  *
368
  *

Loading…
Cancel
Save