libdrm: Patch to compile on hurd.

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

 



Hallo,

attached is a patch that makes libdrm compile on hurd.

(Note: I intentionally said compile, as I have no way to see if it
actually works there.)

The patch is created in a way to be neutral on all other archs;
it is mostly about PATH_MAX, which does not exist on that arch.

Maybe you find the patch useful.


Thanks!

--


--- a/include/drm/drm.h
+++ b/include/drm/drm.h
@@ -42,10 +42,19 @@
 #include <asm/ioctl.h>
 typedef unsigned int drm_handle_t;
 
+#elif defined(__gnu_hurd__)
+#include <stdint.h>
+#include <mach/i386/ioccom.h>
+
 #else /* One of the BSDs */
 
 #include <sys/ioccom.h>
 #include <sys/types.h>
+
+#endif
+
+#if !defined(__linux__)
+
 typedef int8_t   __s8;
 typedef uint8_t  __u8;
 typedef int16_t  __s16;
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -58,7 +58,11 @@
 
 #else /* One of the *BSDs */
 
+#if defined(__gnu_hurd__)
+#include <mach/i386/ioccom.h>
+#else
 #include <sys/ioccom.h>
+#endif
 #define DRM_IOCTL_NR(n)         ((n) & 0xff)
 #define DRM_IOC_VOID            IOC_VOID
 #define DRM_IOC_READ            IOC_OUT
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -103,6 +103,16 @@
 
 #define memclear(s) memset(&s, 0, sizeof(s))
 
+/* for systems like hurd which does not have PATH_MAX.
+ Usage is only for string manipulation, so it is save to define it.
+ 1kB will be plenty space...*/
+#ifndef PATH_MAX
+#define MY_PATH_MAX (1024)
+#else
+#define MY_PATH_MAX PATH_MAX
+#endif
+
+
 static drmServerInfoPtr drm_server_info;
 
 void drmSetServerInfo(drmServerInfoPtr info)
@@ -2835,14 +2845,15 @@
 static int drmParseSubsystemType(int maj, int min)
 {
 #ifdef __linux__
-    char path[PATH_MAX + 1];
-    char link[PATH_MAX + 1] = "";
+
+    char path[MY_PATH_MAX + 1];
+    char link[MY_PATH_MAX + 1] = "";
     char *name;
 
-    snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
+    snprintf(path, MY_PATH_MAX, "/sys/dev/char/%d:%d/device/subsystem",
              maj, min);
 
-    if (readlink(path, link, PATH_MAX) < 0)
+    if (readlink(path, link, MY_PATH_MAX) < 0)
         return -errno;
 
     name = strrchr(link, '/');
@@ -2857,18 +2868,19 @@
 #warning "Missing implementation of drmParseSubsystemType"
     return -EINVAL;
 #endif
+
 }
 
 static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
 {
 #ifdef __linux__
-    char path[PATH_MAX + 1];
+    char path[MY_PATH_MAX + 1];
     char data[128 + 1];
     char *str;
     int domain, bus, dev, func;
     int fd, ret;
 
-    snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/uevent", maj, min);
+    snprintf(path, MY_PATH_MAX, "/sys/dev/char/%d:%d/device/uevent", maj, min);
     fd = open(path, O_RDONLY);
     if (fd < 0)
         return -errno;
@@ -2949,11 +2961,11 @@
                                  drmPciDeviceInfoPtr device)
 {
 #ifdef __linux__
-    char path[PATH_MAX + 1];
+    char path[MY_PATH_MAX + 1];
     unsigned char config[64];
     int fd, ret;
 
-    snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config", d_name);
+    snprintf(path, MY_PATH_MAX, "/sys/class/drm/%s/device/config", d_name);
     fd = open(path, O_RDONLY);
     if (fd < 0)
         return -errno;
@@ -3082,7 +3094,7 @@
     DIR *sysdir;
     struct dirent *dent;
     struct stat sbuf;
-    char node[PATH_MAX + 1];
+    char node[MY_PATH_MAX + 1];
     int node_type, subsystem_type;
     int maj, min;
     int ret, i, node_count;
@@ -3118,7 +3130,7 @@
         if (node_type < 0)
             continue;
 
-        snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
+        snprintf(node, MY_PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
         if (stat(node, &sbuf))
             continue;
 
@@ -3198,7 +3210,7 @@
     DIR *sysdir;
     struct dirent *dent;
     struct stat sbuf;
-    char node[PATH_MAX + 1];
+    char node[MY_PATH_MAX + 1];
     int node_type, subsystem_type;
     int maj, min;
     int ret, i, node_count, device_count;
@@ -3220,7 +3232,7 @@
         if (node_type < 0)
             continue;
 
-        snprintf(node, PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
+        snprintf(node, MY_PATH_MAX, "%s/%s", DRM_DIR_NAME, dent->d_name);
         if (stat(node, &sbuf))
             continue;
 
_______________________________________________
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