1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20: #include <dlfcn.h>
21: #include <pthreadP.h>
22: #include <signal.h>
23: #include <stdlib.h>
24:
25: #include <shlib-compat.h>
26: #include <atomic.h>
27: #include <sysdep.h>
28:
29:
30:
31: struct pthread_functions __libc_pthread_functions attribute_hidden;
32: int __libc_pthread_functions_init attribute_hidden;
33:
34:
35: #define FORWARD2(name, rettype, decl, params, defaction) \
36: rettype \
37: name decl \
38: { \
39: if (!__libc_pthread_functions_init) \
40: defaction; \
41: \
42: return PTHFCT_CALL (ptr_##name, params); \
43: }
44:
45: #define FORWARD(name, decl, params, defretval) \
46: FORWARD2 (name, int, decl, params, return defretval)
47:
48:
49: FORWARD (pthread_attr_destroy, (pthread_attr_t *attr), (attr), 0)
50:
51: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_1)
52: FORWARD (__pthread_attr_init_2_0, (pthread_attr_t *attr), (attr), 0)
53: compat_symbol (libc, __pthread_attr_init_2_0, pthread_attr_init, GLIBC_2_0);
54: #endif
55:
56: FORWARD (__pthread_attr_init_2_1, (pthread_attr_t *attr), (attr), 0)
57: versioned_symbol (libc, __pthread_attr_init_2_1, pthread_attr_init, GLIBC_2_1);
58:
59: FORWARD (pthread_attr_getdetachstate,
60: (const pthread_attr_t *attr, int *detachstate), (attr, detachstate),
61: 0)
62: FORWARD (pthread_attr_setdetachstate, (pthread_attr_t *attr, int detachstate),
63: (attr, detachstate), 0)
64:
65: FORWARD (pthread_attr_getinheritsched,
66: (const pthread_attr_t *attr, int *inherit), (attr, inherit), 0)
67: FORWARD (pthread_attr_setinheritsched, (pthread_attr_t *attr, int inherit),
68: (attr, inherit), 0)
69:
70: FORWARD (pthread_attr_getschedparam,
71: (const pthread_attr_t *attr, struct sched_param *param),
72: (attr, param), 0)
73: FORWARD (pthread_attr_setschedparam,
74: (pthread_attr_t *attr, const struct sched_param *param),
75: (attr, param), 0)
76:
77: FORWARD (pthread_attr_getschedpolicy,
78: (const pthread_attr_t *attr, int *policy), (attr, policy), 0)
79: FORWARD (pthread_attr_setschedpolicy, (pthread_attr_t *attr, int policy),
80: (attr, policy), 0)
81:
82: FORWARD (pthread_attr_getscope,
83: (const pthread_attr_t *attr, int *scope), (attr, scope), 0)
84: FORWARD (pthread_attr_setscope, (pthread_attr_t *attr, int scope),
85: (attr, scope), 0)
86:
87:
88: FORWARD (pthread_condattr_destroy, (pthread_condattr_t *attr), (attr), 0)
89: FORWARD (pthread_condattr_init, (pthread_condattr_t *attr), (attr), 0)
90:
91: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
92: FORWARD2 (__pthread_cond_broadcast_2_0, int attribute_compat_text_section,
93: (pthread_cond_2_0_t *cond), (cond), return 0)
94: compat_symbol (libc, __pthread_cond_broadcast_2_0, pthread_cond_broadcast,
95: GLIBC_2_0);
96: #endif
97: FORWARD (__pthread_cond_broadcast, (pthread_cond_t *cond), (cond), 0)
98: versioned_symbol (libc, __pthread_cond_broadcast, pthread_cond_broadcast,
99: GLIBC_2_3_2);
100:
101: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
102: FORWARD2 (__pthread_cond_destroy_2_0, int attribute_compat_text_section,
103: (pthread_cond_2_0_t *cond), (cond), return 0)
104: compat_symbol (libc, __pthread_cond_destroy_2_0, pthread_cond_destroy,
105: GLIBC_2_0);
106: #endif
107: FORWARD (__pthread_cond_destroy, (pthread_cond_t *cond), (cond), 0)
108: versioned_symbol (libc, __pthread_cond_destroy, pthread_cond_destroy,
109: GLIBC_2_3_2);
110:
111: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
112: FORWARD2 (__pthread_cond_init_2_0, int attribute_compat_text_section,
113: (pthread_cond_2_0_t *cond, const pthread_condattr_t *cond_attr),
114: (cond, cond_attr), return 0)
115: compat_symbol (libc, __pthread_cond_init_2_0, pthread_cond_init, GLIBC_2_0);
116: #endif
117: FORWARD (__pthread_cond_init,
118: (pthread_cond_t *cond, const pthread_condattr_t *cond_attr),
119: (cond, cond_attr), 0)
120: versioned_symbol (libc, __pthread_cond_init, pthread_cond_init, GLIBC_2_3_2);
121:
122: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
123: FORWARD2 (__pthread_cond_signal_2_0, int attribute_compat_text_section,
124: (pthread_cond_2_0_t *cond), (cond), return 0)
125: compat_symbol (libc, __pthread_cond_signal_2_0, pthread_cond_signal,
126: GLIBC_2_0);
127: #endif
128: FORWARD (__pthread_cond_signal, (pthread_cond_t *cond), (cond), 0)
129: versioned_symbol (libc, __pthread_cond_signal, pthread_cond_signal,
130: GLIBC_2_3_2);
131:
132: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
133: FORWARD2 (__pthread_cond_wait_2_0, int attribute_compat_text_section,
134: (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex), (cond, mutex),
135: return 0)
136: compat_symbol (libc, __pthread_cond_wait_2_0, pthread_cond_wait,
137: GLIBC_2_0);
138: #endif
139: FORWARD (__pthread_cond_wait, (pthread_cond_t *cond, pthread_mutex_t *mutex),
140: (cond, mutex), 0)
141: versioned_symbol (libc, __pthread_cond_wait, pthread_cond_wait,
142: GLIBC_2_3_2);
143:
144: #if SHLIB_COMPAT(libc, GLIBC_2_0, GLIBC_2_3_2)
145: FORWARD2 (__pthread_cond_timedwait_2_0, int attribute_compat_text_section,
146: (pthread_cond_2_0_t *cond, pthread_mutex_t *mutex,
147: const struct timespec *abstime), (cond, mutex, abstime),
148: return 0)
149: compat_symbol (libc, __pthread_cond_timedwait_2_0, pthread_cond_timedwait,
150: GLIBC_2_0);
151: #endif
152: FORWARD (__pthread_cond_timedwait,
153: (pthread_cond_t *cond, pthread_mutex_t *mutex,
154: const struct timespec *abstime), (cond, mutex, abstime), 0)
155: versioned_symbol (libc, __pthread_cond_timedwait, pthread_cond_timedwait,
156: GLIBC_2_3_2);
157:
158:
159: FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2),
160: (thread1, thread2), 1)
161:
162:
163:
164: FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS))
165: strong_alias (__pthread_exit, pthread_exit);
166:
167:
168: FORWARD (pthread_getschedparam,
169: (pthread_t target_thread, int *policy, struct sched_param *param),
170: (target_thread, policy, param), 0)
171: FORWARD (pthread_setschedparam,
172: (pthread_t target_thread, int policy,
173: const struct sched_param *param), (target_thread, policy, param), 0)
174:
175:
176: FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0)
177:
178: FORWARD (pthread_mutex_init,
179: (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr),
180: (mutex, mutexattr), 0)
181:
182: FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0)
183:
184: FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0)
185:
186:
187: FORWARD2 (pthread_self, pthread_t, (void), (), return 0)
188:
189:
190: FORWARD (pthread_setcancelstate, (int state, int *oldstate), (state, oldstate),
191: 0)
192:
193: FORWARD (pthread_setcanceltype, (int type, int *oldtype), (type, oldtype), 0)
194:
195: #define return
196: FORWARD2(__pthread_unwind,
197: void attribute_hidden __attribute ((noreturn)) __cleanup_fct_attribute
198: attribute_compat_text_section,
199: (__pthread_unwind_buf_t *buf), (buf), {
200:
201: INTERNAL_SYSCALL_DECL (err);
202: INTERNAL_SYSCALL (kill, err, 1, SIGKILL);
203: })
204: #undef return