1/* Copyright (C) 2002-2020 Free Software Foundation, Inc. 2 3This file is part of GCC. 4 5GCC is free software; you can redistribute it and/or modify it under 6the terms of the GNU General Public License as published by the Free 7Software Foundation; either version 3, or (at your option) any later 8version. 9 10GCC is distributed in the hope that it will be useful, but WITHOUT ANY 11WARRANTY; without even the implied warranty of MERCHANTABILITY or 12FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13for more details. 14 15Under Section 7 of GPL version 3, you are granted additional 16permissions described in the GCC Runtime Library Exception, version 173.1, as published by the Free Software Foundation. 18 19You should have received a copy of the GNU General Public License and 20a copy of the GCC Runtime Library Exception along with this program; 21see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 22<http://www.gnu.org/licenses/>. */ 23 24/* Threads compatibility routines for libgcc2 for VxWorks. 25 26 This file implements the GTHREAD_HAS_COND part of the interface 27 exposed by gthr-vxworks.h. */ 28 29#include "gthr.h" 30#include <taskLib.h> 31 32/* --------------------------- Condition Variables ------------------------ */ 33 34void 35__gthread_cond_init (__gthread_cond_t *cond) 36{ 37 if (!cond) 38 return; 39 *cond = semBCreate (SEM_Q_FIFO, SEM_EMPTY); 40} 41 42int 43__gthread_cond_destroy (__gthread_cond_t *cond) 44{ 45 if (!cond) 46 return ERROR; 47 return __CHECK_RESULT (semDelete (*cond)); 48} 49 50int 51__gthread_cond_broadcast (__gthread_cond_t *cond) 52{ 53 if (!cond) 54 return ERROR; 55 56 return __CHECK_RESULT (semFlush (*cond)); 57} 58 59int 60__gthread_cond_wait (__gthread_cond_t *cond, 61 __gthread_mutex_t *mutex) 62{ 63 if (!cond) 64 return ERROR; 65 66 if (!mutex) 67 return ERROR; 68 69 __RETURN_ERRNO_IF_NOT_OK (semGive (*mutex)); 70 71 __RETURN_ERRNO_IF_NOT_OK (semTake (*cond, WAIT_FOREVER)); 72 73 __RETURN_ERRNO_IF_NOT_OK (semTake (*mutex, WAIT_FOREVER)); 74 75 return OK; 76} 77 78int 79__gthread_cond_wait_recursive (__gthread_cond_t *cond, 80 __gthread_recursive_mutex_t *mutex) 81{ 82 return __gthread_cond_wait (cond, mutex); 83} 84