summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-10-22 17:38:45 +0200
committerNicolai Hähnle <[email protected]>2017-11-09 11:57:22 +0100
commitf1a364878431c8c5f4fd38b40b9766449e49f552 (patch)
tree6ef17660b1942b4b28e1e7001e96334a11eac7b2 /src/egl
parentc50743f61c533fe8bfed0a432ef74fcf6b4cea24 (diff)
threads: update for late C11 changes
C11 threads were changed to use struct timespec instead of xtime, and thrd_sleep got a second argument. See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1554.htm and http://en.cppreference.com/w/c/thread/{thrd_sleep,cnd_timedwait,mtx_timedlock} Note that cnd_timedwait is spec'd to be relative to TIME_UTC / CLOCK_REALTIME. v2: Fix Windows build errors. Tested with a default Appveyor config that uses Visual Studio 2013. Judging from Brian's email and random internet sources, Visual Studio 2015 does have timespec and timespec_get, hence the _MSC_VER-based guard which I have not tested. Cc: Jose Fonseca <[email protected]> Cc: Brian Paul <[email protected]> Reviewed-by: Marek Olšák <[email protected]> (v1)
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index b486be74873..9e0feea9869 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -3064,10 +3064,6 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
struct dri2_egl_sync *dri2_sync = dri2_egl_sync(sync);
unsigned wait_flags = 0;
- /* timespecs for cnd_timedwait */
- struct timespec current;
- xtime expire;
-
EGLint ret = EGL_CONDITION_SATISFIED_KHR;
/* The EGL_KHR_fence_sync spec states:
@@ -3108,19 +3104,25 @@ dri2_client_wait_sync(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
} else {
/* if reusable sync has not been yet signaled */
if (dri2_sync->base.SyncStatus != EGL_SIGNALED_KHR) {
+ /* timespecs for cnd_timedwait */
+ struct timespec current;
+ struct timespec expire;
+
+ /* We override the clock to monotonic when creating the condition
+ * variable. */
clock_gettime(CLOCK_MONOTONIC, &current);
/* calculating when to expire */
- expire.nsec = timeout % 1000000000L;
- expire.sec = timeout / 1000000000L;
+ expire.tv_nsec = timeout % 1000000000L;
+ expire.tv_sec = timeout / 1000000000L;
- expire.nsec += current.tv_nsec;
- expire.sec += current.tv_sec;
+ expire.tv_nsec += current.tv_nsec;
+ expire.tv_sec += current.tv_sec;
/* expire.nsec now is a number between 0 and 1999999998 */
- if (expire.nsec > 999999999L) {
- expire.sec++;
- expire.nsec -= 1000000000L;
+ if (expire.tv_nsec > 999999999L) {
+ expire.tv_sec++;
+ expire.tv_nsec -= 1000000000L;
}
mtx_lock(&dri2_sync->mutex);