1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 21:50:55 +00:00
nixpkgs/pkgs/development/libraries/libdrm/libdrm-apple.patch
Yury G. Kudryashov ee0822153a Upgrade libdrm and mesa to the latest versions
svn path=/nixpkgs/trunk/; revision=31598
2012-01-16 17:48:33 +00:00

89 lines
2.6 KiB
Diff

diff -Naur libdrm-2.4.26-orig/intel/intel_bufmgr_gem.c libdrm-2.4.26/intel/intel_bufmgr_gem.c
--- libdrm-2.4.26-orig/intel/intel_bufmgr_gem.c 2011-04-01 10:30:51.000000000 -0400
+++ libdrm-2.4.26/intel/intel_bufmgr_gem.c 2011-08-29 02:17:20.000000000 -0400
@@ -51,6 +51,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <stdbool.h>
+#include <sys/time.h>
#include "errno.h"
#include "libdrm_lists.h"
@@ -987,9 +988,9 @@
if (atomic_dec_and_test(&bo_gem->refcount)) {
drm_intel_bufmgr_gem *bufmgr_gem =
(drm_intel_bufmgr_gem *) bo->bufmgr;
- struct timespec time;
+ struct timeval time;
- clock_gettime(CLOCK_MONOTONIC, &time);
+ gettimeofday(&time, NULL);
pthread_mutex_lock(&bufmgr_gem->lock);
drm_intel_gem_bo_unreference_final(bo, time.tv_sec);
diff -Naur libdrm-2.4.26-orig/xf86drm.c libdrm-2.4.26/xf86drm.c
--- libdrm-2.4.26-orig/xf86drm.c 2011-03-21 09:39:24.000000000 -0400
+++ libdrm-2.4.26/xf86drm.c 2011-08-29 02:17:49.000000000 -0400
@@ -51,6 +51,9 @@
#include <sys/mman.h>
#include <sys/time.h>
#include <stdarg.h>
+#if defined(__APPLE__) && defined(__MACH__)
+#include <mach/mach_time.h>
+#endif
/* Not all systems have MAP_FAILED defined */
#ifndef MAP_FAILED
@@ -1941,20 +1944,43 @@
*/
int drmWaitVBlank(int fd, drmVBlankPtr vbl)
{
+#if defined(__APPLE__) && defined(__MACH__)
+ uint64_t start, end, elapsed, elapsedNano;
+ static const uint64_t maxElapsed = 2000000000;
+ static mach_timebase_info_data_t timebaseInfo;
+ if ( timebaseInfo.denom == 0 ) {
+ (void) mach_timebase_info(&timebaseInfo);
+ }
+#else
struct timespec timeout, cur;
+#endif
int ret;
+#if defined(__APPLE__) && defined(__MACH__)
+ start = mach_absolute_time();
+#else
ret = clock_gettime(CLOCK_MONOTONIC, &timeout);
if (ret < 0) {
fprintf(stderr, "clock_gettime failed: %s\n", strerror(ret));
goto out;
}
timeout.tv_sec++;
+#endif
do {
ret = ioctl(fd, DRM_IOCTL_WAIT_VBLANK, vbl);
vbl->request.type &= ~DRM_VBLANK_RELATIVE;
if (ret && errno == EINTR) {
+#if defined(__APPLE__) && defined(__MACH__)
+ end = mach_absolute_time();
+ elapsed = end - start;
+ elapsedNano = elapsed * timebaseInfo.numer / timebaseInfo.denom;
+ if (elapsedNano > maxElapsed) {
+ errno = EBUSY;
+ ret = -1;
+ break;
+ }
+#else
clock_gettime(CLOCK_MONOTONIC, &cur);
/* Timeout after 1s */
if (cur.tv_sec > timeout.tv_sec + 1 ||
@@ -1964,6 +1990,7 @@
ret = -1;
break;
}
+#endif
}
} while (ret && errno == EINTR);