Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:21

0001 /*-
0002  * Copyright (c) 2011 Ed Schouten <ed@FreeBSD.org>
0003  * Copyright (c) 2015 embedded brains GmbH & Co. KG
0004  * All rights reserved.
0005  *
0006  * Redistribution and use in source and binary forms, with or without
0007  * modification, are permitted provided that the following conditions
0008  * are met:
0009  * 1. Redistributions of source code must retain the above copyright
0010  *    notice, this list of conditions and the following disclaimer.
0011  * 2. Redistributions in binary form must reproduce the above copyright
0012  *    notice, this list of conditions and the following disclaimer in the
0013  *    documentation and/or other materials provided with the distribution.
0014  *
0015  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
0016  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0017  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0018  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
0019  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0020  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0021  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0022  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
0023  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0024  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
0025  * SUCH DAMAGE.
0026  *
0027  * $FreeBSD r228904 2011-12-26T21:51:53Z$
0028  */
0029 
0030 #include <threads.h>
0031 #include <errno.h>
0032 
0033 int
0034 cnd_broadcast(cnd_t *cond)
0035 {
0036 
0037     _Condition_Broadcast(cond);
0038     return (thrd_success);
0039 }
0040 
0041 void
0042 cnd_destroy(cnd_t *cond)
0043 {
0044 
0045     _Condition_Destroy(cond);
0046 }
0047 
0048 int
0049 cnd_init(cnd_t *cond)
0050 {
0051 
0052     _Condition_Initialize(cond);
0053     return (thrd_success);
0054 }
0055 
0056 int
0057 cnd_signal(cnd_t *cond)
0058 {
0059 
0060     _Condition_Signal(cond);
0061     return (thrd_success);
0062 }
0063 
0064 int
0065 cnd_timedwait(cnd_t *__restrict cond, mtx_t *__restrict mtx,
0066     const struct timespec *__restrict ts)
0067 {
0068 
0069     switch (_Condition_Wait_recursive_timed(cond, mtx, ts)) {
0070     case 0:
0071         return (thrd_success);
0072     case ETIMEDOUT:
0073         return (thrd_timedout);
0074     default:
0075         return (thrd_error);
0076     }
0077 }
0078 
0079 int
0080 cnd_wait(cnd_t *cond, mtx_t *mtx)
0081 {
0082 
0083     _Condition_Wait_recursive(cond, mtx);
0084     return (thrd_success);
0085 }