@@ -38,6 +38,9 @@
#include <sys/types.h>
#include <stdint.h>
#include <drm.h>
+#if defined(__linux__) && defined(__GNUC__) && defined (__x86_64__)
+#include <sys/syscall.h>
+#endif
#include <sys/ioctl.h>
#include <errno.h>
@@ -135,6 +138,30 @@ drmIoctl(int fd, unsigned long request, void *arg)
return ret;
}
+/**
+ * Call ioctl, restarting if it is interupted, and return the error.
+ */
+static inline int
+drmIoctl2(int fd, unsigned long request, void *arg)
+{
+ int result;
+
+ do {
+#if defined(__linux__) && defined(__GNUC__) && defined (__x86_64__)
+ __asm__("syscall"
+ : "=a" (result)
+ : "0" (__NR_ioctl), "D" (fd), "S" (request), "d" (arg)
+ : "cc", "rcx", "r11", "memory");
+#else
+ result = ioctl(fd, request, arg);
+ if (result == -1)
+ result = -errno;
+#endif
+ } while (result == -EINTR || result == -EAGAIN);
+
+ return result;
+}
+
extern void *drmGetHashTable(void);
extern drmHashEntry *drmGetEntry(int fd);