[PATCH] nptl: use arch-specific cancellation routines for x86_64

Roman I Khimov khimov at altell.ru
Fri Apr 30 14:18:31 UTC 2010


They were present in sources, but not compiled in. Generic routines are
broken badly on x86_64, even basic threading test like pthread/ex1 didn't
work with them.

Signed-off-by: Roman I Khimov <khimov at altell.ru>
---
 libpthread/nptl/Makefile.in                        |   10 +++++++
 .../sysdeps/unix/sysv/linux/x86_64/Makefile.arch   |   28 ++++++++-----------
 .../sysdeps/unix/sysv/linux/x86_64/cancellation.S  |    2 +-
 3 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/libpthread/nptl/Makefile.in b/libpthread/nptl/Makefile.in
index 9d3e393..c229673 100644
--- a/libpthread/nptl/Makefile.in
+++ b/libpthread/nptl/Makefile.in
@@ -103,6 +103,10 @@ libpthread-routines = init vars events version \
 
 libpthread-shared-only-routines = version pt-allocrtsig unwind-forcedunwind
 
+ifeq ($(TARGET_ARCH),x86_64)
+libpthread-routines := $(filter-out cancellation,$(libpthread-routines))
+endif
+
 CFLAGS-pthread_atfork.c = -DNOT_IN_libc
 
 # Since cancellation handling is in large parts handled using exceptions
@@ -245,10 +249,16 @@ libpthread_so_SRC = $(patsubst %, $(PTHREAD_DIR)/%.c,			\
 		$(filter-out $(libpthread-os-routines)			\
 			$(libpthread-misc-routines), $(libpthread-routines)))
 
+ifeq ($(TARGET_ARCH),x86_64)
+libc-static-y += $(patsubst %.c, $(PTHREAD_OUT)/%.o, alloca_cutoff.c)
+libc-shared-y += $(patsubst %.c, $(PTHREAD_OUT)/%.oS, forward.c)
+else
 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)
+endif
+
 libpthread-nonshared-y += $(patsubst %,$(PTHREAD_OUT)/%.oS,$(libpthread_static_SRC))
 
 
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
index d59df2c..e481f93 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
@@ -12,16 +12,16 @@ libpthread_SSRC = pt-vfork.S clone.S pthread_once.S
 libpthread_CSRC = pthread_spin_init.c pt-__syscall_error.c
 
 libc_a_CSRC = fork.c
-libc_a_SSRC = clone.S vfork.S
+libc_a_SSRC = clone.S vfork.S libc-cancellation.S
 
 libpthread_SSRC += lowlevellock.S pthread_barrier_wait.S pthread_cond_signal.S pthread_cond_broadcast.S \
 		   sem_post.S sem_timedwait.S lowlevelrobustlock.S \
 		   sem_trywait.S sem_wait.S pthread_rwlock_rdlock.S pthread_rwlock_wrlock.S \
 		   pthread_rwlock_timedrdlock.S pthread_rwlock_timedwrlock.S pthread_rwlock_unlock.S \
-		   pthread_spin_unlock.S
+		   pthread_spin_unlock.S cancellation.S
 # pthread_cond_timedwait.S pthread_cond_wait.S
 libc_a_SSRC += libc-lowlevellock.S
-
+librt_a_SSRC += librt-lowlevellock.S
 
 CFLAGS-OMIT-fork.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1
 CFLAGS-pt-__syscall_error.c =  -DNOT_IN_libc=1 -DIS_IN_libpthread=1
@@ -30,24 +30,17 @@ ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
 CFLAGS-fork.c = -D__USE_STDIO_FUTEXES__
 endif
 
-ASFLAGS-pt-vfork.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD
-ASFLAGS-lowlevellock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD
-ASFLAGS-pthread_once.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD
+ASFLAGS += -DUSE___THREAD
+ASFLAGS-pt-vfork.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT
+ASFLAGS-lowlevellock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT
+ASFLAGS-pthread_once.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT
+ASFLAGS-cancellation.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT
 
 
 ASFLAGS-clone.S = -D_LIBC_REENTRANT
 ASFLAGS-vfork.S = -D_LIBC_REENTRANT
 ASFLAGS-libc-lowlevellock.S = -D_LIBC_REENTRANT
-
-ifeq ($(UCLIBC_HAS_THREADS_NATIVE),y)
-#Needed to use the correct SYSCALL_ERROR_HANDLER
-ASFLAGS-clone.S += -DUSE___THREAD
-ASFLAGS-vfork.S += -DUSE___THREAD
-ASFLAGS-sem_wait.S += -DUSE___THREAD
-ASFLAGS-sem_trywait.S += -DUSE___THREAD
-ASFLAGS-sem_timedwait.S += -DUSE___THREAD
-ASFLAGS-sem_post.S += -DUSE___THREAD
-endif
+ASFLAGS-libc-cancellation.S = -D_LIBC_REENTRANT
 
 CFLAGS += $(SSP_ALL_CFLAGS)
 #CFLAGS:=$(CFLAGS:-O1=-O2)
@@ -66,9 +59,12 @@ libpthread-nomulti-y+=$(LINUX_ARCH_OBJS)
 
 LIBC_LINUX_ARCH_OBJ:=$(patsubst %.c,$(LINUX_ARCH_OUT)/%.o,$(libc_a_CSRC))
 LIBC_LINUX_ARCH_OBJ+=$(patsubst %.S,$(LINUX_ARCH_OUT)/%.o,$(libc_a_SSRC))
+LIBRT_LINUX_ARCH_OBJ+=$(patsubst %.S,$(LINUX_ARCH_OUT)/%.o,$(librt_a_SSRC))
 
 libc-static-y+=$(LIBC_LINUX_ARCH_OBJ)
 libc-shared-y+=$(LIBC_LINUX_ARCH_OBJ:.o=.oS)
+librt-static-y+=$(LIBRT_LINUX_ARCH_OBJ)
+librt-shared-y+=$(LIBRT_LINUX_ARCH_OBJ:.o=.oS)
 
 libc-nomulti-y+=$(LIBC_LINUX_ARCH_OBJ)
 
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
index 6806962..13adea7 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/cancellation.S
@@ -19,7 +19,7 @@
 
 #include <sysdep.h>
 #include <tcb-offsets.h>
-#include <kernel-features.h>
+#include <bits/kernel-features.h>
 #include "lowlevellock.h"
 
 #ifdef IS_IN_libpthread
-- 
1.5.6.5



More information about the uClibc mailing list