summaryrefslogtreecommitdiff
path: root/src/thread/cnd_timedwait.c
diff options
context:
space:
mode:
authorJens Gustedt <Jens.Gustedt@inria.fr>2014-09-06 22:27:45 -0400
committerRich Felker <dalias@aerifal.cx>2014-09-06 22:27:45 -0400
commit14397cec2c8429b504b17aaf92509b48da3681b9 (patch)
tree481ed8c5e1d748e88d263b0b20c1d2ccc934051e /src/thread/cnd_timedwait.c
parent8b0472932c1cb8cb2cc46322b21c0c4e21848522 (diff)
downloadmusl-14397cec2c8429b504b17aaf92509b48da3681b9.tar.gz
add C11 condition variable functions
Because of the clear separation for private pthread_cond_t these interfaces are quite simple and direct.
Diffstat (limited to 'src/thread/cnd_timedwait.c')
-rw-r--r--src/thread/cnd_timedwait.c15
1 files changed, 15 insertions, 0 deletions
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 <threads.h>
+#include <errno.h>
+
+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;
+ }
+}