diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-09-10 17:12:06 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2015-10-14 07:47:12 +0200 |
commit | cff773f5802d0b5b4d007be3f6f4adbb04ce0d41 (patch) | |
tree | afada47b1eb3d9ebbe755c8cd7eca6e3e9eec632 /cpukit/libstdthreads/cnd.c | |
parent | libstdthreads: Import from FreeBSD (diff) | |
download | rtems-cff773f5802d0b5b4d007be3f6f4adbb04ce0d41.tar.bz2 |
libstdthreads: Add C11 threads
Diffstat (limited to 'cpukit/libstdthreads/cnd.c')
-rw-r--r-- | cpukit/libstdthreads/cnd.c | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/cpukit/libstdthreads/cnd.c b/cpukit/libstdthreads/cnd.c index cccf728c77..7ed750aee4 100644 --- a/cpukit/libstdthreads/cnd.c +++ b/cpukit/libstdthreads/cnd.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org> + * Copyright (c) 2015 embedded brains GmbH <info@embedded-brains.de> * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,20 +27,14 @@ * $FreeBSD r228904 2011-12-26T21:51:53Z$ */ -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - +#include <threads.h> #include <errno.h> -#include <pthread.h> - -#include "threads.h" int cnd_broadcast(cnd_t *cond) { - if (pthread_cond_broadcast(cond) != 0) - return (thrd_error); + _Condition_Broadcast(cond); return (thrd_success); } @@ -47,29 +42,22 @@ void cnd_destroy(cnd_t *cond) { - (void)pthread_cond_destroy(cond); + _Condition_Destroy(cond); } int cnd_init(cnd_t *cond) { - switch (pthread_cond_init(cond, NULL)) { - case 0: - return (thrd_success); - case ENOMEM: - return (thrd_nomem); - default: - return (thrd_error); - } + _Condition_Initialize(cond); + return (thrd_success); } int cnd_signal(cnd_t *cond) { - if (pthread_cond_signal(cond) != 0) - return (thrd_error); + _Condition_Signal(cond); return (thrd_success); } @@ -78,7 +66,7 @@ cnd_timedwait(cnd_t *restrict cond, mtx_t *restrict mtx, const struct timespec *restrict ts) { - switch (pthread_cond_timedwait(cond, mtx, ts)) { + switch (_Condition_Wait_recursive_timed(cond, mtx, ts)) { case 0: return (thrd_success); case ETIMEDOUT: @@ -92,7 +80,6 @@ int cnd_wait(cnd_t *cond, mtx_t *mtx) { - if (pthread_cond_wait(cond, mtx) != 0) - return (thrd_error); + _Condition_Wait_recursive(cond, mtx); return (thrd_success); } |