diff mbox

[i-g-t,v4,2/2] lib/ioctl_wrappers.h: Add to_user_pointer() helper

Message ID 20170102102555.9056-3-robert.foss@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robert Foss Jan. 2, 2017, 10:25 a.m. UTC
Add to_user_pointer() helper function which helps cast
pointers properly when being used with ioctls.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
---
 lib/ioctl_wrappers.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox

Patch

diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index 26270975..2ac57f47 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -239,4 +239,15 @@  int __kms_addfb(int fd, uint32_t handle, uint32_t width, uint32_t height,
 		uint32_t stride, uint32_t pixel_format, uint64_t modifier,
 		uint32_t flags, uint32_t *buf_id);
 
+/**
+ * to_user_pointer:
+ *
+ * Makes sure that pointer on 32 and 64-bit systems
+ * are casted properly for being sent through an ioctl.
+ */
+inline uint64_t to_user_pointer(void *ptr)
+{
+	return (uint64_t)(uintptr_t) ptr;
+}
+
 #endif /* IOCTL_WRAPPERS_H */