I'd noticed the #if could be combined, but they weren't in drm,h when they could have been, so I didn't want to depart from the existing pattern.
I think "One of the BSDs" is more informative than "Not Linux" if that statement is still true. Given the aversion to making drm.h robust to Windows, I don't think we want to imply compatibility that isn't there.
Thanks, James
On Mon, Dec 7, 2020 at 1:45 AM Simon Ser contact@emersion.fr wrote:
On Sunday, December 6th, 2020 at 1:39 AM, James Park < jpark37@lagfreegames.com> wrote:
Create drm_basic_types.h to define types previously defined by drm.h.
Use DRM_FOURCC_STANDALONE to include drm_fourcc.h, replacing drm.h dependency with drm_basic_types.h.
This approach looks better to me than the other alternatives.
This will allow Mesa to port code to Windows more easily.
Signed-off-by: James Park jpark37@lagfreegames.com
include/uapi/drm/drm.h | 14 ++-------- include/uapi/drm/drm_basic_types.h | 52
++++++++++++++++++++++++++++++++++++++
include/uapi/drm/drm_fourcc.h | 4 +++ 3 files changed, 58 insertions(+), 12 deletions(-) create mode 100644 include/uapi/drm/drm_basic_types.h
diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h index 808b48a..a7f38fc 100644 --- a/include/uapi/drm/drm.h +++ b/include/uapi/drm/drm.h @@ -36,32 +36,22 @@ #ifndef _DRM_H_ #define _DRM_H_
+#include "drm_basic_types.h"
#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 */
-#include <stdint.h> #include <sys/ioccom.h> #include <sys/types.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; typedef unsigned long drm_handle_t;
#endif diff --git a/include/uapi/drm/drm_basic_types.h
b/include/uapi/drm/drm_basic_types.h
new file mode 100644 index 0000000..b3c00bb --- /dev/null +++ b/include/uapi/drm/drm_basic_types.h @@ -0,0 +1,52 @@ +/*
- Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- All rights reserved.
- Permission is hereby granted, free of charge, to any person
obtaining a
- copy of this software and associated documentation files (the
"Software"),
- to deal in the Software without restriction, including without
limitation
- the rights to use, copy, modify, merge, publish, distribute,
sublicense,
- and/or sell copies of the Software, and to permit persons to whom the
- Software is furnished to do so, subject to the following conditions:
- The above copyright notice and this permission notice (including the
next
- paragraph) shall be included in all copies or substantial portions
of the
- Software.
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL
- VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
- */
+#ifndef _DRM_BASIC_TYPES_H_ +#define _DRM_BASIC_TYPES_H_
+#if defined(__KERNEL__)
+#include <linux/types.h>
+#elif defined(__linux__)
Nit: these two #ifs can be combined together.
+#include <linux/types.h>
+#else /* One of the BSDs */
Maybe replace with /* 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 diff --git a/include/uapi/drm/drm_fourcc.h
b/include/uapi/drm/drm_fourcc.h
index 82f3278..5eb07a5 100644 --- a/include/uapi/drm/drm_fourcc.h +++ b/include/uapi/drm/drm_fourcc.h @@ -24,7 +24,11 @@ #ifndef DRM_FOURCC_H #define DRM_FOURCC_H
+#ifdef DRM_FOURCC_STANDALONE +#include "drm_basic_types.h" +#else #include "drm.h" +#endif
#if defined(__cplusplus) extern "C" { -- 2.7.4
dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel