Browse Source

[uaccess] Add userptr_sub() to find the difference between two user pointers

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

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

68
 	return trivial_userptr_add ( userptr, offset );
68
 	return trivial_userptr_add ( userptr, offset );
69
 }
69
 }
70
 
70
 
71
+static inline __always_inline off_t
72
+UACCESS_INLINE ( librm, userptr_sub ) ( userptr_t userptr,
73
+					userptr_t subtrahend ) {
74
+	return trivial_userptr_sub ( userptr, subtrahend );
75
+}
76
+
71
 static inline __always_inline void
77
 static inline __always_inline void
72
 UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
78
 UACCESS_INLINE ( librm, memcpy_user ) ( userptr_t dest, off_t dest_off,
73
 					userptr_t src, off_t src_off,
79
 					userptr_t src, off_t src_off,

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

56
 	return trivial_userptr_add ( userptr, offset );
56
 	return trivial_userptr_add ( userptr, offset );
57
 }
57
 }
58
 
58
 
59
+static inline __always_inline off_t
60
+UACCESS_INLINE ( efi, userptr_sub ) ( userptr_t userptr,
61
+				      userptr_t subtrahend ) {
62
+	return trivial_userptr_sub ( userptr, subtrahend );
63
+}
64
+
59
 static inline __always_inline void
65
 static inline __always_inline void
60
 UACCESS_INLINE ( efi, memcpy_user ) ( userptr_t dest, off_t dest_off,
66
 UACCESS_INLINE ( efi, memcpy_user ) ( userptr_t dest, off_t dest_off,
61
 					userptr_t src, off_t src_off,
67
 					userptr_t src, off_t src_off,

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

71
 	return trivial_userptr_add(userptr, offset);
71
 	return trivial_userptr_add(userptr, offset);
72
 }
72
 }
73
 
73
 
74
+static inline __always_inline off_t
75
+UACCESS_INLINE(linux, userptr_sub)(userptr_t userptr, userptr_t subtrahend)
76
+{
77
+	return trivial_userptr_sub ( userptr, subtrahend );
78
+}
79
+
74
 static inline __always_inline void
80
 static inline __always_inline void
75
 UACCESS_INLINE(linux, memcpy_user)(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
81
 UACCESS_INLINE(linux, memcpy_user)(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len)
76
 {
82
 {

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

82
 	return ( userptr + offset );
82
 	return ( userptr + offset );
83
 }
83
 }
84
 
84
 
85
+/**
86
+ * Subtract user pointers
87
+ *
88
+ * @v userptr		User pointer
89
+ * @v subtrahend	User pointer to be subtracted
90
+ * @ret offset		Offset
91
+ */
92
+static inline __always_inline off_t
93
+trivial_userptr_sub ( userptr_t userptr, userptr_t subtrahend ) {
94
+	return ( userptr - subtrahend );
95
+}
96
+
85
 /**
97
 /**
86
  * Copy data between user buffers
98
  * Copy data between user buffers
87
  *
99
  *
239
  */
251
  */
240
 userptr_t userptr_add ( userptr_t userptr, off_t offset );
252
 userptr_t userptr_add ( userptr_t userptr, off_t offset );
241
 
253
 
254
+/**
255
+ * Subtract user pointers
256
+ *
257
+ * @v userptr		User pointer
258
+ * @v subtrahend	User pointer to be subtracted
259
+ * @ret offset		Offset
260
+ */
261
+off_t userptr_sub ( userptr_t userptr, userptr_t subtrahend );
262
+
242
 /**
263
 /**
243
  * Convert virtual address to a physical address
264
  * Convert virtual address to a physical address
244
  *
265
  *

Loading…
Cancel
Save