1 /* Threads compatibility routines for libgcc2 and libobjc. */
2 /* Compile this one with gcc. */
3 /* Copyright (C) 2019-2022 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
26 /* AMD GCN does not support dynamic creation of threads. There may be many
27 hardware threads, but they're all created simultaneously at launch time.
29 This implementation is intended to provide mutexes for libgfortran, etc.
30 It is not intended to provide a TLS implementation at this time,
31 although that may be added later if needed.
33 __gthread_active_p returns "1" to ensure that mutexes are used, and that
34 programs attempting to use emutls will fail with the appropriate abort.
35 It is expected that the TLS tests will fail. */
37 #ifndef GCC_GTHR_GCN_H
38 #define GCC_GTHR_GCN_H
47 #error "Objective C is not supported on AMD GCN"
51 __gthread_active_p (void)
56 typedef int __gthread_key_t
;
57 typedef int __gthread_once_t
;
58 typedef int __gthread_mutex_t
;
59 typedef int __gthread_recursive_mutex_t
;
61 #define __GTHREAD_ONCE_INIT 0
62 #define __GTHREAD_MUTEX_INIT 0
63 #define __GTHREAD_RECURSIVE_MUTEX_INIT 0
66 __gthread_once (__gthread_once_t
*__once
__attribute__((unused
)),
67 void (*__func
) (void) __attribute__((unused
)))
73 __gthread_key_create (__gthread_key_t
*__key
__attribute__((unused
)),
74 void (*__dtor
) (void *) __attribute__((unused
)))
76 /* Operation is not supported. */
81 __gthread_key_delete (__gthread_key_t __key
__attribute__ ((__unused__
)))
83 /* Operation is not supported. */
88 __gthread_getspecific (__gthread_key_t __key
__attribute__((unused
)))
94 __gthread_setspecific (__gthread_key_t __key
__attribute__((unused
)),
95 const void *__ptr
__attribute__((unused
)))
97 /* Operation is not supported. */
102 __gthread_mutex_destroy (__gthread_mutex_t
*__mutex
__attribute__((unused
)))
108 __gthread_recursive_mutex_destroy (__gthread_recursive_mutex_t
*__mutex
__attribute__((unused
)))
115 __gthread_mutex_lock (__gthread_mutex_t
*__mutex
)
117 while (__sync_lock_test_and_set (__mutex
, 1))
118 asm volatile ("s_sleep\t1" ::: "memory");
124 __gthread_mutex_trylock (__gthread_mutex_t
*__mutex
)
126 return __sync_lock_test_and_set (__mutex
, 1);
130 __gthread_mutex_unlock (__gthread_mutex_t
*__mutex
)
132 __sync_lock_release (__mutex
);
138 __gthread_recursive_mutex_lock (__gthread_recursive_mutex_t
*__mutex
__attribute__((unused
)))
140 /* Operation is not supported. */
145 __gthread_recursive_mutex_trylock (__gthread_recursive_mutex_t
*__mutex
__attribute__((unused
)))
147 /* Operation is not supported. */
152 __gthread_recursive_mutex_unlock (__gthread_recursive_mutex_t
*__mutex
__attribute__((unused
)))
154 /* Operation is not supported. */
157 #endif /* _LIBOBJC */
163 #endif /* ! GCC_GTHR_GCN_H */