sparc64: Remove unwind information from signal return stubs [BZ#31244]
[glibc.git] / htl / cthreads-compat.c
blob869c7fdce1c02527c03218fce369b879fbd17942
1 /* Compatibility routines for cthreads.
2 Copyright (C) 2000-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <assert.h>
20 #include <pthreadP.h>
22 #define CTHREAD_KEY_INVALID (__cthread_key_t) -1
24 void
25 __cthread_detach (__cthread_t thread)
27 int err;
28 pthread_t pthread = (pthread_t) (uintptr_t) thread;
30 err = __pthread_detach (pthread);
31 assert_perror (err);
33 weak_alias (__cthread_detach, cthread_detach)
35 __cthread_t
36 __cthread_fork (__cthread_fn_t func, void *arg)
38 pthread_t thread;
39 int err;
41 err = __pthread_create (&thread, NULL, func, arg);
42 assert_perror (err);
44 return (__cthread_t) (uintptr_t) thread;
46 weak_alias (__cthread_fork, cthread_fork)
48 int
49 __cthread_keycreate (__cthread_key_t *key)
51 error_t err;
53 err = __pthread_key_create (key, 0);
54 if (err)
56 errno = err;
57 *key = CTHREAD_KEY_INVALID;
58 err = -1;
61 return err;
63 weak_alias (__cthread_keycreate, cthread_keycreate)
65 int
66 __cthread_getspecific (__cthread_key_t key, void **val)
68 *val = __pthread_getspecific (key);
69 return 0;
71 weak_alias (__cthread_getspecific, cthread_getspecific)
73 int
74 __cthread_setspecific (__cthread_key_t key, void *val)
76 error_t err;
78 err = __pthread_setspecific (key, (const void *) val);
79 if (err)
81 errno = err;
82 err = -1;
85 return err;
87 weak_alias (__cthread_setspecific, cthread_setspecific)
89 void
90 __mutex_lock_solid (void *lock)
92 __pthread_mutex_lock (lock);
95 void
96 __mutex_unlock_solid (void *lock)
98 if (__pthread_spin_trylock (lock) != 0)
99 /* Somebody already got the lock, that one will manage waking up others */
100 return;
101 __pthread_mutex_unlock (lock);