Add UNSUPPORTED check in elf/tst-pldd.
[glibc.git] / htl / cthreads-compat.c
blob896b82f4918179bde5a0691d78587887193d944a
1 /* Compatibility routines for cthreads.
2 Copyright (C) 2000-2019 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;
29 err = __pthread_detach ((pthread_t) thread);
30 assert_perror (err);
32 weak_alias (__cthread_detach, cthread_detach)
34 __cthread_t
35 __cthread_fork (__cthread_fn_t func, void *arg)
37 pthread_t thread;
38 int err;
40 err = __pthread_create (&thread, NULL, func, arg);
41 assert_perror (err);
43 return (__cthread_t) thread;
45 weak_alias (__cthread_fork, cthread_fork)
47 int
48 __cthread_keycreate (__cthread_key_t *key)
50 error_t err;
52 err = __pthread_key_create (key, 0);
53 if (err)
55 errno = err;
56 *key = CTHREAD_KEY_INVALID;
57 err = -1;
60 return err;
62 weak_alias (__cthread_keycreate, cthread_keycreate)
64 int
65 __cthread_getspecific (__cthread_key_t key, void **val)
67 *val = __pthread_getspecific (key);
68 return 0;
70 weak_alias (__cthread_getspecific, cthread_getspecific)
72 int
73 __cthread_setspecific (__cthread_key_t key, void *val)
75 error_t err;
77 err = __pthread_setspecific (key, (const void *) val);
78 if (err)
80 errno = err;
81 err = -1;
84 return err;
86 weak_alias (__cthread_setspecific, cthread_setspecific)
88 void
89 __mutex_lock_solid (void *lock)
91 __pthread_mutex_lock (lock);
94 void
95 __mutex_unlock_solid (void *lock)
97 if (__pthread_spin_trylock (lock) != 0)
98 /* Somebody already got the lock, that one will manage waking up others */
99 return;
100 __pthread_mutex_unlock (lock);