* extend.texi: Improve documentation of volatile asms.
[official-gcc.git] / gcc / gthr-rtems.h
blob05400c57a3ce1a650310079040502a3778dacc2e
1 /* RTEMS threads compatibily 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 Free Software Foundation, Inc.
6 This file is part of GNU CC.
8 GNU CC is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 GNU CC is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GNU CC; see the file COPYING. If not, write to
20 the Free Software Foundation, 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, 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 __gthr_rtems_h
31 #define __gthr_rtems_h
34 #define __GTHREADS 1
36 #define __GTHREAD_ONCE_INIT 0
37 #define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init
39 /* avoid depedency on rtems specific headers */
40 typedef void *__gthread_key_t;
41 typedef int __gthread_once_t;
42 typedef void *__gthread_mutex_t;
45 * External functions provided by RTEMS. They are very similar to their POSIX
46 * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS
47 * header files.
50 /* generic per task variables */
51 extern int rtems_gxx_once (__gthread_once_t *once, void (*func) ());
52 extern int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *));
53 extern int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr);
54 extern int rtems_gxx_key_delete (__gthread_key_t key);
55 extern void *rtems_gxx_getspecific (__gthread_key_t key);
56 extern int rtems_gxx_setspecific (__gthread_key_t key, const void *ptr);
58 /* mutex support */
59 extern void rtems_gxx_mutex_init (__gthread_mutex_t *mutex);
60 extern int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex);
61 extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex);
62 extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex);
65 /* Wrapper calls */
66 static inline int
67 __gthread_once (__gthread_once_t *once, void (*func) ())
69 return rtems_gxx_once( once, func );
72 static inline int
73 __gthread_key_create (__gthread_key_t *key, void (*dtor) (void *))
75 return rtems_gxx_key_create( key, dtor );
78 static inline int
79 __gthread_key_dtor (__gthread_key_t key, void *ptr)
81 return rtems_gxx_key_dtor(key, ptr);
84 static inline int
85 __gthread_key_delete (__gthread_key_t key)
87 return rtems_gxx_key_delete (key);
90 static inline void *
91 __gthread_getspecific (__gthread_key_t key)
93 return rtems_gxx_getspecific (key);
96 static inline int
97 __gthread_setspecific (__gthread_key_t key, const void *ptr)
99 return rtems_gxx_setspecific (key, ptr);
102 static inline int
103 __gthread_mutex_lock (__gthread_mutex_t *mutex)
105 return rtems_gxx_mutex_lock (mutex);
108 static inline int
109 __gthread_mutex_trylock (__gthread_mutex_t *mutex)
111 return rtems_gxx_mutex_trylock (mutex);
114 static inline int
115 __gthread_mutex_unlock (__gthread_mutex_t *mutex)
117 return rtems_gxx_mutex_unlock( mutex );
120 #endif /* __gthr_rtems_h */