]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[uaccess] Add memcmp_user()
authorMichael Brown <mcb30@ipxe.org>
Mon, 6 Jan 2014 17:56:58 +0000 (18:56 +0100)
committerMichael Brown <mcb30@ipxe.org>
Sun, 12 Jan 2014 21:53:16 +0000 (22:53 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/arch/i386/include/librm.h
src/include/ipxe/efi/efi_uaccess.h
src/include/ipxe/linux/linux_uaccess.h
src/include/ipxe/uaccess.h

index 801f586b8e39c8291e16b2ebe08070fabbc103f9..fc5598ebacd14e03799d9011ae2a364c33149324 100644 (file)
@@ -88,6 +88,13 @@ UACCESS_INLINE ( librm, memmove_user ) ( userptr_t dest, off_t dest_off,
        trivial_memmove_user ( dest, dest_off, src, src_off, len );
 }
 
+static inline __always_inline int
+UACCESS_INLINE ( librm, memcmp_user ) ( userptr_t first, off_t first_off,
+                                       userptr_t second, off_t second_off,
+                                       size_t len ) {
+       return trivial_memcmp_user ( first, first_off, second, second_off, len);
+}
+
 static inline __always_inline void
 UACCESS_INLINE ( librm, memset_user ) ( userptr_t buffer, off_t offset,
                                        int c, size_t len ) {
index 79c18972e2257ffb1624ef41e54143952688d437..870a089b25ce933c6f4d5b797c206e98ec105da8 100644 (file)
@@ -76,6 +76,13 @@ UACCESS_INLINE ( efi, memmove_user ) ( userptr_t dest, off_t dest_off,
        trivial_memmove_user ( dest, dest_off, src, src_off, len );
 }
 
+static inline __always_inline int
+UACCESS_INLINE ( efi, memcmp_user ) ( userptr_t first, off_t first_off,
+                                     userptr_t second, off_t second_off,
+                                     size_t len ) {
+       return trivial_memcmp_user ( first, first_off, second, second_off, len);
+}
+
 static inline __always_inline void
 UACCESS_INLINE ( efi, memset_user ) ( userptr_t buffer, off_t offset,
                                        int c, size_t len ) {
index e4dfdd357718c00b39151ad05df90e6cf266f03e..e4d16d9e069a18afe611d827691adb4ee7d9a224 100644 (file)
@@ -89,6 +89,12 @@ UACCESS_INLINE(linux, memmove_user)(userptr_t dest, off_t dest_off, userptr_t sr
        trivial_memmove_user(dest, dest_off, src, src_off, len);
 }
 
+static inline __always_inline int
+UACCESS_INLINE(linux, memcmp_user)(userptr_t first, off_t first_off, userptr_t second, off_t second_off, size_t len)
+{
+       return trivial_memcmp_user(first, first_off, second, second_off, len);
+}
+
 static inline __always_inline void
 UACCESS_INLINE(linux, memset_user)(userptr_t buffer, off_t offset, int c, size_t len)
 {
index 95e9436759ff8d7970add4d4f6cca43d538f37e7..055bb2ca741fee4382079986dabaf12d8d43a2b7 100644 (file)
@@ -126,6 +126,23 @@ trivial_memmove_user ( userptr_t dest, off_t dest_off,
                  ( ( void * ) src + src_off ), len );
 }
 
+/**
+ * Compare data between user buffers
+ *
+ * @v first            First buffer
+ * @v first_off                First buffer offset
+ * @v second           Second buffer
+ * @v second_off       Second buffer offset
+ * @v len              Length
+ * @ret diff           Difference
+ */
+static inline __always_inline int
+trivial_memcmp_user ( userptr_t first, off_t first_off,
+                     userptr_t second, off_t second_off, size_t len ) {
+       return memcmp ( ( ( void * ) first + first_off ),
+                       ( ( void * ) second + second_off ), len );
+}
+
 /**
  * Fill user buffer with a constant byte
  *
@@ -333,6 +350,19 @@ copy_from_user ( void *dest, userptr_t src, off_t src_off, size_t len ) {
 void memmove_user ( userptr_t dest, off_t dest_off,
                    userptr_t src, off_t src_off, size_t len );
 
+/**
+ * Compare data between user buffers
+ *
+ * @v first            First buffer
+ * @v first_off                First buffer offset
+ * @v second           Second buffer
+ * @v second_off       Second buffer offset
+ * @v len              Length
+ * @ret diff           Difference
+ */
+int memcmp_user ( userptr_t first, off_t first_off,
+                 userptr_t second, off_t second_off, size_t len );
+
 /**
  * Fill user buffer with a constant byte
  *