ada: Fix internal error on 'Address of task component
[official-gcc.git] / libgcc / config / gthr-vxworks-cond.c
blob4a0e76db607f6bce72d8dc467bfd405f618a8e6d
1 /* Copyright (C) 2002-2023 Free Software Foundation, Inc.
3 This file is part of GCC.
5 GCC is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 3, or (at your option) any later
8 version.
10 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 for more details.
15 Under Section 7 of GPL version 3, you are granted additional
16 permissions described in the GCC Runtime Library Exception, version
17 3.1, as published by the Free Software Foundation.
19 You should have received a copy of the GNU General Public License and
20 a copy of the GCC Runtime Library Exception along with this program;
21 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
22 <http://www.gnu.org/licenses/>. */
24 /* Threads compatibility routines for libgcc2 for VxWorks.
26 This file implements the GTHREAD_HAS_COND part of the interface
27 exposed by gthr-vxworks.h. */
29 #include "gthr.h"
31 #if __GTHREAD_HAS_COND
33 #include <taskLib.h>
35 /* --------------------------- Condition Variables ------------------------ */
37 void
38 __gthread_cond_init (__gthread_cond_t *cond)
40 if (!cond)
41 return;
42 *cond = semBCreate (SEM_Q_FIFO, SEM_EMPTY);
45 int
46 __gthread_cond_destroy (__gthread_cond_t *cond)
48 if (!cond)
49 return ERROR;
50 return __CHECK_RESULT (semDelete (*cond));
53 int
54 __gthread_cond_broadcast (__gthread_cond_t *cond)
56 if (!cond)
57 return ERROR;
59 return __CHECK_RESULT (semFlush (*cond));
62 int
63 __gthread_cond_wait (__gthread_cond_t *cond,
64 __gthread_mutex_t *mutex)
66 if (!cond)
67 return ERROR;
69 if (!mutex)
70 return ERROR;
72 int ret = __CHECK_RESULT (semExchange (*mutex, *cond, WAIT_FOREVER));
74 __RETURN_ERRNO_IF_NOT_OK (semTake (*mutex, WAIT_FOREVER));
76 return ret;
79 int
80 __gthread_cond_wait_recursive (__gthread_cond_t *cond,
81 __gthread_recursive_mutex_t *mutex)
83 return __gthread_cond_wait (cond, mutex);
86 #endif