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

Robert Foss robert.foss at collabora.com
Mon Jan 2 10:25:55 UTC 2017


Add to_user_pointer() helper function which helps cast
pointers properly when being used with ioctls.

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

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 */
-- 
2.11.0



More information about the Intel-gfx mailing list