All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tobias Frost <tobi@frost.de>
To: dri-devel@lists.freedesktop.org
Subject: libdrm: Patch to compile on hurd.
Date: Thu, 21 Apr 2016 07:30:33 +0200	[thread overview]
Message-ID: <1461216633.14744.4.camel@frost.de> (raw)

[-- Attachment #1: Type: text/plain, Size: 351 bytes --]

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!

--



[-- Attachment #2: 02_hurd.patch --]
[-- Type: text/x-patch, Size: 3828 bytes --]

--- 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;
 

[-- Attachment #3: Type: text/plain, Size: 160 bytes --]

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

             reply	other threads:[~2016-04-21  5:40 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21  5:30 Tobias Frost [this message]
2016-04-21 12:33 ` libdrm: Patch to compile on hurd Emil Velikov
2016-04-24  8:00   ` Tobias Frost
2016-04-24  7:57 ` [PATCH] Workaround for systems that does not have PATH_MAX, like hurd Tobias Frost
2016-04-24 20:03   ` Emil Velikov
2016-04-24  8:09 ` libdrm: Patch to compile on hurd -- includes in drm.h Tobias Frost
2016-04-24  8:09   ` [PATCH] On hurd other includes are required to compile Tobias Frost
2016-04-24 20:20     ` Emil Velikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461216633.14744.4.camel@frost.de \
    --to=tobi@frost.de \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.