1diff --git a/include/c11/threads_posix.h b/include/c11/threads_posix.h
2index 45cb6075e6..62937311b9 100644
3--- a/include/c11/threads_posix.h
4+++ b/include/c11/threads_posix.h
5@@ -36,6 +36,11 @@
6 #include <sched.h>
7 #include <stdint.h> /* for intptr_t */
8
9+#ifdef __MACH__
10+#include <mach/clock.h>
11+#include <mach/mach.h>
12+#endif
13+
14 /*
15 Configuration macro:
16
17@@ -383,12 +388,25 @@ tss_set(tss_t key, void *val)
18 /*-------------------- 7.25.7 Time functions --------------------*/
19 // 7.25.6.1
20 #ifndef HAVE_TIMESPEC_GET
21+
22 static inline int
23 timespec_get(struct timespec *ts, int base)
24 {
25 if (!ts) return 0;
26 if (base == TIME_UTC) {
27+#ifdef __MACH__
28+ if (ts != NULL) {
29+ clock_serv_t cclock;
30+ mach_timespec_t mts;
31+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
32+ clock_get_time(cclock, &mts);
33+ mach_port_deallocate(mach_task_self(), cclock);
34+ ts->tv_sec = mts.tv_sec;
35+ ts->tv_nsec = mts.tv_nsec;
36+ }
37+#else
38 clock_gettime(CLOCK_REALTIME, ts);
39+#endif
40 return base;
41 }
42 return 0;
43diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
44index 1208ebb315..e1378fb1f0 100644
45--- a/src/egl/drivers/dri2/egl_dri2.c
46+++ b/src/egl/drivers/dri2/egl_dri2.c
47@@ -65,6 +65,11 @@
48 #include "util/u_vector.h"
49 #include "mapi/glapi/glapi.h"
50
51+#ifdef __MACH__
52+#include <mach/clock.h>
53+#include <mach/mach.h>
54+#endif
55+
56 #define NUM_ATTRIBS 12
57
58 static void
59@@ -3092,7 +3097,17 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
60
61 /* We override the clock to monotonic when creating the condition
62 * variable. */
63+#ifdef __MACH__
64+ clock_serv_t cclock;
65+ mach_timespec_t mts;
66+ host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
67+ clock_get_time(cclock, &mts);
68+ mach_port_deallocate(mach_task_self(), cclock);
69+ current.tv_sec = mts.tv_sec;
70+ current.tv_nsec = mts.tv_nsec;
71+#else
72 clock_gettime(CLOCK_MONOTONIC, ¤t);
73+#endif
74
75 /* calculating when to expire */
76 expire.tv_nsec = timeout % 1000000000L;