<div dir="ltr">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.<div><br></div><div>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.</div><div><br></div><div>Thanks,</div><div>James</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Dec 7, 2020 at 1:45 AM Simon Ser <<a href="mailto:contact@emersion.fr">contact@emersion.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Sunday, December 6th, 2020 at 1:39 AM, James Park <<a href="mailto:jpark37@lagfreegames.com" target="_blank">jpark37@lagfreegames.com</a>> wrote:<br>
<br>
> Create drm_basic_types.h to define types previously defined by drm.h.<br>
><br>
> Use DRM_FOURCC_STANDALONE to include drm_fourcc.h, replacing drm.h<br>
> dependency with drm_basic_types.h.<br>
<br>
This approach looks better to me than the other alternatives.<br>
<br>
> This will allow Mesa to port code to Windows more easily.<br>
><br>
> Signed-off-by: James Park <<a href="mailto:jpark37@lagfreegames.com" target="_blank">jpark37@lagfreegames.com</a>><br>
> ---<br>
>  include/uapi/drm/drm.h             | 14 ++--------<br>
>  include/uapi/drm/drm_basic_types.h | 52 ++++++++++++++++++++++++++++++++++++++<br>
>  include/uapi/drm/drm_fourcc.h      |  4 +++<br>
>  3 files changed, 58 insertions(+), 12 deletions(-)<br>
>  create mode 100644 include/uapi/drm/drm_basic_types.h<br>
><br>
> diff --git a/include/uapi/drm/drm.h b/include/uapi/drm/drm.h<br>
> index 808b48a..a7f38fc 100644<br>
> --- a/include/uapi/drm/drm.h<br>
> +++ b/include/uapi/drm/drm.h<br>
> @@ -36,32 +36,22 @@<br>
>  #ifndef _DRM_H_<br>
>  #define _DRM_H_<br>
><br>
> +#include "drm_basic_types.h"<br>
> +<br>
>  #if defined(__KERNEL__)<br>
><br>
> -#include <linux/types.h><br>
>  #include <asm/ioctl.h><br>
>  typedef unsigned int drm_handle_t;<br>
><br>
>  #elif defined(__linux__)<br>
><br>
> -#include <linux/types.h><br>
>  #include <asm/ioctl.h><br>
>  typedef unsigned int drm_handle_t;<br>
><br>
>  #else /* One of the BSDs */<br>
><br>
> -#include <stdint.h><br>
>  #include <sys/ioccom.h><br>
>  #include <sys/types.h><br>
> -typedef int8_t   __s8;<br>
> -typedef uint8_t  __u8;<br>
> -typedef int16_t  __s16;<br>
> -typedef uint16_t __u16;<br>
> -typedef int32_t  __s32;<br>
> -typedef uint32_t __u32;<br>
> -typedef int64_t  __s64;<br>
> -typedef uint64_t __u64;<br>
> -typedef size_t   __kernel_size_t;<br>
>  typedef unsigned long drm_handle_t;<br>
><br>
>  #endif<br>
> diff --git a/include/uapi/drm/drm_basic_types.h b/include/uapi/drm/drm_basic_types.h<br>
> new file mode 100644<br>
> index 0000000..b3c00bb<br>
> --- /dev/null<br>
> +++ b/include/uapi/drm/drm_basic_types.h<br>
> @@ -0,0 +1,52 @@<br>
> +/*<br>
> + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.<br>
> + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.<br>
> + * All rights reserved.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
> + * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR<br>
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,<br>
> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR<br>
> + * OTHER DEALINGS IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +#ifndef _DRM_BASIC_TYPES_H_<br>
> +#define _DRM_BASIC_TYPES_H_<br>
> +<br>
> +#if defined(__KERNEL__)<br>
> +<br>
> +#include <linux/types.h><br>
> +<br>
> +#elif defined(__linux__)<br>
<br>
Nit: these two #ifs can be combined together.<br>
<br>
> +#include <linux/types.h><br>
> +<br>
> +#else /* One of the BSDs */<br>
<br>
Maybe replace with /* Not Linux */?<br>
<br>
> +#include <stdint.h><br>
> +typedef int8_t   __s8;<br>
> +typedef uint8_t  __u8;<br>
> +typedef int16_t  __s16;<br>
> +typedef uint16_t __u16;<br>
> +typedef int32_t  __s32;<br>
> +typedef uint32_t __u32;<br>
> +typedef int64_t  __s64;<br>
> +typedef uint64_t __u64;<br>
> +typedef size_t   __kernel_size_t;<br>
> +<br>
> +#endif<br>
> +<br>
> +#endif<br>
> diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h<br>
> index 82f3278..5eb07a5 100644<br>
> --- a/include/uapi/drm/drm_fourcc.h<br>
> +++ b/include/uapi/drm/drm_fourcc.h<br>
> @@ -24,7 +24,11 @@<br>
>  #ifndef DRM_FOURCC_H<br>
>  #define DRM_FOURCC_H<br>
><br>
> +#ifdef DRM_FOURCC_STANDALONE<br>
> +#include "drm_basic_types.h"<br>
> +#else<br>
>  #include "drm.h"<br>
> +#endif<br>
><br>
>  #if defined(__cplusplus)<br>
>  extern "C" {<br>
> --<br>
> 2.7.4<br>
><br>
> _______________________________________________<br>
> dri-devel mailing list<br>
> <a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/dri-devel" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</blockquote></div>