]> gcc.gnu.org Git - gcc.git/blame - gcc/gthr-vxworks.h
re PR c++/13684 (local static object variable constructed once but ctors and dtors...
[gcc.git] / gcc / gthr-vxworks.h
CommitLineData
15794a95 1/* Threads compatibility routines for libgcc2 and libobjc for VxWorks. */
7cc34889 2/* Compile this one with gcc. */
15794a95 3/* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
7cc34889
MS
4 Contributed by Mike Stump <mrs@wrs.com>.
5
1322177d 6This file is part of GCC.
7cc34889 7
1322177d
LB
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 2, or (at your option) any later
11version.
7cc34889 12
1322177d
LB
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
7cc34889
MS
17
18You should have received a copy of the GNU General Public License
1322177d
LB
19along with GCC; see the file COPYING. If not, write to the Free
20Software Foundation, 59 Temple Place - Suite 330, Boston, MA
2102111-1307, USA. */
7cc34889
MS
22
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. */
29
88657302
RH
30#ifndef GCC_GTHR_VXWORKS_H
31#define GCC_GTHR_VXWORKS_H
7cc34889 32
15794a95
L
33#ifdef _LIBOBJC
34
4977bab6
ZW
35/* libobjc requires the optional pthreads component. */
36#include "gthr-posix.h"
15794a95 37
4977bab6 38#else
7cc34889
MS
39
40#define __GTHREADS 1
4977bab6
ZW
41#define __gthread_active_p() 1
42
43/* Mutexes are easy, except that they need to be initialized at runtime. */
7cc34889 44
7cc34889 45#include <semLib.h>
7cc34889 46
7cc34889 47typedef SEM_ID __gthread_mutex_t;
40aac948
JM
48/* All VxWorks mutexes are recursive. */
49typedef SEM_ID __gthread_recursive_mutex_t;
4977bab6 50#define __GTHREAD_MUTEX_INIT_FUNCTION __gthread_mutex_init_function
40aac948 51#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION __gthread_recursive_mutex_init_function
7cc34889 52
4977bab6
ZW
53static inline void
54__gthread_mutex_init_function (__gthread_mutex_t *mutex)
7cc34889 55{
4977bab6 56 *mutex = semMCreate (SEM_Q_PRIORITY | SEM_INVERSION_SAFE | SEM_DELETE_SAFE);
7cc34889
MS
57}
58
7cc34889
MS
59static inline int
60__gthread_mutex_lock (__gthread_mutex_t *mutex)
61{
7cc34889
MS
62 return semTake (*mutex, WAIT_FOREVER);
63}
64
65static inline int
66__gthread_mutex_trylock (__gthread_mutex_t *mutex)
67{
7cc34889
MS
68 return semTake (*mutex, NO_WAIT);
69}
70
71static inline int
72__gthread_mutex_unlock (__gthread_mutex_t *mutex)
73{
7cc34889
MS
74 return semGive (*mutex);
75}
76
40aac948
JM
77static inline void
78__gthread_recursive_mutex_init_function (__gthread_recursive_mutex_t *mutex)
79{
80 __gthread_mutex_init_function (mutex);
81}
82
83static inline int
84__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
85{
86 return __gthread_mutex_lock (mutex);
87}
88
89static inline int
90__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
91{
92 return __gthread_mutex_trylock (mutex);
93}
94
95static inline int
96__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
97{
98 return __gthread_mutex_unlock (mutex);
99}
100
4977bab6
ZW
101/* pthread_once is complicated enough that it's implemented
102 out-of-line. See config/vxlib.c. */
103
104typedef struct
105{
106 volatile unsigned char busy;
107 volatile unsigned char done;
108}
109__gthread_once_t;
110
111#define __GTHREAD_ONCE_INIT { 0, 0 }
112
113extern int __gthread_once (__gthread_once_t *once, void (*func)(void));
114
115/* Thread-specific data requires a great deal of effort, since VxWorks
116 is not really set up for it. See config/vxlib.c for the gory
117 details. All the TSD routines are sufficiently complex that they
118 need to be implemented out of line. */
119
120typedef unsigned int __gthread_key_t;
121
122extern int __gthread_key_create (__gthread_key_t *keyp, void (*dtor)(void *));
123extern int __gthread_key_delete (__gthread_key_t key);
124
125extern void *__gthread_getspecific (__gthread_key_t key);
126extern int __gthread_setspecific (__gthread_key_t key, void *ptr);
127
128#endif /* not _LIBOBJC */
15794a95 129
4977bab6 130#endif /* gthr-vxworks.h */
This page took 1.637971 seconds and 5 git commands to generate.