gthr-rtems.h revision 110611
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, 2002, 2003 Free Software Foundation, Inc. 5 6This file is part of GCC. 7 8GCC is free software; you can redistribute it and/or modify it under 9the terms of the GNU General Public License as published by the Free 10Software Foundation; either version 2, or (at your option) any later 11version. 12 13GCC is distributed in the hope that it will be useful, but WITHOUT ANY 14WARRANTY; without even the implied warranty of MERCHANTABILITY or 15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 16for more details. 17 18You should have received a copy of the GNU General Public License 19along with GCC; see the file COPYING. If not, write to the Free 20Software Foundation, 59 Temple Place - Suite 330, Boston, MA 2102111-1307, USA. */ 22 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. */ 29 30#ifndef GCC_GTHR_RTEMS_H 31#define GCC_GTHR_RTEMS_H 32 33#ifdef __cplusplus 34extern "C" { 35#endif 36 37#define __GTHREADS 1 38 39#define __GTHREAD_ONCE_INIT 0 40#define __GTHREAD_MUTEX_INIT 0 41#define __GTHREAD_MUTEX_INIT_FUNCTION rtems_gxx_mutex_init 42 43/* avoid depedency on rtems specific headers */ 44typedef void *__gthread_key_t; 45typedef int __gthread_once_t; 46typedef void *__gthread_mutex_t; 47 48/* 49 * External functions provided by RTEMS. They are very similar to their POSIX 50 * counterparts. A "Wrapper API" is being use to avoid dependency on any RTEMS 51 * header files. 52 */ 53 54/* generic per task variables */ 55extern int rtems_gxx_once (__gthread_once_t *once, void (*func) (void)); 56extern int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *)); 57extern int rtems_gxx_key_dtor (__gthread_key_t key, void *ptr); 58extern int rtems_gxx_key_delete (__gthread_key_t key); 59extern void *rtems_gxx_getspecific (__gthread_key_t key); 60extern int rtems_gxx_setspecific (__gthread_key_t key, const void *ptr); 61 62/* mutex support */ 63extern void rtems_gxx_mutex_init (__gthread_mutex_t *mutex); 64extern int rtems_gxx_mutex_lock (__gthread_mutex_t *mutex); 65extern int rtems_gxx_mutex_trylock (__gthread_mutex_t *mutex); 66extern int rtems_gxx_mutex_unlock (__gthread_mutex_t *mutex); 67 68 69/* RTEMS threading is always active */ 70static inline int 71__gthread_active_p (void) 72{ 73 return 1; 74} 75 76/* Wrapper calls */ 77static inline int 78__gthread_once (__gthread_once_t *once, void (*func) (void)) 79{ 80 return rtems_gxx_once( once, func ); 81} 82 83static inline int 84__gthread_key_create (__gthread_key_t *key, void (*dtor) (void *)) 85{ 86 return rtems_gxx_key_create( key, dtor ); 87} 88 89static inline int 90__gthread_key_dtor (__gthread_key_t key, void *ptr) 91{ 92 return rtems_gxx_key_dtor(key, ptr); 93} 94 95static inline int 96__gthread_key_delete (__gthread_key_t key) 97{ 98 return rtems_gxx_key_delete (key); 99} 100 101static inline void * 102__gthread_getspecific (__gthread_key_t key) 103{ 104 return rtems_gxx_getspecific (key); 105} 106 107static inline int 108__gthread_setspecific (__gthread_key_t key, const void *ptr) 109{ 110 return rtems_gxx_setspecific (key, ptr); 111} 112 113static inline int 114__gthread_mutex_lock (__gthread_mutex_t *mutex) 115{ 116 return rtems_gxx_mutex_lock (mutex); 117} 118 119static inline int 120__gthread_mutex_trylock (__gthread_mutex_t *mutex) 121{ 122 return rtems_gxx_mutex_trylock (mutex); 123} 124 125static inline int 126__gthread_mutex_unlock (__gthread_mutex_t *mutex) 127{ 128 return rtems_gxx_mutex_unlock( mutex ); 129} 130 131#ifdef __cplusplus 132} 133#endif 134 135#endif /* ! GCC_GTHR_RTEMS_H */ 136