* loop-iv.c (determine_max_iter): New arg OLD_NITER. All callers
[official-gcc/alias-decl.git] / gcc / gthr-vxworks.h
blobe0ff957e4f4557e7085c1a72b565b38a86bc02dd
1 /* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 1997, 1999, 2000, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by Mike Stump <mrs@wrs.com>.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA. */
23 /* As a special exception, if you link this library with other files,
24 some of which are compiled with GCC, to produce an executable,
25 this library does not by itself cause the resulting executable
26 to be covered by the GNU General Public License.
27 This exception does not however invalidate any other reasons why
28 the executable file might be covered by the GNU General Public License. */
30 #ifndef GCC_GTHR_VXWORKS_H
31 #define GCC_GTHR_VXWORKS_H
33 #ifdef _LIBOBJC
35 /* libobjc requires the optional pthreads component. */
36 #include "gthr-posix.h"
38 #else
39 #ifdef __cplusplus
40 #define UNUSED(x)
41 #else
42 #define UNUSED(x) x __attribute__((unused))
43 #endif
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
49 #define __GTHREADS 1
50 #define __gthread_active_p() 1
52 /* Mutexes are easy, except that they need to be initialized at runtime. */
54 #include <semLib.h>
56 typedef SEM_ID __gthread_mutex_t;
57 /* All VxWorks mutexes are recursive. */
58 typedef SEM_ID __gthread_recursive_mutex_t;
59 #define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
60 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
62 static inline void
63 __gthread_mutex_init_function (__gthread_mutex_t *mutex)
65 *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
68 static inline int
69 __gthread_mutex_destroy (__gthread_mutex_t * UNUSED(mutex))
71 return 0;
74 static inline int
75 __gthread_mutex_lock (__gthread_mutex_t *mutex)
77 return semTake (*mutex, WAIT_FOREVER);
80 static inline int
81 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
83 return semTake (*mutex, NO_WAIT);
86 static inline int
87 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
89 return semGive (*mutex);
92 static inline void
93 __gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
95 __gthread_mutex_init_function (mutex);
98 static inline int
99 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
101 return __gthread_mutex_lock (mutex);
104 static inline int
105 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
107 return __gthread_mutex_trylock (mutex);
110 static inline int
111 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
113 return __gthread_mutex_unlock (mutex);
116 /* pthread_once is complicated enough that it's implemented
117 out-of-line. See config/vxlib.c. */
119 typedef struct
121 #ifndef __RTP__
122 volatile unsigned char busy;
123 #endif
124 volatile unsigned char done;
126 __gthread_once_t;
128 #ifndef __RTP__
129 # define __GTHREAD_ONCE_INIT { 0, 0 }
130 #else
131 # define __GTHREAD_ONCE_INIT { 0 }
132 #endif
134 extern int __gthread_once (__gthread_once_t *__once, void (*__func)(void));
136 /* Thread-specific data requires a great deal of effort, since VxWorks
137 is not really set up for it. See config/vxlib.c for the gory
138 details. All the TSD routines are sufficiently complex that they
139 need to be implemented out of line. */
141 typedef unsigned int __gthread_key_t;
143 extern int __gthread_key_create (__gthread_key_t *__keyp, void (*__dtor)(void *));
144 extern int __gthread_key_delete (__gthread_key_t __key);
146 extern void *__gthread_getspecific (__gthread_key_t __key);
147 extern int __gthread_setspecific (__gthread_key_t __key, void *__ptr);
149 #undef UNUSED
151 #ifdef __cplusplus
153 #endif
155 #endif /* not _LIBOBJC */
157 #endif /* gthr-vxworks.h */