118a5822eSThomas Veerman /* This file is automatically generated. DO NOT EDIT! */
2*0a6a1f1dSLionel Sambuc /* Generated from: NetBSD: mknative-gcc,v 1.70 2013/05/05 07:11:34 skrll Exp */
3*0a6a1f1dSLionel Sambuc /* Generated from: NetBSD: mknative.common,v 1.8 2006/05/26 19:17:21 mrg Exp */
418a5822eSThomas Veerman
518a5822eSThomas Veerman /* Threads compatibility routines for libgcc2 and libobjc. */
618a5822eSThomas Veerman /* Compile this one with gcc. */
7*0a6a1f1dSLionel Sambuc /* Copyright (C) 1997-2013 Free Software Foundation, Inc.
818a5822eSThomas Veerman
918a5822eSThomas Veerman This file is part of GCC.
1018a5822eSThomas Veerman
1118a5822eSThomas Veerman GCC is free software; you can redistribute it and/or modify it under
1218a5822eSThomas Veerman the terms of the GNU General Public License as published by the Free
1318a5822eSThomas Veerman Software Foundation; either version 3, or (at your option) any later
1418a5822eSThomas Veerman version.
1518a5822eSThomas Veerman
1618a5822eSThomas Veerman GCC is distributed in the hope that it will be useful, but WITHOUT ANY
1718a5822eSThomas Veerman WARRANTY; without even the implied warranty of MERCHANTABILITY or
1818a5822eSThomas Veerman FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1918a5822eSThomas Veerman for more details.
2018a5822eSThomas Veerman
2118a5822eSThomas Veerman Under Section 7 of GPL version 3, you are granted additional
2218a5822eSThomas Veerman permissions described in the GCC Runtime Library Exception, version
2318a5822eSThomas Veerman 3.1, as published by the Free Software Foundation.
2418a5822eSThomas Veerman
2518a5822eSThomas Veerman You should have received a copy of the GNU General Public License and
2618a5822eSThomas Veerman a copy of the GCC Runtime Library Exception along with this program;
2718a5822eSThomas Veerman see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
2818a5822eSThomas Veerman <http://www.gnu.org/licenses/>. */
2918a5822eSThomas Veerman
3018a5822eSThomas Veerman #ifndef _GLIBCXX_GCC_GTHR_SINGLE_H
3118a5822eSThomas Veerman #define _GLIBCXX_GCC_GTHR_SINGLE_H
3218a5822eSThomas Veerman
3318a5822eSThomas Veerman /* Just provide compatibility for mutex handling. */
3418a5822eSThomas Veerman
3518a5822eSThomas Veerman typedef int __gthread_key_t;
3618a5822eSThomas Veerman typedef int __gthread_once_t;
3718a5822eSThomas Veerman typedef int __gthread_mutex_t;
3818a5822eSThomas Veerman typedef int __gthread_recursive_mutex_t;
3918a5822eSThomas Veerman
4018a5822eSThomas Veerman #define __GTHREAD_ONCE_INIT 0
4118a5822eSThomas Veerman #define __GTHREAD_MUTEX_INIT 0
42*0a6a1f1dSLionel Sambuc #define __GTHREAD_MUTEX_INIT_FUNCTION(mx)
4318a5822eSThomas Veerman #define __GTHREAD_RECURSIVE_MUTEX_INIT 0
4418a5822eSThomas Veerman
4518a5822eSThomas Veerman #define _GLIBCXX_UNUSED __attribute__((unused))
4618a5822eSThomas Veerman
4718a5822eSThomas Veerman #ifdef _LIBOBJC
4818a5822eSThomas Veerman
4918a5822eSThomas Veerman /* Thread local storage for a single thread */
5018a5822eSThomas Veerman static void *thread_local_storage = NULL;
5118a5822eSThomas Veerman
5218a5822eSThomas Veerman /* Backend initialization functions */
5318a5822eSThomas Veerman
5418a5822eSThomas Veerman /* Initialize the threads subsystem. */
5518a5822eSThomas Veerman static inline int
__gthread_objc_init_thread_system(void)5618a5822eSThomas Veerman __gthread_objc_init_thread_system (void)
5718a5822eSThomas Veerman {
5818a5822eSThomas Veerman /* No thread support available */
5918a5822eSThomas Veerman return -1;
6018a5822eSThomas Veerman }
6118a5822eSThomas Veerman
6218a5822eSThomas Veerman /* Close the threads subsystem. */
6318a5822eSThomas Veerman static inline int
__gthread_objc_close_thread_system(void)6418a5822eSThomas Veerman __gthread_objc_close_thread_system (void)
6518a5822eSThomas Veerman {
6618a5822eSThomas Veerman /* No thread support available */
6718a5822eSThomas Veerman return -1;
6818a5822eSThomas Veerman }
6918a5822eSThomas Veerman
7018a5822eSThomas Veerman /* Backend thread functions */
7118a5822eSThomas Veerman
7218a5822eSThomas Veerman /* Create a new thread of execution. */
7318a5822eSThomas Veerman static inline objc_thread_t
__gthread_objc_thread_detach(void (* func)(void *),void * arg _GLIBCXX_UNUSED)7418a5822eSThomas Veerman __gthread_objc_thread_detach (void (* func)(void *), void * arg _GLIBCXX_UNUSED)
7518a5822eSThomas Veerman {
7618a5822eSThomas Veerman /* No thread support available */
7718a5822eSThomas Veerman return NULL;
7818a5822eSThomas Veerman }
7918a5822eSThomas Veerman
8018a5822eSThomas Veerman /* Set the current thread's priority. */
8118a5822eSThomas Veerman static inline int
__gthread_objc_thread_set_priority(int priority _GLIBCXX_UNUSED)8218a5822eSThomas Veerman __gthread_objc_thread_set_priority (int priority _GLIBCXX_UNUSED)
8318a5822eSThomas Veerman {
8418a5822eSThomas Veerman /* No thread support available */
8518a5822eSThomas Veerman return -1;
8618a5822eSThomas Veerman }
8718a5822eSThomas Veerman
8818a5822eSThomas Veerman /* Return the current thread's priority. */
8918a5822eSThomas Veerman static inline int
__gthread_objc_thread_get_priority(void)9018a5822eSThomas Veerman __gthread_objc_thread_get_priority (void)
9118a5822eSThomas Veerman {
9218a5822eSThomas Veerman return OBJC_THREAD_INTERACTIVE_PRIORITY;
9318a5822eSThomas Veerman }
9418a5822eSThomas Veerman
9518a5822eSThomas Veerman /* Yield our process time to another thread. */
9618a5822eSThomas Veerman static inline void
__gthread_objc_thread_yield(void)9718a5822eSThomas Veerman __gthread_objc_thread_yield (void)
9818a5822eSThomas Veerman {
9918a5822eSThomas Veerman return;
10018a5822eSThomas Veerman }
10118a5822eSThomas Veerman
10218a5822eSThomas Veerman /* Terminate the current thread. */
10318a5822eSThomas Veerman static inline int
__gthread_objc_thread_exit(void)10418a5822eSThomas Veerman __gthread_objc_thread_exit (void)
10518a5822eSThomas Veerman {
10618a5822eSThomas Veerman /* No thread support available */
10718a5822eSThomas Veerman /* Should we really exit the program */
10818a5822eSThomas Veerman /* exit (&__objc_thread_exit_status); */
10918a5822eSThomas Veerman return -1;
11018a5822eSThomas Veerman }
11118a5822eSThomas Veerman
11218a5822eSThomas Veerman /* Returns an integer value which uniquely describes a thread. */
11318a5822eSThomas Veerman static inline objc_thread_t
__gthread_objc_thread_id(void)11418a5822eSThomas Veerman __gthread_objc_thread_id (void)
11518a5822eSThomas Veerman {
11618a5822eSThomas Veerman /* No thread support, use 1. */
11718a5822eSThomas Veerman return (objc_thread_t) 1;
11818a5822eSThomas Veerman }
11918a5822eSThomas Veerman
12018a5822eSThomas Veerman /* Sets the thread's local storage pointer. */
12118a5822eSThomas Veerman static inline int
__gthread_objc_thread_set_data(void * value)12218a5822eSThomas Veerman __gthread_objc_thread_set_data (void *value)
12318a5822eSThomas Veerman {
12418a5822eSThomas Veerman thread_local_storage = value;
12518a5822eSThomas Veerman return 0;
12618a5822eSThomas Veerman }
12718a5822eSThomas Veerman
12818a5822eSThomas Veerman /* Returns the thread's local storage pointer. */
12918a5822eSThomas Veerman static inline void *
__gthread_objc_thread_get_data(void)13018a5822eSThomas Veerman __gthread_objc_thread_get_data (void)
13118a5822eSThomas Veerman {
13218a5822eSThomas Veerman return thread_local_storage;
13318a5822eSThomas Veerman }
13418a5822eSThomas Veerman
13518a5822eSThomas Veerman /* Backend mutex functions */
13618a5822eSThomas Veerman
13718a5822eSThomas Veerman /* Allocate a mutex. */
13818a5822eSThomas Veerman static inline int
__gthread_objc_mutex_allocate(objc_mutex_t mutex _GLIBCXX_UNUSED)13918a5822eSThomas Veerman __gthread_objc_mutex_allocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
14018a5822eSThomas Veerman {
14118a5822eSThomas Veerman return 0;
14218a5822eSThomas Veerman }
14318a5822eSThomas Veerman
14418a5822eSThomas Veerman /* Deallocate a mutex. */
14518a5822eSThomas Veerman static inline int
__gthread_objc_mutex_deallocate(objc_mutex_t mutex _GLIBCXX_UNUSED)14618a5822eSThomas Veerman __gthread_objc_mutex_deallocate (objc_mutex_t mutex _GLIBCXX_UNUSED)
14718a5822eSThomas Veerman {
14818a5822eSThomas Veerman return 0;
14918a5822eSThomas Veerman }
15018a5822eSThomas Veerman
15118a5822eSThomas Veerman /* Grab a lock on a mutex. */
15218a5822eSThomas Veerman static inline int
__gthread_objc_mutex_lock(objc_mutex_t mutex _GLIBCXX_UNUSED)15318a5822eSThomas Veerman __gthread_objc_mutex_lock (objc_mutex_t mutex _GLIBCXX_UNUSED)
15418a5822eSThomas Veerman {
15518a5822eSThomas Veerman /* There can only be one thread, so we always get the lock */
15618a5822eSThomas Veerman return 0;
15718a5822eSThomas Veerman }
15818a5822eSThomas Veerman
15918a5822eSThomas Veerman /* Try to grab a lock on a mutex. */
16018a5822eSThomas Veerman static inline int
__gthread_objc_mutex_trylock(objc_mutex_t mutex _GLIBCXX_UNUSED)16118a5822eSThomas Veerman __gthread_objc_mutex_trylock (objc_mutex_t mutex _GLIBCXX_UNUSED)
16218a5822eSThomas Veerman {
16318a5822eSThomas Veerman /* There can only be one thread, so we always get the lock */
16418a5822eSThomas Veerman return 0;
16518a5822eSThomas Veerman }
16618a5822eSThomas Veerman
16718a5822eSThomas Veerman /* Unlock the mutex */
16818a5822eSThomas Veerman static inline int
__gthread_objc_mutex_unlock(objc_mutex_t mutex _GLIBCXX_UNUSED)16918a5822eSThomas Veerman __gthread_objc_mutex_unlock (objc_mutex_t mutex _GLIBCXX_UNUSED)
17018a5822eSThomas Veerman {
17118a5822eSThomas Veerman return 0;
17218a5822eSThomas Veerman }
17318a5822eSThomas Veerman
17418a5822eSThomas Veerman /* Backend condition mutex functions */
17518a5822eSThomas Veerman
17618a5822eSThomas Veerman /* Allocate a condition. */
17718a5822eSThomas Veerman static inline int
__gthread_objc_condition_allocate(objc_condition_t condition _GLIBCXX_UNUSED)17818a5822eSThomas Veerman __gthread_objc_condition_allocate (objc_condition_t condition _GLIBCXX_UNUSED)
17918a5822eSThomas Veerman {
18018a5822eSThomas Veerman return 0;
18118a5822eSThomas Veerman }
18218a5822eSThomas Veerman
18318a5822eSThomas Veerman /* Deallocate a condition. */
18418a5822eSThomas Veerman static inline int
__gthread_objc_condition_deallocate(objc_condition_t condition _GLIBCXX_UNUSED)18518a5822eSThomas Veerman __gthread_objc_condition_deallocate (objc_condition_t condition _GLIBCXX_UNUSED)
18618a5822eSThomas Veerman {
18718a5822eSThomas Veerman return 0;
18818a5822eSThomas Veerman }
18918a5822eSThomas Veerman
19018a5822eSThomas Veerman /* Wait on the condition */
19118a5822eSThomas Veerman static inline int
__gthread_objc_condition_wait(objc_condition_t condition _GLIBCXX_UNUSED,objc_mutex_t mutex _GLIBCXX_UNUSED)19218a5822eSThomas Veerman __gthread_objc_condition_wait (objc_condition_t condition _GLIBCXX_UNUSED,
19318a5822eSThomas Veerman objc_mutex_t mutex _GLIBCXX_UNUSED)
19418a5822eSThomas Veerman {
19518a5822eSThomas Veerman return 0;
19618a5822eSThomas Veerman }
19718a5822eSThomas Veerman
19818a5822eSThomas Veerman /* Wake up all threads waiting on this condition. */
19918a5822eSThomas Veerman static inline int
__gthread_objc_condition_broadcast(objc_condition_t condition _GLIBCXX_UNUSED)20018a5822eSThomas Veerman __gthread_objc_condition_broadcast (objc_condition_t condition _GLIBCXX_UNUSED)
20118a5822eSThomas Veerman {
20218a5822eSThomas Veerman return 0;
20318a5822eSThomas Veerman }
20418a5822eSThomas Veerman
20518a5822eSThomas Veerman /* Wake up one thread waiting on this condition. */
20618a5822eSThomas Veerman static inline int
__gthread_objc_condition_signal(objc_condition_t condition _GLIBCXX_UNUSED)20718a5822eSThomas Veerman __gthread_objc_condition_signal (objc_condition_t condition _GLIBCXX_UNUSED)
20818a5822eSThomas Veerman {
20918a5822eSThomas Veerman return 0;
21018a5822eSThomas Veerman }
21118a5822eSThomas Veerman
21218a5822eSThomas Veerman #else /* _LIBOBJC */
21318a5822eSThomas Veerman
21418a5822eSThomas Veerman static inline int
__gthread_active_p(void)21518a5822eSThomas Veerman __gthread_active_p (void)
21618a5822eSThomas Veerman {
21718a5822eSThomas Veerman return 0;
21818a5822eSThomas Veerman }
21918a5822eSThomas Veerman
22018a5822eSThomas Veerman static inline int
__gthread_once(__gthread_once_t * __once _GLIBCXX_UNUSED,void (* __func)(void)_GLIBCXX_UNUSED)22118a5822eSThomas Veerman __gthread_once (__gthread_once_t *__once _GLIBCXX_UNUSED, void (*__func) (void) _GLIBCXX_UNUSED)
22218a5822eSThomas Veerman {
22318a5822eSThomas Veerman return 0;
22418a5822eSThomas Veerman }
22518a5822eSThomas Veerman
22618a5822eSThomas Veerman static inline int _GLIBCXX_UNUSED
__gthread_key_create(__gthread_key_t * __key _GLIBCXX_UNUSED,void (* __func)(void *)_GLIBCXX_UNUSED)22718a5822eSThomas Veerman __gthread_key_create (__gthread_key_t *__key _GLIBCXX_UNUSED, void (*__func) (void *) _GLIBCXX_UNUSED)
22818a5822eSThomas Veerman {
22918a5822eSThomas Veerman return 0;
23018a5822eSThomas Veerman }
23118a5822eSThomas Veerman
23218a5822eSThomas Veerman static int _GLIBCXX_UNUSED
__gthread_key_delete(__gthread_key_t __key _GLIBCXX_UNUSED)23318a5822eSThomas Veerman __gthread_key_delete (__gthread_key_t __key _GLIBCXX_UNUSED)
23418a5822eSThomas Veerman {
23518a5822eSThomas Veerman return 0;
23618a5822eSThomas Veerman }
23718a5822eSThomas Veerman
23818a5822eSThomas Veerman static inline void *
__gthread_getspecific(__gthread_key_t __key _GLIBCXX_UNUSED)23918a5822eSThomas Veerman __gthread_getspecific (__gthread_key_t __key _GLIBCXX_UNUSED)
24018a5822eSThomas Veerman {
24118a5822eSThomas Veerman return 0;
24218a5822eSThomas Veerman }
24318a5822eSThomas Veerman
24418a5822eSThomas Veerman static inline int
__gthread_setspecific(__gthread_key_t __key _GLIBCXX_UNUSED,const void * __v _GLIBCXX_UNUSED)24518a5822eSThomas Veerman __gthread_setspecific (__gthread_key_t __key _GLIBCXX_UNUSED, const void *__v _GLIBCXX_UNUSED)
24618a5822eSThomas Veerman {
24718a5822eSThomas Veerman return 0;
24818a5822eSThomas Veerman }
24918a5822eSThomas Veerman
25018a5822eSThomas Veerman static inline int
__gthread_mutex_destroy(__gthread_mutex_t * __mutex _GLIBCXX_UNUSED)25118a5822eSThomas Veerman __gthread_mutex_destroy (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
25218a5822eSThomas Veerman {
25318a5822eSThomas Veerman return 0;
25418a5822eSThomas Veerman }
25518a5822eSThomas Veerman
25618a5822eSThomas Veerman static inline int
__gthread_mutex_lock(__gthread_mutex_t * __mutex _GLIBCXX_UNUSED)25718a5822eSThomas Veerman __gthread_mutex_lock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
25818a5822eSThomas Veerman {
25918a5822eSThomas Veerman return 0;
26018a5822eSThomas Veerman }
26118a5822eSThomas Veerman
26218a5822eSThomas Veerman static inline int
__gthread_mutex_trylock(__gthread_mutex_t * __mutex _GLIBCXX_UNUSED)26318a5822eSThomas Veerman __gthread_mutex_trylock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
26418a5822eSThomas Veerman {
26518a5822eSThomas Veerman return 0;
26618a5822eSThomas Veerman }
26718a5822eSThomas Veerman
26818a5822eSThomas Veerman static inline int
__gthread_mutex_unlock(__gthread_mutex_t * __mutex _GLIBCXX_UNUSED)26918a5822eSThomas Veerman __gthread_mutex_unlock (__gthread_mutex_t *__mutex _GLIBCXX_UNUSED)
27018a5822eSThomas Veerman {
27118a5822eSThomas Veerman return 0;
27218a5822eSThomas Veerman }
27318a5822eSThomas Veerman
27418a5822eSThomas Veerman static inline int
__gthread_recursive_mutex_lock(__gthread_recursive_mutex_t * __mutex)27518a5822eSThomas Veerman __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t *__mutex)
27618a5822eSThomas Veerman {
27718a5822eSThomas Veerman return __gthread_mutex_lock (__mutex);
27818a5822eSThomas Veerman }
27918a5822eSThomas Veerman
28018a5822eSThomas Veerman static inline int
__gthread_recursive_mutex_trylock(__gthread_recursive_mutex_t * __mutex)28118a5822eSThomas Veerman __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t *__mutex)
28218a5822eSThomas Veerman {
28318a5822eSThomas Veerman return __gthread_mutex_trylock (__mutex);
28418a5822eSThomas Veerman }
28518a5822eSThomas Veerman
28618a5822eSThomas Veerman static inline int
__gthread_recursive_mutex_unlock(__gthread_recursive_mutex_t * __mutex)28718a5822eSThomas Veerman __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t *__mutex)
28818a5822eSThomas Veerman {
28918a5822eSThomas Veerman return __gthread_mutex_unlock (__mutex);
29018a5822eSThomas Veerman }
29118a5822eSThomas Veerman
292*0a6a1f1dSLionel Sambuc static inline int
__gthread_recursive_mutex_destroy(__gthread_recursive_mutex_t * __mutex)293*0a6a1f1dSLionel Sambuc __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t *__mutex)
294*0a6a1f1dSLionel Sambuc {
295*0a6a1f1dSLionel Sambuc return __gthread_mutex_destroy (__mutex);
296*0a6a1f1dSLionel Sambuc }
297*0a6a1f1dSLionel Sambuc
29818a5822eSThomas Veerman #endif /* _LIBOBJC */
29918a5822eSThomas Veerman
30018a5822eSThomas Veerman #undef _GLIBCXX_UNUSED
30118a5822eSThomas Veerman
30218a5822eSThomas Veerman #endif /* ! _GLIBCXX_GCC_GTHR_SINGLE_H */
303