From 488e56e0d9fca517e62a96d2eae5e1ef9fdb38bc Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Tue, 4 Jan 2011 14:16:50 +0100 Subject: nptl: get rid of preprocessor warning when __ASSUME_TGKILL is not defined A sample of the warning reported while building for ARM that has not __ASSUME_TGKILL defined. libpthread/nptl/sysdeps/unix/sysv/linux/raise.c: In function 'raise': libpthread/nptl/sysdeps/unix/sysv/linux/raise.c:33:5: warning: "__ASSUME_TGKILL" is not defined Signed-off-by: Carmelo Amoroso --- libpthread/nptl/pthread_cancel.c | 2 +- libpthread/nptl/sysdeps/pthread/createthread.c | 2 +- libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c | 4 ++-- libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c | 2 +- libpthread/nptl/sysdeps/unix/sysv/linux/raise.c | 8 ++++---- 5 files changed, 9 insertions(+), 9 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/pthread_cancel.c b/libpthread/nptl/pthread_cancel.c index 4a958bcde..163fa0243 100644 --- a/libpthread/nptl/pthread_cancel.c +++ b/libpthread/nptl/pthread_cancel.c @@ -76,7 +76,7 @@ pthread_cancel ( a signal handler. But this is no allowed, pthread_cancel is not guaranteed to be async-safe. */ int val; -#if __ASSUME_TGKILL +#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), pd->tid, SIGCANCEL); diff --git a/libpthread/nptl/sysdeps/pthread/createthread.c b/libpthread/nptl/sysdeps/pthread/createthread.c index a676e277f..ce86f5f33 100644 --- a/libpthread/nptl/sysdeps/pthread/createthread.c +++ b/libpthread/nptl/sysdeps/pthread/createthread.c @@ -106,7 +106,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, send it the cancellation signal. */ INTERNAL_SYSCALL_DECL (err2); err_out: -#if __ASSUME_TGKILL +#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL (void) INTERNAL_SYSCALL (tgkill, err2, 3, THREAD_GETMEM (THREAD_SELF, pid), pd->tid, SIGCANCEL); diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c index d256ebcb0..622bb66ca 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pt-raise.c @@ -28,7 +28,7 @@ int raise ( int sig) { -#if __ASSUME_TGKILL || defined __NR_tgkill +#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill /* raise is an async-safe function. It could be called while the fork function temporarily invalidated the PID field. Adjust for that. */ @@ -37,7 +37,7 @@ raise ( pid = -pid; #endif -#if __ASSUME_TGKILL +#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL return INLINE_SYSCALL (tgkill, 3, pid, THREAD_GETMEM (THREAD_SELF, tid), sig); #else diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c index 3a70c3764..2d6bb8002 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c @@ -59,7 +59,7 @@ __pthread_kill ( fork, it would have to happen in a signal handler. But this is no allowed, pthread_kill is not guaranteed to be async-safe. */ int val; -#if __ASSUME_TGKILL +#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), tid, signo); #else diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c index da35cfe9f..708ed6d76 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c @@ -30,7 +30,7 @@ raise ( int sig) { struct pthread *pd = THREAD_SELF; -#if __ASSUME_TGKILL || defined __NR_tgkill +#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill pid_t pid = THREAD_GETMEM (pd, pid); #endif pid_t selftid = THREAD_GETMEM (pd, tid); @@ -45,13 +45,13 @@ raise ( #endif THREAD_SETMEM (pd, tid, selftid); -#if __ASSUME_TGKILL || defined __NR_tgkill +#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill /* We do not set the PID field in the TID here since we might be called from a signal handler while the thread executes fork. */ pid = selftid; #endif } -#if __ASSUME_TGKILL || defined __NR_tgkill +#if (defined(__ASSUME_TGKILL) && __ASSUME_TGKILL) || defined __NR_tgkill else /* raise is an async-safe function. It could be called while the fork/vfork function temporarily invalidated the PID field. Adjust for @@ -60,7 +60,7 @@ raise ( pid = (pid & INT_MAX) == 0 ? selftid : -pid; #endif -#if __ASSUME_TGKILL +#if defined(__ASSUME_TGKILL) && __ASSUME_TGKILL return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig); #else # ifdef __NR_tgkill -- cgit v1.2.3 From 8958a63759c2ae23b47e76efeed1b7fc1f22728c Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Wed, 5 Jan 2011 17:22:25 +0100 Subject: nptl: get rid of the last preprocessor warning when __ASSUME_TGKILL is not defined A missing change in the previous commit. Signed-off-by: Carmelo Amoroso --- libpthread/nptl/allocatestack.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpthread') diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index 9ffa7e7e2..1c549cee1 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -993,7 +993,7 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t) int val; INTERNAL_SYSCALL_DECL (err); -#if __ASSUME_TGKILL +#if defined (__ASSUME_TGKILL) && __ASSUME_TGKILL val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid), t->tid, SIGSETXID); #else -- cgit v1.2.3 From 5c02df4f734011cccc65441e5dae2f5c18447f39 Mon Sep 17 00:00:00 2001 From: Will Newton Date: Thu, 20 Jan 2011 15:26:14 +0100 Subject: nptl: fix start_thread() for _STACK_GROWS_UP This patch adds a working implementation of pthread_create for architectures where STACK_GROWS_UP. Signed-off-by: Matt Fleming Signed-off-by: Carmelo Amoroso --- libpthread/nptl/pthread_create.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/pthread_create.c b/libpthread/nptl/pthread_create.c index 63e5588d5..86ff1488b 100644 --- a/libpthread/nptl/pthread_create.c +++ b/libpthread/nptl/pthread_create.c @@ -379,11 +379,11 @@ start_thread (void *arg) /* Mark the memory of the stack as usable to the kernel. We free everything except for the space used for the TCB itself. */ size_t pagesize_m1 = __getpagesize () - 1; -#ifdef _STACK_GROWS_DOWN char *sp = CURRENT_STACK_FRAME; +#ifdef _STACK_GROWS_DOWN size_t freesize = (sp - (char *) pd->stackblock) & ~pagesize_m1; #else -# error "to do" + size_t freesize = ((char *) pd->stackblock - sp) & ~pagesize_m1; #endif assert (freesize < pd->stackblock_size); if (freesize > PTHREAD_STACK_MIN) -- cgit v1.2.3 From 6d5e1c5ee7a3c307251c4be7076982f5a1f1769d Mon Sep 17 00:00:00 2001 From: Will Newton Date: Thu, 20 Jan 2011 15:31:14 +0100 Subject: nptl: Fix __USER_LABEL_PREFIX__ concatenatio The current C macro magic does not correctly concatenate the __USER_LABEL_PREFIX__ string on architectures where it has a non-empty value. We need to use __stringify to get the desired behaviour. Signed-off-by: Will Newton Signed-off-by: Carmelo Amoroso --- libpthread/nptl/pthreadP.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h index c45bd1170..fbac7d08f 100644 --- a/libpthread/nptl/pthreadP.h +++ b/libpthread/nptl/pthreadP.h @@ -274,6 +274,8 @@ __do_cancel (void) #define CANCEL_RESET(oldtype) \ __pthread_disable_asynccancel (oldtype) +#define __LABEL_PREFIX__ __stringify(__USER_LABEL_PREFIX__) + #if !defined NOT_IN_libc /* Same as CANCEL_ASYNC, but for use in libc.so. */ # define LIBC_CANCEL_ASYNC() \ @@ -282,22 +284,22 @@ __do_cancel (void) # define LIBC_CANCEL_RESET(oldtype) \ __libc_disable_asynccancel (oldtype) # define LIBC_CANCEL_HANDLED() \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__libc_enable_asynccancel"); \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__libc_disable_asynccancel") + __asm__ (".globl " __LABEL_PREFIX__ "__libc_enable_asynccancel"); \ + __asm__ (".globl " __LABEL_PREFIX__ "__libc_disable_asynccancel") #elif defined NOT_IN_libc && defined IS_IN_libpthread # define LIBC_CANCEL_ASYNC() CANCEL_ASYNC () # define LIBC_CANCEL_RESET(val) CANCEL_RESET (val) # define LIBC_CANCEL_HANDLED() \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__pthread_enable_asynccancel"); \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__pthread_disable_asynccancel") + __asm__ (".globl " __LABEL_PREFIX__ "__pthread_enable_asynccancel"); \ + __asm__ (".globl " __LABEL_PREFIX__ "__pthread_disable_asynccancel") #elif defined NOT_IN_libc && defined IS_IN_librt # define LIBC_CANCEL_ASYNC() \ __librt_enable_asynccancel () # define LIBC_CANCEL_RESET(val) \ __librt_disable_asynccancel (val) # define LIBC_CANCEL_HANDLED() \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__librt_enable_asynccancel"); \ - __asm__ (".globl " __USER_LABEL_PREFIX__ "__librt_disable_asynccancel") + __asm__ (".globl " __LABEL_PREFIX__ "__librt_enable_asynccancel"); \ + __asm__ (".globl " __LABEL_PREFIX__ "__librt_disable_asynccancel") #else # define LIBC_CANCEL_ASYNC() 0 /* Just a dummy value. */ # define LIBC_CANCEL_RESET(val) ((void)(val)) /* Nothing, but evaluate it. */ -- cgit v1.2.3