]>
Commit | Line | Data |
---|---|---|
33574c17 | 1 | /* Libc stubs for pthread functions. Hurd pthread version. |
d614a753 | 2 | Copyright (C) 2002-2020 Free Software Foundation, Inc. |
33574c17 ST |
3 | This file is part of the GNU C Library. |
4 | ||
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. | |
9 | ||
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. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
33574c17 ST |
18 | |
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 <fork.h> | |
a50efac1 | 26 | #include <pt-internal.h> |
33574c17 ST |
27 | |
28 | /* Pointers to the libc functions. */ | |
29 | struct pthread_functions __libc_pthread_functions attribute_hidden; | |
30 | int __libc_pthread_functions_init attribute_hidden; | |
31 | ||
32 | ||
33 | #define FORWARD2(name, rettype, decl, params, defaction) \ | |
34 | rettype \ | |
35 | name decl \ | |
36 | { \ | |
37 | if (!__libc_pthread_functions_init) \ | |
38 | defaction; \ | |
39 | \ | |
40 | return PTHFCT_CALL (ptr_##name, params); \ | |
41 | } | |
42 | ||
43 | /* Same as FORWARD2, only without return. */ | |
44 | #define FORWARD_NORETURN(name, rettype, decl, params, defaction) \ | |
45 | rettype \ | |
46 | name decl \ | |
47 | { \ | |
48 | if (!__libc_pthread_functions_init) \ | |
49 | defaction; \ | |
50 | \ | |
51 | PTHFCT_CALL (ptr_##name, params); \ | |
52 | } | |
53 | ||
54 | #define FORWARD(name, decl, params, defretval) \ | |
55 | FORWARD2 (name, int, decl, params, return defretval) | |
56 | ||
57 | FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0) | |
58 | ||
59 | FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0) | |
60 | ||
61 | FORWARD (pthread_attr_getdetachstate, | |
62 | (const pthread_attr_t *attr, int *detachstate), (attr, detachstate), | |
63 | 0) | |
64 | FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate), | |
65 | (attr, detachstate), 0) | |
66 | ||
67 | FORWARD (pthread_attr_getinheritsched, | |
68 | (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0) | |
69 | FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit), | |
70 | (attr, inherit), 0) | |
71 | ||
72 | FORWARD (pthread_attr_getschedparam, | |
73 | (const pthread_attr_t *attr, struct sched_param *param), | |
74 | (attr, param), 0) | |
75 | FORWARD (pthread_attr_setschedparam, | |
76 | (pthread_attr_t *attr, const struct sched_param *param), | |
77 | (attr, param), 0) | |
78 | ||
79 | FORWARD (pthread_attr_getschedpolicy, | |
80 | (const pthread_attr_t *attr, int *policy), (attr, policy), 0) | |
81 | FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy), | |
82 | (attr, policy), 0) | |
83 | ||
84 | FORWARD (pthread_attr_getscope, | |
85 | (const pthread_attr_t *attr, int *scope), (attr, scope), 0) | |
86 | FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope), | |
87 | (attr, scope), 0) | |
88 | ||
89 | ||
90 | FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0) | |
91 | FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0) | |
92 | ||
93 | ||
94 | FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0) | |
95 | FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0) | |
96 | FORWARD (pthread_cond_init, | |
97 | (pthread_cond_t *cond, const pthread_condattr_t *cond_attr), | |
98 | (cond, cond_attr), 0) | |
99 | FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0) | |
100 | FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex), | |
101 | (cond, mutex), 0) | |
102 | FORWARD (pthread_cond_timedwait, | |
103 | (pthread_cond_t *cond, pthread_mutex_t *mutex, | |
104 | const struct timespec *abstime), (cond, mutex, abstime), 0) | |
105 | ||
106 | FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), | |
107 | (thread1, thread2), 1) | |
108 | ||
109 | ||
110 | /* Use an alias to avoid warning, as pthread_exit is declared noreturn. */ | |
111 | FORWARD_NORETURN (__pthread_exit, void, (void *retval), (retval), | |
112 | exit (EXIT_SUCCESS)) | |
113 | strong_alias (__pthread_exit, pthread_exit); | |
114 | ||
115 | ||
116 | FORWARD (pthread_getschedparam, | |
117 | (pthread_t target_thread, int *policy, struct sched_param *param), | |
118 | (target_thread, policy, param), 0) | |
119 | FORWARD (pthread_setschedparam, | |
120 | (pthread_t target_thread, int policy, | |
121 | const struct sched_param *param), (target_thread, policy, param), 0) | |
122 | ||
123 | ||
124 | FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) | |
125 | ||
126 | FORWARD (pthread_mutex_init, | |
127 | (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), | |
128 | (mutex, mutexattr), 0) | |
129 | ||
130 | FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) | |
131 | ||
132 | FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) | |
133 | ||
134 | ||
135 | FORWARD2 (pthread_self, pthread_t, (void), (), return 0) | |
136 | ||
137 | ||
138 | FORWARD (__pthread_setcancelstate, (int state, int *oldstate), | |
139 | (state, oldstate), 0) | |
140 | strong_alias (__pthread_setcancelstate, pthread_setcancelstate); | |
141 | ||
142 | FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0) | |
143 | ||
33574c17 | 144 | FORWARD2 (__pthread_get_cleanup_stack, struct __pthread_cancelation_handler **, |
a50efac1 | 145 | (void), (), return &__pthread_cleanup_stack); |