From 14397cec2c8429b504b17aaf92509b48da3681b9 Mon Sep 17 00:00:00 2001 From: Jens Gustedt Date: Sat, 6 Sep 2014 22:27:45 -0400 Subject: add C11 condition variable functions Because of the clear separation for private pthread_cond_t these interfaces are quite simple and direct. --- src/thread/cnd_timedwait.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/thread/cnd_timedwait.c (limited to 'src/thread/cnd_timedwait.c') diff --git a/src/thread/cnd_timedwait.c b/src/thread/cnd_timedwait.c new file mode 100644 index 00000000..59976793 --- /dev/null +++ b/src/thread/cnd_timedwait.c @@ -0,0 +1,15 @@ +#include +#include + +int __pthread_cond_timedwait(cnd_t *restrict, mtx_t *restrict, const struct timespec *restrict); + +int cnd_timedwait(cnd_t *restrict c, mtx_t *restrict m, const struct timespec *restrict ts) +{ + int ret = __pthread_cond_timedwait(c, m, ts); + switch (ret) { + /* May also return EINVAL or EPERM. */ + default: return thrd_error; + case 0: return thrd_success; + case ETIMEDOUT: return thrd_timedout; + } +} -- cgit v1.2.1