diff options
author | Michael Brown <mcb30@ipxe.org> | 2012-11-05 16:09:38 +0000 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2012-11-05 16:15:14 +0000 |
commit | 1494d41d0a20a1facff7558ff825a2681b419e9d (patch) | |
tree | 63950ade91da20fa06e2b47429dea8433625f441 /src/include/ipxe | |
parent | 54a861a7bdfb2186239d520d5e4b0ce88c7604ab (diff) | |
download | ipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.zip ipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.tar.gz ipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.tar.bz2 |
[uaccess] Add userptr_sub() to find the difference between two user pointers
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/include/ipxe')
-rw-r--r-- | src/include/ipxe/efi/efi_uaccess.h | 6 | ||||
-rw-r--r-- | src/include/ipxe/linux/linux_uaccess.h | 6 | ||||
-rw-r--r-- | src/include/ipxe/uaccess.h | 21 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/include/ipxe/efi/efi_uaccess.h b/src/include/ipxe/efi/efi_uaccess.h index dc226a3..79c1897 100644 --- a/src/include/ipxe/efi/efi_uaccess.h +++ b/src/include/ipxe/efi/efi_uaccess.h @@ -56,6 +56,12 @@ UACCESS_INLINE ( efi, userptr_add ) ( userptr_t userptr, off_t offset ) { return trivial_userptr_add ( userptr, offset ); } +static inline __always_inline off_t +UACCESS_INLINE ( efi, userptr_sub ) ( userptr_t userptr, + userptr_t subtrahend ) { + return trivial_userptr_sub ( userptr, subtrahend ); +} + static inline __always_inline void UACCESS_INLINE ( efi, memcpy_user ) ( userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, diff --git a/src/include/ipxe/linux/linux_uaccess.h b/src/include/ipxe/linux/linux_uaccess.h index 1b49611..e4dfdd3 100644 --- a/src/include/ipxe/linux/linux_uaccess.h +++ b/src/include/ipxe/linux/linux_uaccess.h @@ -71,6 +71,12 @@ UACCESS_INLINE(linux, userptr_add)(userptr_t userptr, off_t offset) return trivial_userptr_add(userptr, offset); } +static inline __always_inline off_t +UACCESS_INLINE(linux, userptr_sub)(userptr_t userptr, userptr_t subtrahend) +{ + return trivial_userptr_sub ( userptr, subtrahend ); +} + static inline __always_inline void UACCESS_INLINE(linux, memcpy_user)(userptr_t dest, off_t dest_off, userptr_t src, off_t src_off, size_t len) { diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h index b574c31..95e9436 100644 --- a/src/include/ipxe/uaccess.h +++ b/src/include/ipxe/uaccess.h @@ -83,6 +83,18 @@ trivial_userptr_add ( userptr_t userptr, off_t offset ) { } /** + * Subtract user pointers + * + * @v userptr User pointer + * @v subtrahend User pointer to be subtracted + * @ret offset Offset + */ +static inline __always_inline off_t +trivial_userptr_sub ( userptr_t userptr, userptr_t subtrahend ) { + return ( userptr - subtrahend ); +} + +/** * Copy data between user buffers * * @v dest Destination @@ -240,6 +252,15 @@ void * user_to_virt ( userptr_t userptr, off_t offset ); userptr_t userptr_add ( userptr_t userptr, off_t offset ); /** + * Subtract user pointers + * + * @v userptr User pointer + * @v subtrahend User pointer to be subtracted + * @ret offset Offset + */ +off_t userptr_sub ( userptr_t userptr, userptr_t subtrahend ); + +/** * Convert virtual address to a physical address * * @v addr Virtual address |