OSDN Git Service

* lto-stramer-out.c (produce_asm_for_decls): Correct accidentally commited change.
[pf3gnuchains/gcc-fork.git] / gcc / gthr-rtems.h
1 /* RTEMS threads compatibility routines for libgcc2 and libobjc.
2    by: Rosimildo da Silva( rdasilva@connecttel.com ) */
3 /* Compile this one with gcc.  */
4 /* Copyright (C) 1997, 1999, 2000, 2002, 2003, 2005, 2008, 2009
5    Free Software Foundation, Inc.
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
22
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
26 <http://www.gnu.org/licenses/>.  */
27
28 #ifndef GCC_GTHR_RTEMS_H
29 #define GCC_GTHR_RTEMS_H
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define __GTHREADS 1
36
37 #define __GTHREAD_ONCE_INIT  0
38 #define __GTHREAD_MUTEX_INIT_FUNCTION  rtems_gxx_mutex_init
39 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION  rtems_gxx_recursive_mutex_init
40
41 /* Avoid dependency on rtems specific headers.  */
42 typedef void *__gthread_key_t;
43 typedef int   __gthread_once_t;
44 typedef void *__gthread_mutex_t;
45 typedef void *__gthread_recursive_mutex_t;
46
47 /*
48  * External functions provided by RTEMS. They are very similar to their POSIX
49  * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS
50  * header files.
51  */
52
53 /* generic per task variables */
54 extern int rtems_gxx_once (__gthread_once_t *__once, void (*__func) (void));
55 extern int rtems_gxx_key_create (__gthread_key_t *__key, void (*__dtor) (void *));
56 extern int rtems_gxx_key_delete (__gthread_key_t __key);
57 extern void *rtems_gxx_getspecific (__gthread_key_t __key);
58 extern int rtems_gxx_setspecific (__gthread_key_t __key, const void *__ptr);
59
60 /* mutex support */
61 extern void rtems_gxx_mutex_init (__gthread_mutex_t *__mutex);
62 extern int rtems_gxx_mutex_destroy (__gthread_mutex_t *__mutex);
63 extern int rtems_gxx_mutex_lock (__gthread_mutex_t *__mutex);
64 extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *__mutex);
65 extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *__mutex);
66
67 /* recursive mutex support */
68 extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t *__mutex);
69 extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex);
70 extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex);
71 extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex);
72
73 /* RTEMS threading is always active */
74 static inline int
75 __gthread_active_p (void)
76 {
77   return 1;
78 }
79
80 /* Wrapper calls */
81 static inline int
82 __gthread_once (__gthread_once_t *__once, void (*__func) (void))
83 {
84    return rtems_gxx_once( __once, __func );
85 }
86
87 static inline int
88 __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
89 {
90   return rtems_gxx_key_create( __key, __dtor );
91 }
92
93 static inline int
94 __gthread_key_delete (__gthread_key_t __key)
95 {
96   return rtems_gxx_key_delete (__key);
97 }
98
99 static inline void *
100 __gthread_getspecific (__gthread_key_t __key)
101 {
102   return rtems_gxx_getspecific (__key);
103 }
104
105 static inline int
106 __gthread_setspecific (__gthread_key_t __key, const void *__ptr)
107 {
108   return rtems_gxx_setspecific (__key, __ptr);
109 }
110
111 static inline int
112 __gthread_mutex_destroy (__gthread_mutex_t *__mutex)
113 {
114   return rtems_gxx_mutex_destroy (__mutex);
115 }
116
117 static inline int
118 __gthread_mutex_lock (__gthread_mutex_t *__mutex)
119 {
120     return rtems_gxx_mutex_lock (__mutex);
121 }
122
123 static inline int
124 __gthread_mutex_trylock (__gthread_mutex_t *__mutex)
125 {
126     return rtems_gxx_mutex_trylock (__mutex);
127 }
128
129 static inline int
130 __gthread_mutex_unlock (__gthread_mutex_t *__mutex)
131 {
132     return rtems_gxx_mutex_unlock( __mutex );
133 }
134
135 static inline int
136 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
137 {
138     return rtems_gxx_recursive_mutex_lock (__mutex);
139 }
140
141 static inline int
142 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
143 {
144     return rtems_gxx_recursive_mutex_trylock (__mutex);
145 }
146
147 static inline int
148 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
149 {
150     return rtems_gxx_recursive_mutex_unlock( __mutex );
151 }
152
153 #ifdef __cplusplus
154 }
155 #endif
156
157 #endif /* ! GCC_GTHR_RTEMS_H */