From 670e53434593607728acab7a5e52864d91345b68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= <krh@bitplanet.net>
Date: Mon, 23 Nov 2009 18:02:44 -0500
Subject: [PATCH] drm: Add minimal BSD #ifdefs so we can share the drm.h unchanged
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

We ship a copy of drm.h in the libdrm repo.  By adding these minimal
the *BSDs verbatim and avoid error prone manual editing.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
---
 include/drm/drm.h  |   23 +++++++++++++----------
 include/drm/drmP.h |   10 ++++++++++
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/include/drm/drm.h b/include/drm/drm.h
index 3919a4f..361a141 100644
--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -36,17 +36,21 @@
 #ifndef _DRM_H_
 #define _DRM_H_
 
+#if defined(__linux__)
+
 #include <linux/types.h>
-#include <asm/ioctl.h>		/* For _IO* macros */
-#define DRM_IOCTL_NR(n)		_IOC_NR(n)
-#define DRM_IOC_VOID		_IOC_NONE
-#define DRM_IOC_READ		_IOC_READ
-#define DRM_IOC_WRITE		_IOC_WRITE
-#define DRM_IOC_READWRITE	_IOC_READ|_IOC_WRITE
-#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
+#include <asm/ioctl.h>
+typedef unsigned int drm_handle_t;
+
+#else /* One of the BSDs */
 
-#define DRM_MAJOR       226
-#define DRM_MAX_MINOR   15
+#include <sys/ioccom.h>
+#include <sys/types.h>
+typedef uint32_t __u32;
+typedef uint64_t __u64;
+typedef unsigned long drm_handle_t;
+
+#endif
 
 #define DRM_NAME	"drm"	  /**< Name in kernel, /dev, and /proc */
 #define DRM_MIN_ORDER	5	  /**< At least 2^5 bytes = 32 bytes */
@@ -59,7 +63,6 @@
 #define _DRM_LOCK_IS_CONT(lock)	   ((lock) & _DRM_LOCK_CONT)
 #define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
 
-typedef unsigned int drm_handle_t;
 typedef unsigned int drm_context_t;
 typedef unsigned int drm_drawable_t;
 typedef unsigned int drm_magic_t;
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 1b72a52..65a3369 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -289,6 +289,16 @@ typedef int drm_ioctl_t(struct drm_device *dev, void *data,
 typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
 			       unsigned long arg);
 
+#define DRM_MAJOR       226
+#define DRM_MAX_MINOR   15
+
+#define DRM_IOCTL_NR(n)                _IOC_NR(n)
+#define DRM_IOC_VOID           _IOC_NONE
+#define DRM_IOC_READ           _IOC_READ
+#define DRM_IOC_WRITE          _IOC_WRITE
+#define DRM_IOC_READWRITE      _IOC_READ|_IOC_WRITE
+#define DRM_IOC(dir, group, nr, size) _IOC(dir, group, nr, size)
+
 #define DRM_AUTH	0x1
 #define	DRM_MASTER	0x2
 #define DRM_ROOT_ONLY	0x4
-- 
1.6.5.rc2

