diff options
author | Khem Raj <raj.khem@gmail.com> | 2010-05-05 22:50:19 -0700 |
---|---|---|
committer | Khem Raj <raj.khem@gmail.com> | 2010-05-09 22:53:25 -0700 |
commit | e3dec33ba03ef7080a39444388a01e59135bb3aa (patch) | |
tree | 9693449a78a556a91ddba349116d9c988399071a /libpthread/nptl | |
parent | d2ab6ee38dd6ef107bac77f485ab1bb35b177e6c (diff) |
powerpc: Add TLS and NPTL support
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Diffstat (limited to 'libpthread/nptl')
21 files changed, 180 insertions, 37 deletions
diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile b/libpthread/nptl/sysdeps/powerpc/Makefile deleted file mode 100644 index 3af245600..000000000 --- a/libpthread/nptl/sysdeps/powerpc/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2003 Free Software Foundation, Inc. -# This file is part of the GNU C Library. - -# The GNU C Library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. - -# The GNU C Library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. - -# You should have received a copy of the GNU Lesser General Public -# License along with the GNU C Library; if not, write to the Free -# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA -# 02111-1307 USA. - -ifeq ($(subdir),csu) -gen-as-const-headers += tcb-offsets.sym -endif diff --git a/libpthread/nptl/sysdeps/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/powerpc/Makefile.arch new file mode 100644 index 000000000..bd34063b5 --- /dev/null +++ b/libpthread/nptl/sysdeps/powerpc/Makefile.arch @@ -0,0 +1,50 @@ +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +PTHREAD_ARCH_DIR := $(top_srcdir)libpthread/nptl/sysdeps/powerpc +PTHREAD_ARCH_OUT := $(top_builddir)libpthread/nptl/sysdeps/powerpc + +libpthread_SSRC = +libpthread_CSRC = pthread_spin_lock.c pthread_spin_trylock.c + +PTHREAD_ARCH_OBJ := $(patsubst %.S,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_SSRC)) +PTHREAD_ARCH_OBJ += $(patsubst %.c,$(PTHREAD_ARCH_OUT)/%.o,$(libpthread_CSRC)) + +ifeq ($(DOPIC),y) +libpthread-a-y += $(PTHREAD_ARCH_OBJ:.o=.os) +else +libpthread-a-y += $(PTHREAD_ARCH_OBJ) +endif +libpthread-so-y += $(PTHREAD_ARCH_OBJ:.o=.oS) + +libpthread-nomulti-y += $(PTHREAD_ARCH_OBJ) + +CFLAGS-powerpc = $(SSP_ALL_CFLAGS) + +# +# Create 'tcb-offsets.h' header file. +# +CFLAGS-tcb-offsets.c = -S + +$(PTHREAD_ARCH_OUT)/tcb-offsets.c: $(PTHREAD_ARCH_DIR)/tcb-offsets.sym + $(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@ + +$(PTHREAD_ARCH_OUT)/tcb-offsets.s: $(PTHREAD_ARCH_OUT)/tcb-offsets.c + $(compile.c) + +$(PTHREAD_ARCH_OUT)/tcb-offsets.h: $(PTHREAD_ARCH_OUT)/tcb-offsets.s + $(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@ + +pregen-headers-$(UCLIBC_HAS_THREADS_NATIVE) += $(PTHREAD_ARCH_OUT)/tcb-offsets.h + +nptl_arch_headers_clean: + $(RM) $(PTHREAD_ARCH_OUT)/tcb-offsets.c \ + $(PTHREAD_ARCH_OUT)/tcb-offsets.s \ + $(PTHREAD_ARCH_OUT)/tcb-offsets.h + +nptl_arch_objclean: + $(RM) $(PTHREAD_ARCH_OUT)/*.{o,os,oS} diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c index e2293fda1..9334d4217 100644 --- a/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c +++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_lock.c @@ -20,12 +20,11 @@ #include "pthreadP.h" int -pthread_spin_lock (lock) - pthread_spinlock_t *lock; +pthread_spin_lock (pthread_spinlock_t *lock) { unsigned int __tmp; - asm volatile ( + __asm__ __volatile__ ( "1: lwarx %0,0,%1\n" " cmpwi 0,%0,0\n" " bne- 2f\n" diff --git a/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c index d8e1dbcc8..a2757e207 100644 --- a/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c +++ b/libpthread/nptl/sysdeps/powerpc/pthread_spin_trylock.c @@ -21,13 +21,12 @@ #include "pthreadP.h" int -pthread_spin_trylock (lock) - pthread_spinlock_t *lock; +pthread_spin_trylock (pthread_spinlock_t *lock) { unsigned int old; int err = EBUSY; - asm ("1: lwarx %0,0,%2\n" + __asm__ ("1: lwarx %0,0,%2\n" " cmpwi 0,%0,0\n" " bne 2f\n" " stwcx. %3,0,%2\n" diff --git a/libpthread/nptl/sysdeps/powerpc/tls.h b/libpthread/nptl/sysdeps/powerpc/tls.h index ce5559eef..990972eaa 100644 --- a/libpthread/nptl/sysdeps/powerpc/tls.h +++ b/libpthread/nptl/sysdeps/powerpc/tls.h @@ -40,6 +40,13 @@ typedef union dtv # include <tcb-offsets.h> #endif /* __ASSEMBLER__ */ +/* We require TLS support in the tools. */ +#define HAVE_TLS_SUPPORT 1 +#define HAVE_TLS_MODEL_ATTRIBUTE 1 +#define HAVE___THREAD 1 + +/* Signal that TLS support is available. */ +#define USE_TLS 1 /* We require TLS support in the tools. */ #ifndef HAVE_TLS_SUPPORT @@ -61,7 +68,7 @@ typedef union dtv #define TLS_MULTIPLE_THREADS_IN_TCB 1 /* Get the thread descriptor definition. */ -# include <nptl/descr.h> +# include <../../descr.h> /* The stack_guard is accessed directly by GCC -fstack-protector code, so it is a part of public ABI. The dtv and pointer_guard fields diff --git a/libpthread/nptl/sysdeps/pthread/Makefile.in b/libpthread/nptl/sysdeps/pthread/Makefile.in index 000d18b1d..36d9eeb90 100644 --- a/libpthread/nptl/sysdeps/pthread/Makefile.in +++ b/libpthread/nptl/sysdeps/pthread/Makefile.in @@ -43,6 +43,17 @@ SH_PTHREAD_EXCLUDE_LIST = pthread_spin_unlock.c pthread_spin_init.c \ libpthread_CSRC := $(filter-out $(SH_PTHREAD_EXCLUDE_LIST),$(libpthread_CSRC)) endif +ifeq ($(TARGET_ARCH),powerpc) +#EXCLUDE_LIST := pthread_cond_broadcast.c \ +# pthread_cond_signal.c pthread_cond_timedwait.c \ +# pthread_cond_wait.c \ +# pthread_spin_init.c \ +# pthread_spin_unlock.c pt-sigfillset.c \ +# pt-longjmp.c +# +#libpthread_CSRC := $(filter-out $(EXCLUDE_LIST),$(libpthread_CSRC)) +endif + ifeq ($(TARGET_ARCH),sparc) SPARC_PTHREAD_EXCLUDE_LIST = pthread_barrier_init.c pthread_barrier_wait.c \ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in index 1c75c14c5..c2ade848e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in @@ -45,9 +45,9 @@ libc_CSRC += libc-lowlevellock.c endif ifeq ($(TARGET_ARCH),powerpc) -libpthread_CSRC += lowlevellock.c +libpthread_CSRC += lowlevellock.c lowlevelrobustlock.c libc_CSRC += libc-lowlevellock.c -librt_CSRC := mq_notify.c +librt_CSRC += __syscall_error.c endif ifeq ($(TARGET_ARCH),sparc) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c index 6a51e73da..2b19fd5d9 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/createthread.c @@ -20,4 +20,4 @@ #define TLS_VALUE (pd + 1) /* Get the real implementation. */ -#include <nptl/sysdeps/pthread/createthread.c> +#include <sysdeps/pthread/createthread.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile index e98c9bd86..421a62b3d 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile @@ -1,2 +1,13 @@ -# pull in __syscall_error routine -libpthread-routines += sysdep +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +top_srcdir=../../../../../../../ +top_builddir=../../../../../../../ +all: objs +include $(top_builddir)Rules.mak +include Makefile.arch +include $(top_srcdir)Makerules diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch new file mode 100644 index 000000000..2c39551dc --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch @@ -0,0 +1,62 @@ +# Makefile for uClibc NPTL +# +# Copyright (C) 2009 Bernhard Reutner-Fischer <uclibc@uclibc.org> +# +# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. +# + +libpthread_LINUX_ARCH_SSRC = pt-vfork.S +libpthread_LINUX_ARCH_CSRC = pthread_once.c pt-__syscall_error.c + +libc_a_CSRC = fork.c +libc_a_SSRC = clone.S vfork.S + +ARCH_OBJS += $(libc_a_SSRC:.S=.c) + +CFLAGS += $(SSP_ALL_CFLAGS) +ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y) +CFLAGS-fork.c = -D__USE_STDIO_FUTEXES__ +endif + +CFLAGS-pthread_once.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 +CFLAGS-lowlevellock.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 +CFLAGS-pt-__syscall_error.c = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 + +ASFLAGS-pt-vfork.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD +#ASFLAGS-libc-lowlevellock.S = -D_LIBC_REENTRANT -DUSE___THREAD +#ASFLAGS-lowlevellock.S = -DNOT_IN_libc=1 -DIS_IN_libpthread=1 -D_LIBC_REENTRANT -DUSE___THREAD +ASFLAGS-clone.S = -D_LIBC_REENTRANT +ASFLAGS-vfork.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 +endif + +LINUX_ARCH_DIR:=$(top_srcdir)libpthread/nptl/sysdeps/unix/sysv/linux/powerpc +LINUX_ARCH_OUT:=$(top_builddir)libpthread/nptl/sysdeps/unix/sysv/linux/powerpc +LINUX_ARCH_OBJ:=$(patsubst %.S,$(LINUX_ARCH_OUT)/%.o,$(libpthread_LINUX_ARCH_SSRC)) +LINUX_ARCH_OBJ+=$(patsubst %.c,$(LINUX_ARCH_OUT)/%.o,$(libpthread_LINUX_ARCH_CSRC)) + +ifeq ($(DOPIC),y) +libpthread-a-y += $(LINUX_ARCH_OBJ:.o=.os) +else +libpthread-a-y += $(LINUX_ARCH_OBJ) +endif +libpthread-so-y += $(LINUX_ARCH_OBJ:.o=.oS) + +libpthread-multi-y+=$(libpthread_LINUX_ARCH_CSRC) + +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)) + +libc-static-y+=$(LIBC_LINUX_ARCH_OBJ) +libc-shared-y+=$(LIBC_LINUX_ARCH_OBJ:.o=.oS) + +libc-multi-y+=$(libc_a_CSRC) + +objclean-y+=nptl_linux_arch_clean + +nptl_linux_arch_clean: + $(do_rm) $(addprefix $(LINUX_ARCH_OUT)/*., o os oS) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S new file mode 100644 index 000000000..91c939e57 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/clone.S" +#else +# include "powerpc32/clone.S" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c index e811ad74e..26efabd0d 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/createthread.c @@ -22,4 +22,4 @@ + TLS_TCB_OFFSET + TLS_PRE_TCB_SIZE) /* Get the real implementation. */ -#include <nptl/sysdeps/pthread/createthread.c> +#include <sysdeps/pthread/createthread.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h index 66c02cbbd..ecfa9702e 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/lowlevellock.h @@ -24,7 +24,8 @@ #include <sys/param.h> #include <bits/pthreadtypes.h> #include <atomic.h> -#include <kernel-features.h> +#include <bits/kernel-features.h> +#include <sysdep.h> #ifndef __NR_futex # define __NR_futex 221 diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h index 88b24e7d9..4daa115ed 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep-cancel.h @@ -21,7 +21,7 @@ #include <sysdep.h> #include <tls.h> #ifndef __ASSEMBLER__ -# include <nptl/pthreadP.h> +# include <pthreadP.h> #endif #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S index eed2a8f1a..8d3773ca4 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S @@ -55,3 +55,4 @@ ENTRY (__vfork) PSEUDO_END (__vfork) libc_hidden_def (__vfork) weak_alias (__vfork, vfork) +libc_hidden_weak(vfork) diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h index 707765ab5..8e5e477b3 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep-cancel.h @@ -21,7 +21,7 @@ #include <sysdep.h> #include <tls.h> #ifndef __ASSEMBLER__ -# include <nptl/pthreadP.h> +# include <pthreadP.h> #endif #if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S index 26885bb95..64aa952cd 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/powerpc64/vfork.S @@ -53,3 +53,5 @@ ENTRY (__vfork) PSEUDO_END (__vfork) libc_hidden_def (__vfork) weak_alias (__vfork, vfork) +libc_hidden_weak(vfork) + diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c new file mode 100644 index 000000000..2a402e5af --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-__syscall_error.c @@ -0,0 +1 @@ +#include <../../../../../../../libc/sysdeps/linux/powerpc/__syscall_error.c> diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S new file mode 100644 index 000000000..0225219d9 --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/pt-vfork.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/pt-vfork.S" +#else +# include "powerpc32/pt-vfork.S" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h new file mode 100644 index 000000000..dab7e0beb --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/sysdep-cancel.h @@ -0,0 +1,5 @@ +#if defined(__powerpc64__) +#include "powerpc64/sysdep-cancel.h" +#else +#include "powerpc32/sysdep-cancel.h" +#endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S new file mode 100644 index 000000000..27d29020e --- /dev/null +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S @@ -0,0 +1,5 @@ +#if defined __powerpc64__ +# include "powerpc64/vfork.S" +#else +# include "powerpc32/vfork.S" +#endif |