]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/gthr-rtems.h
re PR testsuite/27476 (ACATS: Ada testsuite Bourne shell compatibility problem on...
[thirdparty/gcc.git] / gcc / gthr-rtems.h
CommitLineData
fbe5a4a6 1/* RTEMS threads compatibility routines for libgcc2 and libobjc.
bc98ef7f
JS
2 by: Rosimildo da Silva( rdasilva@connecttel.com ) */
3/* Compile this one with gcc. */
5d58d2f8
RC
4/* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005
5 Free Software Foundation, Inc.
bc98ef7f 6
1322177d 7This file is part of GCC.
bc98ef7f 8
1322177d
LB
9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 2, or (at your option) any later
12version.
bc98ef7f 13
1322177d
LB
14GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
bc98ef7f
JS
18
19You should have received a copy of the GNU General Public License
1322177d 20along with GCC; see the file COPYING. If not, write to the Free
366ccddb
KC
21Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
2202110-1301, USA. */
bc98ef7f
JS
23
24/* As a special exception, if you link this library with other files,
25 some of which are compiled with GCC, to produce an executable,
26 this library does not by itself cause the resulting executable
27 to be covered by the GNU General Public License.
28 This exception does not however invalidate any other reasons why
29 the executable file might be covered by the GNU General Public License. */
30
88657302
RH
31#ifndef GCC_GTHR_RTEMS_H
32#define GCC_GTHR_RTEMS_H
bc98ef7f 33
f22b4bc4
JS
34#ifdef __cplusplus
35extern "C" {
36#endif
bc98ef7f
JS
37
38#define __GTHREADS 1
39
40#define __GTHREAD_ONCE_INIT 0
0680c8fb 41#define __GTHREAD_MUTEX_INIT 0
bc98ef7f 42#define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init
5d58d2f8 43#define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION rtems_gxx_recursive_mutex_init
bc98ef7f 44
fbe5a4a6 45/* Avoid dependency on rtems specific headers. */
bc98ef7f
JS
46typedef void *__gthread_key_t;
47typedef int __gthread_once_t;
48typedef void *__gthread_mutex_t;
5d58d2f8 49typedef void *__gthread_recursive_mutex_t;
bc98ef7f
JS
50
51/*
589005ff 52 * External functions provided by RTEMS. They are very similar to their POSIX
bc98ef7f
JS
53 * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS
54 * header files.
55 */
56
57/* generic per task variables */
1b61552b 58extern int rtems_gxx_once (__gthread_once_t *once, void (*func) (void));
bc98ef7f 59extern int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *));
bc98ef7f
JS
60extern int rtems_gxx_key_delete (__gthread_key_t key);
61extern void *rtems_gxx_getspecific (__gthread_key_t key);
62extern int rtems_gxx_setspecific (__gthread_key_t key, const void *ptr);
63
64/* mutex support */
65extern void rtems_gxx_mutex_init (__gthread_mutex_t *mutex);
66extern int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex);
67extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex);
68extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex);
69
5d58d2f8
RC
70/* recursive mutex support */
71extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *mutex);
72extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex);
73extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex);
74extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex);
bc98ef7f 75
e08f13ee
JS
76/* RTEMS threading is always active */
77static inline int
78__gthread_active_p (void)
79{
80 return 1;
81}
82
bc98ef7f
JS
83/* Wrapper calls */
84static inline int
1b61552b 85__gthread_once (__gthread_once_t *once, void (*func) (void))
bc98ef7f
JS
86{
87 return rtems_gxx_once( once, func );
88}
89
90static inline int
91__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
92{
93 return rtems_gxx_key_create( key, dtor );
94}
95
bc98ef7f
JS
96static inline int
97__gthread_key_delete (__gthread_key_t key)
98{
99 return rtems_gxx_key_delete (key);
100}
101
102static inline void *
103__gthread_getspecific (__gthread_key_t key)
104{
105 return rtems_gxx_getspecific (key);
106}
107
108static inline int
109__gthread_setspecific (__gthread_key_t key, const void *ptr)
110{
111 return rtems_gxx_setspecific (key, ptr);
112}
113
114static inline int
115__gthread_mutex_lock (__gthread_mutex_t *mutex)
116{
117 return rtems_gxx_mutex_lock (mutex);
118}
119
120static inline int
121__gthread_mutex_trylock (__gthread_mutex_t *mutex)
122{
123 return rtems_gxx_mutex_trylock (mutex);
124}
125
126static inline int
127__gthread_mutex_unlock (__gthread_mutex_t *mutex)
128{
129 return rtems_gxx_mutex_unlock( mutex );
130}
131
5d58d2f8
RC
132static inline int
133__gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *mutex)
134{
135 return rtems_gxx_recursive_mutex_lock (mutex);
136}
137
138static inline int
139__gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *mutex)
140{
141 return rtems_gxx_recursive_mutex_trylock (mutex);
142}
143
144static inline int
145__gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *mutex)
146{
147 return rtems_gxx_recursive_mutex_unlock( mutex );
148}
149
f22b4bc4
JS
150#ifdef __cplusplus
151}
152#endif
153
88657302 154#endif /* ! GCC_GTHR_RTEMS_H */