blob: 9d25d9a0db54b1b84de38bfe2e067a7b9ee49eea [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/* Copyright (C) 2002, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#include <features.h>
21#include <stdlib.h>
22#include <dlfcn.h>
23
24/* psm: keep this before internals.h */
25
26#include "internals.h"
27
28/* Pointers to the libc functions. */
29struct pthread_functions __libc_pthread_functions attribute_hidden;
30
31
32# define FORWARD2(name, rettype, decl, params, defaction) \
33rettype \
34name decl \
35{ \
36 if (__libc_pthread_functions.ptr_##name == NULL) \
37 defaction; \
38 \
39 return __libc_pthread_functions.ptr_##name params; \
40}
41
42# define FORWARD(name, decl, params, defretval) \
43 FORWARD2 (name, int, decl, params, return defretval)
44
45FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
46
47FORWARD (pthread_attr_init, (pthread_attr_t *attr), (attr), 0)
48
49FORWARD (pthread_attr_getdetachstate,
50 (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
51 0)
52FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
53 (attr, detachstate), 0)
54
55FORWARD (pthread_attr_getinheritsched,
56 (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
57FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
58 (attr, inherit), 0)
59
60FORWARD (pthread_attr_getschedparam,
61 (const pthread_attr_t *attr, struct sched_param *param),
62 (attr, param), 0)
63FORWARD (pthread_attr_setschedparam,
64 (pthread_attr_t *attr, const struct sched_param *param),
65 (attr, param), 0)
66
67FORWARD (pthread_attr_getschedpolicy,
68 (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
69FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
70 (attr, policy), 0)
71
72FORWARD (pthread_attr_getscope,
73 (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
74FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
75 (attr, scope), 0)
76
77
78FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
79FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
80
81
82FORWARD (pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
83
84FORWARD (pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
85
86FORWARD (pthread_cond_init,
87 (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
88 (cond, cond_attr), 0)
89
90FORWARD (pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
91
92FORWARD (pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
93 (cond, mutex), 0)
94
95FORWARD (pthread_cond_timedwait,
96 (pthread_cond_t *cond, pthread_mutex_t *mutex,
97 const struct timespec *abstime), (cond, mutex, abstime), 0)
98
99
100FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
101 (thread1, thread2), 1)
102
103
104/* Use an alias to avoid warning, as pthread_exit is declared noreturn. */
105FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
106strong_alias (__pthread_exit, pthread_exit)
107
108
109FORWARD (pthread_getschedparam,
110 (pthread_t target_thread, int *policy, struct sched_param *param),
111 (target_thread, policy, param), 0)
112FORWARD (pthread_setschedparam,
113 (pthread_t target_thread, int policy,
114 const struct sched_param *param), (target_thread, policy, param), 0)
115
116
117FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
118
119FORWARD (pthread_mutex_init,
120 (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
121 (mutex, mutexattr), 0)
122strong_alias(pthread_mutex_init, __pthread_mutex_init)
123
124FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
125strong_alias(pthread_mutex_lock, __pthread_mutex_lock)
126
127FORWARD (pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), 0)
128strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock)
129
130FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
131strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock)
132
133FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
134
135
136FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
137 0)
138
139FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
140
141FORWARD2 (_pthread_cleanup_push, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
142FORWARD2 (_pthread_cleanup_push_defer, void, (struct _pthread_cleanup_buffer * buffer, void (*routine)(void *), void * arg), (buffer, routine, arg), return)
143
144FORWARD2 (_pthread_cleanup_pop, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)
145FORWARD2 (_pthread_cleanup_pop_restore, void, (struct _pthread_cleanup_buffer * buffer, int execute), (buffer, execute), return)