summaryrefslogtreecommitdiffstats
path: root/src/include/ipxe/uaccess.h
diff options
context:
space:
mode:
authorMichael Brown2012-11-05 17:09:38 +0100
committerMichael Brown2012-11-05 17:15:14 +0100
commit1494d41d0a20a1facff7558ff825a2681b419e9d (patch)
tree63950ade91da20fa06e2b47429dea8433625f441 /src/include/ipxe/uaccess.h
parent[list] Reduce overall code size by externalising many list functions (diff)
downloadipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.tar.gz
ipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.tar.xz
ipxe-1494d41d0a20a1facff7558ff825a2681b419e9d.zip
[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/uaccess.h')
-rw-r--r--src/include/ipxe/uaccess.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/ipxe/uaccess.h b/src/include/ipxe/uaccess.h
index b574c3183..95e943675 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