stdlib: Optimization qsort{_r} swap implementation
[glibc.git] / htl / forward.c
blobcc8147d6de95d0a7024d9ea1082945a4ecdcfe98
1 /* Libc stubs for pthread functions. Hurd pthread version.
2 Copyright (C) 2002-2023 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 <errno.h>
20 #include <dlfcn.h>
21 #include <stdlib.h>
22 #include <shlib-compat.h>
23 #include <pthread-functions.h>
24 #include <libc-lock.h>
25 #include <pt-internal.h>
27 /* Pointers to the libc functions. */
28 struct pthread_functions __libc_pthread_functions attribute_hidden;
29 int __libc_pthread_functions_init attribute_hidden;
32 #define FORWARD2(name, rettype, decl, params, defaction) \
33 rettype \
34 name decl \
35 { \
36 if (!__libc_pthread_functions_init) \
37 defaction; \
39 return PTHFCT_CALL (ptr_##name, params); \
42 /* Same as FORWARD2, only without return. */
43 #define FORWARD_NORETURN(name, rettype, decl, params, defaction) \
44 rettype \
45 name decl \
46 { \
47 if (!__libc_pthread_functions_init) \
48 defaction; \
50 PTHFCT_CALL (ptr_##name, params); \
53 #define FORWARD(name, decl, params, defretval) \
54 FORWARD2 (name, int, decl, params, return defretval)
56 FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
58 FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0)
60 FORWARD (pthread_attr_setschedparam,
61 (pthread_attr_t *attr, const struct sched_param *param),
62 (attr, param), 0)
64 FORWARD (pthread_attr_getscope,
65 (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
66 FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
67 (attr, scope), 0)
70 FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
71 FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
74 FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
75 FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
76 FORWARD (pthread_cond_init,
77 (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
78 (cond, cond_attr), 0)
79 FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
80 FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
81 (cond, mutex), 0)
82 FORWARD (pthread_cond_timedwait,
83 (pthread_cond_t *cond, pthread_mutex_t *mutex,
84 const struct timespec *abstime), (cond, mutex, abstime), 0)
86 /* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
87 FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval),
88 exit (EXIT_SUCCESS))
89 strong_alias (__pthread_exit, pthread_exit);
91 FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
93 FORWARD (pthread_mutex_init,
94 (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
95 (mutex, mutexattr), 0)
97 FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
99 FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
101 FORWARD (__pthread_setcancelstate, (int state, int *oldstate),
102 (state, oldstate), 0)
103 strong_alias (__pthread_setcancelstate, pthread_setcancelstate);
105 FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
107 FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **,
108 (void), (), return &__pthread_cleanup_stack);