2011-08-19 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / gthr-rtems.h
blobc5bd52292cf0a8f63714d2da633fe19a3aec8aec
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.
7 This file is part of GCC.
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.
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.
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.
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/>. */
28 #ifndef GCC_GTHR_RTEMS_H
29 #define GCC_GTHR_RTEMS_H
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 #define __GTHREADS 1
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
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;
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.
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);
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);
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);
73 /* RTEMS threading is always active */
74 static inline int
75 __gthread_active_p (void)
77 return 1;
80 /* Wrapper calls */
81 static inline int
82 __gthread_once (__gthread_once_t *__once, void (*__func) (void))
84 return rtems_gxx_once( __once, __func );
87 static inline int
88 __gthread_key_create (__gthread_key_t *__key, void (*__dtor) (void *))
90 return rtems_gxx_key_create( __key, __dtor );
93 static inline int
94 __gthread_key_delete (__gthread_key_t __key)
96 return rtems_gxx_key_delete (__key);
99 static inline void *
100 __gthread_getspecific (__gthread_key_t __key)
102 return rtems_gxx_getspecific (__key);
105 static inline int
106 __gthread_setspecific (__gthread_key_t __key, const void *__ptr)
108 return rtems_gxx_setspecific (__key, __ptr);
111 static inline int
112 __gthread_mutex_destroy (__gthread_mutex_t *__mutex)
114 return rtems_gxx_mutex_destroy (__mutex);
117 static inline int
118 __gthread_mutex_lock (__gthread_mutex_t *__mutex)
120 return rtems_gxx_mutex_lock (__mutex);
123 static inline int
124 __gthread_mutex_trylock (__gthread_mutex_t *__mutex)
126 return rtems_gxx_mutex_trylock (__mutex);
129 static inline int
130 __gthread_mutex_unlock (__gthread_mutex_t *__mutex)
132 return rtems_gxx_mutex_unlock( __mutex );
135 static inline int
136 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
138 return rtems_gxx_recursive_mutex_lock (__mutex);
141 static inline int
142 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
144 return rtems_gxx_recursive_mutex_trylock (__mutex);
147 static inline int
148 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
150 return rtems_gxx_recursive_mutex_unlock( __mutex );
153 #ifdef __cplusplus
155 #endif
157 #endif /* ! GCC_GTHR_RTEMS_H */