1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
# Makefile for uClibc NPTL
#
# Copyright (C) 2005-2006 Steven J. Hill <sjhill@realitydiluted.com>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
subdirs += libpthread/nptl/sysdeps/$(TARGET_ARCH) \
libpthread/nptl/sysdeps/unix/sysv/linux \
libpthread/nptl/sysdeps/pthread
libpthread-routines = init vars events version \
pthread_create pthread_exit pthread_detach \
pthread_join pthread_tryjoin pthread_timedjoin \
pthread_self pthread_equal pthread_yield \
pthread_getconcurrency pthread_setconcurrency \
pthread_getschedparam pthread_setschedparam \
pthread_setschedprio \
pthread_attr_init pthread_attr_destroy \
pthread_attr_getdetachstate pthread_attr_setdetachstate \
pthread_attr_getguardsize pthread_attr_setguardsize \
pthread_attr_getschedparam pthread_attr_setschedparam \
pthread_attr_getschedpolicy pthread_attr_setschedpolicy \
pthread_attr_getinheritsched \
pthread_attr_setinheritsched \
pthread_attr_getscope pthread_attr_setscope \
pthread_attr_getstackaddr pthread_attr_setstackaddr \
pthread_attr_getstacksize pthread_attr_setstacksize \
pthread_attr_getstack pthread_attr_setstack \
pthread_getattr_np \
pthread_mutex_init pthread_mutex_destroy \
pthread_mutex_lock pthread_mutex_trylock \
pthread_mutex_timedlock pthread_mutex_unlock \
pthread_mutex_consistent \
pthread_mutexattr_init pthread_mutexattr_destroy \
pthread_mutexattr_getpshared \
pthread_mutexattr_setpshared \
pthread_mutexattr_getrobust \
pthread_mutexattr_setrobust \
pthread_mutexattr_getprotocol \
pthread_mutexattr_setprotocol \
pthread_mutexattr_getprioceiling \
pthread_mutexattr_setprioceiling \
pthread_mutexattr_gettype pthread_mutexattr_settype \
pthread_rwlock_init pthread_rwlock_destroy \
pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
pthread_rwlock_tryrdlock pthread_rwlock_trywrlock \
pthread_rwlock_unlock \
pthread_rwlockattr_init pthread_rwlockattr_destroy \
pthread_rwlockattr_getpshared \
pthread_rwlockattr_setpshared \
pthread_rwlockattr_getkind_np \
pthread_rwlockattr_setkind_np \
pthread_cond_init pthread_cond_destroy \
pthread_cond_wait pthread_cond_timedwait \
pthread_cond_signal pthread_cond_broadcast \
pthread_condattr_init pthread_condattr_destroy \
pthread_condattr_getpshared pthread_condattr_setpshared \
pthread_condattr_getclock pthread_condattr_setclock \
pthread_spin_init pthread_spin_destroy \
pthread_spin_lock pthread_spin_trylock \
pthread_spin_unlock \
pthread_barrier_init pthread_barrier_destroy \
pthread_barrier_wait \
pthread_barrierattr_init pthread_barrierattr_destroy \
pthread_barrierattr_getpshared \
pthread_barrierattr_setpshared \
pthread_key_create pthread_key_delete \
pthread_getspecific pthread_setspecific \
pthread_sigmask pthread_kill \
pthread_cancel pthread_testcancel \
pthread_setcancelstate pthread_setcanceltype \
pthread_once \
pthread_atfork \
pthread_getcpuclockid \
pthread_clock_gettime pthread_clock_settime \
sem_init sem_destroy \
sem_open sem_close sem_unlink \
sem_getvalue \
sem_wait sem_trywait sem_timedwait sem_post \
cleanup cleanup_defer cleanup_compat \
cleanup_defer_compat unwind \
pt-longjmp pt-cleanup\
cancellation \
lowlevellock \
pt-vfork \
ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg ptw-send \
ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek ptw-llseek \
ptw-msync ptw-nanosleep ptw-open ptw-open64 ptw-pause \
ptw-pread ptw-pread64 ptw-pwrite ptw-pwrite64 \
ptw-tcdrain ptw-wait ptw-waitpid ptw-msgrcv ptw-msgsnd \
ptw-sigwait \
pt-raise pt-system \
flockfile ftrylockfile funlockfile \
sigaction \
herrno res \
pthread_kill_other_threads \
pthread_getaffinity pthread_setaffinity \
pthread_attr_getaffinity pthread_attr_setaffinity \
cleanup_routine unwind-forcedunwind
libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
CFLAGS-pthread_atfork.c = -DNOT_IN_libc
# Since cancellation handling is in large parts handled using exceptions
# we have to compile some files with exception handling enabled, some
# even with asynchronous unwind tables.
# init.c contains sigcancel_handler().
CFLAGS-init.c = -fexceptions -fasynchronous-unwind-tables
# The unwind code itself,
CFLAGS-unwind.c = -fexceptions
CFLAGS-unwind-forcedunwind.c = -fexceptions -fasynchronous-unwind-tables
# The following three functions must be async-cancel safe.
CFLAGS-pthread_cancel.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_setcancelstate.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_setcanceltype.c = -fexceptions -fasynchronous-unwind-tables
# These are internal functions which similar functionality as setcancelstate
# and setcanceltype.
CFLAGS-cancellation.c = -fasynchronous-unwind-tables
CFLAGS-libc-cancellation.c = -fasynchronous-unwind-tables
# Calling pthread_exit() must cause the registered cancel handlers to
# be executed. Therefore exceptions have to be thrown through this
# function.
CFLAGS-pthread_exit.c = -fexceptions
# Among others, __pthread_unwind is forwarded. This function must handle
# exceptions.
CFLAGS-forward.c = -fexceptions
# The following are cancellation points. Some of the functions can
# block and therefore temporarily enable asynchronous cancellation.
# Those must be compiled asynchronous unwind tables.
CFLAGS-pthread_testcancel.c = -fexceptions
CFLAGS-pthread_join.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_timedjoin.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_once.c = $(uses-callbacks) -fexceptions \
-fasynchronous-unwind-tables
CFLAGS-pthread_cond_wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pthread_cond_timedwait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sem_wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sem_timedwait.c = -fexceptions -fasynchronous-unwind-tables
# These are the function wrappers we have to duplicate here.
CFLAGS-fcntl.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-lockf.c = -fexceptions
CFLAGS-pread.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pread64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pwrite64.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-wait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-waitpid.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-sigwait.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msgrcv.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-msgsnd.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-tcdrain.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-pt-system.c = -fexceptions -I./libc/stdlib
#
# The rest of this file is uClibc specific.
#
CFLAGS-pthread_barrier_init.c = -D_GNU_SOURCE
CFLAGS-pthread_barrier_destroy.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_init.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_destroy.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_getpshared.c = -D_GNU_SOURCE
CFLAGS-pthread_barrierattr_setpshared.c = -D_GNU_SOURCE
CFLAGS-sem_open.c = -D_GNU_SOURCE
CFLAGS-nptl = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 $(SSP_ALL_CFLAGS)
CFLAGS-OMIT-alloca_cutoff.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
CFLAGS-OMIT-forward.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
CFLAGS-OMIT-libc-lowlevelock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
CFLAGS-OMIT-libc-cancellation.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
libpthread-os-routines = pthread_yield
libpthread-misc-routines = pthread_rwlock_rdlock pthread_rwlock_timedrdlock \
pthread_rwlock_wrlock pthread_rwlock_timedwrlock \
pthread_rwlock_unlock pthread_cond_wait \
pthread_cond_timedwait pthread_cond_signal \
pthread_cond_broadcast pthread_spin_init \
pthread_spin_destroy pthread_spin_lock \
pthread_spin_trylock pthread_spin_unlock \
pthread_barrier_init pthread_barrier_destroy \
pthread_barrier_wait pthread_sigmask \
pthread_kill pthread_once \
pthread_getcpuclockid sem_wait \
sem_trywait sem_timedwait \
sem_post pt-longjmp \
lowlevellock pt-vfork \
ptw-close ptw-read ptw-write \
ptw-fcntl ptw-accept ptw-connect \
ptw-recv ptw-recvfrom ptw-recvmsg \
ptw-send ptw-sendmsg ptw-sendto \
ptw-fsync ptw-lseek ptw-llseek \
ptw-msync ptw-nanosleep ptw-open \
ptw-open64 ptw-pause ptw-pread \
ptw-pread64 ptw-pwrite ptw-pwrite64 \
ptw-tcdrain ptw-wait ptw-waitpid \
ptw-msgrcv ptw-msgsnd ptw-sigwait \
pt-raise flockfile ftrylockfile \
funlockfile sigaction \
pthread_getaffinity \
pthread_setaffinity \
pthread_attr_getaffinity \
pthread_attr_setaffinity \
unwind-forcedunwind
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs
else
LDFLAGS-libpthread.so := $(LDFLAGS)
endif
LDFLAGS-libpthread.so += $(top_builddir)lib/$(UCLIBC_LDSO_NAME)-$(VERSION).so $(top_builddir)lib/libdl-$(VERSION).so
LIBS-libpthread.so := $(LIBS)
ifneq ($(UCLIBC_CTOR_DTOR),y)
START_FILE-libpthread.so := $(top_builddir)/libpthread/nptl/sysdeps/pthread/crti.o $(SHARED_START_FILES)
END_FILE-libpthread.so := $(SHARED_END_FILES) $(top_builddir)/libpthread/nptl/sysdeps/pthread/crtn.o
endif
libpthread_FULL_NAME := libpthread-$(VERSION).so
PTHREAD_DIR := $(top_srcdir)libpthread/nptl
PTHREAD_OUT := $(top_builddir)libpthread/nptl
libpthread_static_SRC := pthread_atfork
libpthread_a_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
$(filter-out $(libpthread-os-routines) \
$(libpthread-misc-routines) \
$(libpthread-shared-only-routines), \
$(libpthread-routines)))
libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c, \
$(filter-out $(libpthread-os-routines) \
$(libpthread-misc-routines), $(libpthread-routines)))
libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c \
libc-cancellation.c)
libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c \
libc-cancellation.c)
libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
ifeq ($(DOPIC),y)
libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.os,$(libpthread_a_SRC))
else
libpthread-a-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC))
endif
libpthread-so-y := $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.oS,$(libpthread_so_SRC))
libpthread-static-y += $(patsubst $(PTHREAD_DIR)/%.c,$(PTHREAD_OUT)/%.o,$(libpthread_a_SRC) $(libpthread_static_SRC))
objclean-y += libpthread_clean
headers_clean-y += nptl_headers_clean
-include $(PTHREAD_DIR)/sysdeps/generic/Makefile.in
-include $(PTHREAD_DIR)/sysdeps/pthread/Makefile.in
-include $(PTHREAD_DIR)/sysdeps/$(TARGET_ARCH)/Makefile.arch
-include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/Makefile.in
-include $(PTHREAD_DIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/Makefile.arch
pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers) $(nptl_arch_headers) $(nptl_linux_headers)
lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a
lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so
$(top_builddir)lib/libpthread.so: $(PTHREAD_OUT)/libpthread_so.a $(libc.depend) $(libdl.depend) $(top_builddir)lib/libpthread_nonshared.a
$(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION))
$(Q)$(RM) $@
$(Q)cp $(top_srcdir)extra/scripts/format.lds $@
$(Q)echo "GROUP ( $(notdir $@).$(MAJOR_VERSION) libpthread_nonshared.a )" >> $@
$(PTHREAD_OUT)/libpthread_so.a: $(libpthread-so-y)
$(Q)$(RM) $@
ifeq ($(PTHREADS_DEBUG_SUPPORT),y)
$(do_strip:-x=-X --strip-debug)
else
$(do_strip)
endif
$(do_ar)
$(top_builddir)lib/libpthread.a: $(libpthread-a-y)
$(Q)$(INSTALL) -d $(dir $@)
$(Q)$(RM) $@
$(do_strip)
$(do_ar)
#
# Create 'pthread-errnos.h' header file.
#
CFLAGS-pthread-errnos.c = -S
$(PTHREAD_OUT)/pthread-errnos.c: $(PTHREAD_DIR)/pthread-errnos.sym
$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
$(PTHREAD_OUT)/pthread-errnos.s: $(PTHREAD_OUT)/pthread-errnos.c
$(compile.c)
$(PTHREAD_OUT)/pthread-errnos.h: $(PTHREAD_OUT)/pthread-errnos.s
$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(nptl_headers_bootstrap)
$(top_builddir)include/pthread.h:
$(do_ln) ../$(PTDIR)/sysdeps/pthread/$(@F) $(top_builddir)$@
$(top_builddir)include/semaphore.h:
$(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
$(top_builddir)include/bits/semaphore.h: | include/bits
$(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
$(top_builddir)include/bits/pthreadtypes.h: | include/bits
$(do_ln) ../../$(PTDIR)/sysdeps/unix/sysv/linux/$(TARGET_ARCH)/bits/$(@F) $(top_builddir)$@
$(top_builddir)include/bits/libc-lock.h: | include/bits
$(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
$(top_builddir)include/bits/stdio-lock.h: | include/bits
$(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
nptl_headers_bootstrap := $(top_builddir)include/pthread.h \
$(top_builddir)include/semaphore.h \
$(top_builddir)include/bits/semaphore.h \
$(top_builddir)include/bits/pthreadtypes.h \
$(top_builddir)include/bits/libc-lock.h \
$(top_builddir)include/bits/stdio-lock.h
nptl_headers := $(PTHREAD_OUT)/pthread-errnos.h
nptl_headers_clean:
$(do_rm) $(nptl_headers_bootstrap) \
$(addprefix $(PTHREAD_OUT)/pthread-errnos., c h s)
libpthread_clean:
$(do_rm) $(addprefix $(PTHREAD_OUT)/*., o os oS a)
|