[PATCH v2] drm: DRM_FOURCC_STANDALONE macro support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use DRM_FOURCC_STANDALONE to include drm_fourcc.h without drm.h.

Copy type definitions from drm.h to drm_fourcc.h, and wrap with
DRM_BASIC_TYPED_DEFINED to avoid redundant inclusion.

This will allow code to avoid unnecessary definitions.

Signed-off-by: James Park <jpark37@xxxxxxxxxxxxxxxx>
Acked-by: Simon Ser <contact@xxxxxxxxxxx>
---
Add Acked-by line to the commit description.

 include/uapi/drm/drm.h        | 35 ++++++++++++++++++++++++++++-------
 include/uapi/drm/drm_fourcc.h | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h
index 808b48a..5640062 100644
--- a/include/uapi/drm/drm.h
+++ b/include/uapi/drm/drm.h
@@ -36,23 +36,25 @@
 #ifndef _DRM_H_
 #define _DRM_H_
 
+/**
+ * DRM_BASIC_TYPES_DEFINED section exists in both drm.h and drm_fourcc.h files.
+ * Do not modify the section in one file without updating the other!
+ */
+
+#ifndef DRM_BASIC_TYPES_DEFINED
+#define DRM_BASIC_TYPES_DEFINED
+
 #if defined(__KERNEL__)
 
 #include <linux/types.h>
-#include <asm/ioctl.h>
-typedef unsigned int drm_handle_t;
 
 #elif defined(__linux__)
 
 #include <linux/types.h>
-#include <asm/ioctl.h>
-typedef unsigned int drm_handle_t;
 
-#else /* One of the BSDs */
+#else /* Not Linux */
 
 #include <stdint.h>
-#include <sys/ioccom.h>
-#include <sys/types.h>
 typedef int8_t   __s8;
 typedef uint8_t  __u8;
 typedef int16_t  __s16;
@@ -62,6 +64,25 @@ typedef uint32_t __u32;
 typedef int64_t  __s64;
 typedef uint64_t __u64;
 typedef size_t   __kernel_size_t;
+
+#endif
+
+#endif /* DRM_BASIC_TYPES_DEFINED */
+
+#if defined(__KERNEL__)
+
+#include <asm/ioctl.h>
+typedef unsigned int drm_handle_t;
+
+#elif defined(__linux__)
+
+#include <asm/ioctl.h>
+typedef unsigned int drm_handle_t;
+
+#else /* One of the BSDs */
+
+#include <sys/ioccom.h>
+#include <sys/types.h>
 typedef unsigned long drm_handle_t;
 
 #endif
diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 723c8e2..5e5f4cf 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -24,7 +24,42 @@
 #ifndef DRM_FOURCC_H
 #define DRM_FOURCC_H
 
+/**
+ * DRM_BASIC_TYPES_DEFINED section exists in both drm.h and drm_fourcc.h files.
+ * Do not modify the section in one file without updating the other!
+ */
+
+#ifndef DRM_BASIC_TYPES_DEFINED
+#define DRM_BASIC_TYPES_DEFINED
+
+#if defined(__KERNEL__)
+
+#include <linux/types.h>
+
+#elif defined(__linux__)
+
+#include <linux/types.h>
+
+#else /* Not Linux */
+
+#include <stdint.h>
+typedef int8_t   __s8;
+typedef uint8_t  __u8;
+typedef int16_t  __s16;
+typedef uint16_t __u16;
+typedef int32_t  __s32;
+typedef uint32_t __u32;
+typedef int64_t  __s64;
+typedef uint64_t __u64;
+typedef size_t   __kernel_size_t;
+
+#endif
+
+#endif /* DRM_BASIC_TYPES_DEFINED */
+
+#ifndef DRM_FOURCC_STANDALONE
 #include "drm.h"
+#endif
 
 #if defined(__cplusplus)
 extern "C" {
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux