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
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 2, or (at your option) any later
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
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING. If not, write to the Free
21 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
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. */
31 #ifndef GCC_GTHR_RTEMS_H
32 #define GCC_GTHR_RTEMS_H
40 #define __GTHREAD_ONCE_INIT 0
41 #define __GTHREAD_MUTEX_INIT 0
42 #define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init
43 #define __GTHREAD_RECURSIVE_MUTEX_INIT_FUNCTION rtems_gxx_recursive_mutex_init
45 /* Avoid dependency on rtems specific headers. */
46 typedef void *__gthread_key_t
;
47 typedef int __gthread_once_t
;
48 typedef void *__gthread_mutex_t
;
49 typedef void *__gthread_recursive_mutex_t
;
52 * External functions provided by RTEMS. They are very similar to their POSIX
53 * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS
57 /* generic per task variables */
58 extern int rtems_gxx_once (__gthread_once_t
*once
, void (*func
) (void));
59 extern int rtems_gxx_key_create (__gthread_key_t
*key
, void (*dtor
) (void *));
60 extern int rtems_gxx_key_delete (__gthread_key_t key
);
61 extern void *rtems_gxx_getspecific (__gthread_key_t key
);
62 extern int rtems_gxx_setspecific (__gthread_key_t key
, const void *ptr
);
65 extern void rtems_gxx_mutex_init (__gthread_mutex_t
*mutex
);
66 extern int rtems_gxx_mutex_lock (__gthread_mutex_t
*mutex
);
67 extern int rtems_gxx_mutex_trylock (__gthread_mutex_t
*mutex
);
68 extern int rtems_gxx_mutex_unlock (__gthread_mutex_t
*mutex
);
70 /* recursive mutex support */
71 extern void rtems_gxx_recursive_mutex_init (__gthread_recursive_mutex_t
*mutex
);
72 extern int rtems_gxx_recursive_mutex_lock (__gthread_recursive_mutex_t
*mutex
);
73 extern int rtems_gxx_recursive_mutex_trylock (__gthread_recursive_mutex_t
*mutex
);
74 extern int rtems_gxx_recursive_mutex_unlock (__gthread_recursive_mutex_t
*mutex
);
76 /* RTEMS threading is always active */
78 __gthread_active_p (void)
85 __gthread_once (__gthread_once_t
*once
, void (*func
) (void))
87 return rtems_gxx_once( once
, func
);
91 __gthread_key_create (__gthread_key_t
*key
, void (*dtor
) (void *))
93 return rtems_gxx_key_create( key
, dtor
);
97 __gthread_key_delete (__gthread_key_t key
)
99 return rtems_gxx_key_delete (key
);
103 __gthread_getspecific (__gthread_key_t key
)
105 return rtems_gxx_getspecific (key
);
109 __gthread_setspecific (__gthread_key_t key
, const void *ptr
)
111 return rtems_gxx_setspecific (key
, ptr
);
115 __gthread_mutex_lock (__gthread_mutex_t
*mutex
)
117 return rtems_gxx_mutex_lock (mutex
);
121 __gthread_mutex_trylock (__gthread_mutex_t
*mutex
)
123 return rtems_gxx_mutex_trylock (mutex
);
127 __gthread_mutex_unlock (__gthread_mutex_t
*mutex
)
129 return rtems_gxx_mutex_unlock( mutex
);
133 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*mutex
)
135 return rtems_gxx_recursive_mutex_lock (mutex
);
139 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*mutex
)
141 return rtems_gxx_recursive_mutex_trylock (mutex
);
145 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*mutex
)
147 return rtems_gxx_recursive_mutex_unlock( mutex
);
154 #endif /* ! GCC_GTHR_RTEMS_H */