From 6a0aa4add30eecf76b9d14ad3f204e4017f9f22c Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 9 Feb 2011 20:08:20 +0100 Subject: arm: mv nptl specific atomic impl to common place Thanks to Nitin Garg for notincing! Signed-off-by: Bernhard Reutner-Fischer --- .../nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h | 122 --------------------- 1 file changed, 122 deletions(-) delete mode 100644 libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h deleted file mode 100644 index 8f63e2510..000000000 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2002, 2003, 2004, 2005 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. */ - -#include -#include - - -typedef int8_t atomic8_t; -typedef uint8_t uatomic8_t; -typedef int_fast8_t atomic_fast8_t; -typedef uint_fast8_t uatomic_fast8_t; - -typedef int32_t atomic32_t; -typedef uint32_t uatomic32_t; -typedef int_fast32_t atomic_fast32_t; -typedef uint_fast32_t uatomic_fast32_t; - -typedef intptr_t atomicptr_t; -typedef uintptr_t uatomicptr_t; -typedef intmax_t atomic_max_t; -typedef uintmax_t uatomic_max_t; - -void __arm_link_error (void); - -#ifdef __thumb2__ -#define atomic_full_barrier() \ - __asm__ __volatile__ \ - ("movw\tip, #0x0fa0\n\t" \ - "movt\tip, #0xffff\n\t" \ - "blx\tip" \ - : : : "ip", "lr", "cc", "memory"); -#else -#define atomic_full_barrier() \ - __asm__ __volatile__ \ - ("mov\tip, #0xffff0fff\n\t" \ - "mov\tlr, pc\n\t" \ - "add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" \ - : : : "ip", "lr", "cc", "memory"); -#endif - -/* Atomic compare and exchange. This sequence relies on the kernel to - provide a compare and exchange operation which is atomic on the - current architecture, either via cleverness on pre-ARMv6 or via - ldrex / strex on ARMv6. */ - -#define __arch_compare_and_exchange_val_8_acq(mem, newval, oldval) \ - ({ __arm_link_error (); oldval; }) - -#define __arch_compare_and_exchange_val_16_acq(mem, newval, oldval) \ - ({ __arm_link_error (); oldval; }) - -/* It doesn't matter what register is used for a_oldval2, but we must - specify one to work around GCC PR rtl-optimization/21223. Otherwise - it may cause a_oldval or a_tmp to be moved to a different register. */ - -#ifdef __thumb2__ -/* Thumb-2 has ldrex/strex. However it does not have barrier instructions, - so we still need to use the kernel helper. */ -#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ - ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \ - register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \ - register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \ - register __typeof (oldval) a_tmp __asm__ ("r3"); \ - register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \ - __asm__ __volatile__ \ - ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \ - "cmp\t%[tmp], %[old2]\n\t" \ - "bne\t1f\n\t" \ - "mov\t%[old], %[old2]\n\t" \ - "movw\t%[tmp], #0x0fc0\n\t" \ - "movt\t%[tmp], #0xffff\n\t" \ - "blx\t%[tmp]\n\t" \ - "bcc\t0b\n\t" \ - "mov\t%[tmp], %[old2]\n\t" \ - "1:" \ - : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \ - : [new] "r" (a_newval), [ptr] "r" (a_ptr), \ - [old2] "r" (a_oldval2) \ - : "ip", "lr", "cc", "memory"); \ - a_tmp; }) -#else -#define __arch_compare_and_exchange_val_32_acq(mem, newval, oldval) \ - ({ register __typeof (oldval) a_oldval __asm__ ("r0"); \ - register __typeof (oldval) a_newval __asm__ ("r1") = (newval); \ - register __typeof (mem) a_ptr __asm__ ("r2") = (mem); \ - register __typeof (oldval) a_tmp __asm__ ("r3"); \ - register __typeof (oldval) a_oldval2 __asm__ ("r4") = (oldval); \ - __asm__ __volatile__ \ - ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \ - "cmp\t%[tmp], %[old2]\n\t" \ - "bne\t1f\n\t" \ - "mov\t%[old], %[old2]\n\t" \ - "mov\t%[tmp], #0xffff0fff\n\t" \ - "mov\tlr, pc\n\t" \ - "add\tpc, %[tmp], #(0xffff0fc0 - 0xffff0fff)\n\t" \ - "bcc\t0b\n\t" \ - "mov\t%[tmp], %[old2]\n\t" \ - "1:" \ - : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \ - : [new] "r" (a_newval), [ptr] "r" (a_ptr), \ - [old2] "r" (a_oldval2) \ - : "ip", "lr", "cc", "memory"); \ - a_tmp; }) -#endif - -#define __arch_compare_and_exchange_val_64_acq(mem, newval, oldval) \ - ({ __arm_link_error (); oldval; }) -- cgit v1.2.3 From 7a583ea370974998b4584595b9a4088fc070df1f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 21 Feb 2011 17:19:35 -0500 Subject: linuxthreads.old: fix nommu initial thread stack detection Because the nommu address space is flat, and the application stack can literally be located anywhere, we cannot rely on the assumptions that the mmu port gets away with. Namely, that the first thread's stack lives at the top of memory and nothing will be created above it. Currently, the code rounds the current stack up a page and sets that as the "top" of the stack, and then marks the "bottom" of the stack as "1". Then as new threads are created, this assumption is further refined by slowly backing off the "bottom" when a new stack is created within the range of the initial stack. Simple ascii example (tid0 is the initial thread): 1 thread: [bos tid0 stack tos] 2 threads: [ tid0 stack ] [tid1 stack] 3 threads: [ tid0 stack ] [tid1 stack] [tid2 stack] As you can kind of see, this algorithm operates on one basic assumption: the initial top of stack calculation is the absolute top of the stack. While this assumption was fairly safe in the original nommu days of yore where the only file format was FLAT (which defaults to a 4KiB stack -- exactly 1 page), and memory was fairly tight, we can see that this falls apart pretty quickly as soon as the initial stack is larger than a page. The issue that crops up now is simple to hit: start an application with an 8KiB stack, execute some functions that put pressure on the stack so that it exceeds 4KiB, then start up some threads. The initial tos will be rounded up by a page, but this is actually the middle of the stack. Now when the initial thread returns from its functions (thus unwinding the stack) and tries to call something which calls back into libpthread, the thread_self() func fails to detect itself as the initial thread as the current stack is now above the tos. The __pthread_find_self() func kicks in, walks all the thread arrays, fails to find a hit, and then walks into uninitialized memory for the thread descriptor. Use of this garbage memory has obvious results -- things fall down & go boom. To address this, I extend the current algorithm to automatically scale back both the bottom and the top stack limits of the initial thread. We use the current stack pointer at "thread boot time" only as a single known point. The initial thread stack bottom is set to the bottom of memory and the initial thread stack top is set to the top of memory. Then as we create new stack threads, we figure out whether the new stack is above or below the single known good address, and then scale back either the tos or the bos accordingly. Reviewed-by: Steven J. Magnani Signed-off-by: Mike Frysinger --- libpthread/linuxthreads.old/internals.h | 24 ++++++++++++++++-------- libpthread/linuxthreads.old/pthread.c | 23 ++++++++++++++--------- 2 files changed, 30 insertions(+), 17 deletions(-) (limited to 'libpthread') diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h index 637fcea62..110dd9d56 100644 --- a/libpthread/linuxthreads.old/internals.h +++ b/libpthread/linuxthreads.old/internals.h @@ -252,17 +252,25 @@ extern pthread_descr __pthread_main_thread; Initially 0, meaning that the current thread is (by definition) the initial thread. */ -/* For non-MMU systems also remember to stack top of the initial thread. - * This is adapted when other stacks are malloc'ed since we don't know - * the bounds a-priori. -StS */ - extern char *__pthread_initial_thread_bos; #ifndef __ARCH_USE_MMU__ -extern char *__pthread_initial_thread_tos; +/* For non-MMU systems, we have no idea the bounds of the initial thread + * stack, so we have to track it on the fly relative to other stacks. Do + * so by scaling back our assumptions on the limits of the bos/tos relative + * to the known mid point. See also the comments in pthread_initialize(). */ +extern char *__pthread_initial_thread_tos, *__pthread_initial_thread_mid; #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \ - if ((tos)>=__pthread_initial_thread_bos \ - && (bos)<__pthread_initial_thread_tos) \ - __pthread_initial_thread_bos = (tos)+1 + do { \ + char *__tos = (tos); \ + char *__bos = (bos); \ + if (__tos >= __pthread_initial_thread_bos && \ + __bos < __pthread_initial_thread_tos) { \ + if (__bos < __pthread_initial_thread_mid) \ + __pthread_initial_thread_bos = __tos; \ + else \ + __pthread_initial_thread_tos = __bos; \ + } \ + } while (0) #else #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */ #endif /* __ARCH_USE_MMU__ */ diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c index ad392e34e..a8830b1a4 100644 --- a/libpthread/linuxthreads.old/pthread.c +++ b/libpthread/linuxthreads.old/pthread.c @@ -168,12 +168,10 @@ pthread_descr __pthread_main_thread = &__pthread_initial_thread; char *__pthread_initial_thread_bos = NULL; -/* For non-MMU systems also remember to stack top of the initial thread. - * This is adapted when other stacks are malloc'ed since we don't know - * the bounds a-priori. -StS */ - #ifndef __ARCH_USE_MMU__ +/* See nommu notes in internals.h and pthread_initialize() below. */ char *__pthread_initial_thread_tos = NULL; +char *__pthread_initial_thread_mid = NULL; #endif /* __ARCH_USE_MMU__ */ /* File descriptor for sending requests to the thread manager. */ @@ -457,12 +455,19 @@ static void pthread_initialize(void) setrlimit(RLIMIT_STACK, &limit); } #else - /* For non-MMU assume __pthread_initial_thread_tos at upper page boundary, and - * __pthread_initial_thread_bos at address 0. These bounds are refined as we - * malloc other stack frames such that they don't overlap. -StS + /* For non-MMU, the initial thread stack can reside anywhere in memory. + * We don't have a way of knowing where the kernel started things -- top + * or bottom (well, that isn't exactly true, but the solution is fairly + * complex and error prone). All we can determine here is an address + * that lies within that stack. Save that address as a reference so that + * as other thread stacks are created, we can adjust the estimated bounds + * of the initial thread's stack appropriately. + * + * This checking is handled in NOMMU_INITIAL_THREAD_BOUNDS(), so see that + * for a few more details. */ - __pthread_initial_thread_tos = - (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 1)); + __pthread_initial_thread_mid = CURRENT_STACK_FRAME; + __pthread_initial_thread_tos = (char *) -1; __pthread_initial_thread_bos = (char *) 1; /* set it non-zero so we know we have been here */ PDEBUG("initial thread stack bounds: bos=%p, tos=%p\n", __pthread_initial_thread_bos, __pthread_initial_thread_tos); -- cgit v1.2.3 From be88a80858ea4febcc621f87166fbf4c1753e513 Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Mon, 7 Feb 2011 18:03:36 +0100 Subject: nptl:arm: add a wrapper for .cfi_sections pseudo-ops ARM disables by default the support for ASM CFI directives. Anyway using an old version of binutils that does not support some new pseudo-op, the build fails as below: AS libpthread/nptl/sysdeps/unix/sysv/linux/close.oS libpthread/nptl/sysdeps/unix/sysv/linux/close.S: Assembler messages: libpthread/nptl/sysdeps/unix/sysv/linux/close.S:9: Error: unknown pseudo-op: `.cfi_sections' The problem is that the .cfi_sections pseudo should be wrapped by a macro that expands to nothing when the CFI is off. Signed-off-by: Carmelo Amoroso CC: Khem Ray --- libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h | 2 +- libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h index 7ac9ca1e9..f0e5f6b37 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h @@ -36,7 +36,7 @@ .type __##syscall_name##_nocancel,%function; \ .globl __##syscall_name##_nocancel; \ __##syscall_name##_nocancel: \ - .cfi_sections .debug_frame; \ + cfi_sections(.debug_frame); \ cfi_startproc; \ DO_CALL (syscall_name, args); \ PSEUDO_RET; \ diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c index e35374d34..15250157c 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c @@ -65,7 +65,7 @@ __asm__ ( " .globl _Unwind_Resume\n" " .type _Unwind_Resume, %function\n" "_Unwind_Resume:\n" -" .cfi_sections .debug_frame\n" +" " CFI_SECTIONS (.debug_frame) "\n" " " CFI_STARTPROC "\n" " stmfd sp!, {r4, r5, r6, lr}\n" " " CFI_ADJUST_CFA_OFFSET (16)" \n" -- cgit v1.2.3 From 099b65127dd434846ca75d5fb11c2db303ed77a6 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 26 Feb 2011 19:23:10 +0100 Subject: avoid warnings on _STACK_GROWS_* usage Signed-off-by: Peter S. Mazinger --- libpthread/linuxthreads/cancel.c | 2 +- libpthread/linuxthreads/manager.c | 10 +++++----- libpthread/linuxthreads/ptcleanup.c | 4 ++-- libpthread/linuxthreads/pthread.c | 4 ++-- libpthread/nptl/allocatestack.c | 16 ++++++++-------- libpthread/nptl/pt-cleanup.c | 4 ++-- libpthread/nptl/unwind.c | 2 +- 7 files changed, 21 insertions(+), 21 deletions(-) (limited to 'libpthread') diff --git a/libpthread/linuxthreads/cancel.c b/libpthread/linuxthreads/cancel.c index 34356801a..43f04457b 100644 --- a/libpthread/linuxthreads/cancel.c +++ b/libpthread/linuxthreads/cancel.c @@ -23,7 +23,7 @@ #ifdef _STACK_GROWS_DOWN # define FRAME_LEFT(frame, other) ((char *) frame >= (char *) other) -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP # define FRAME_LEFT(frame, other) ((char *) frame <= (char *) other) #else # error "Define either _STACK_GROWS_DOWN or _STACK_GROWS_UP" diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c index 4293741ac..1dd626e23 100644 --- a/libpthread/linuxthreads/manager.c +++ b/libpthread/linuxthreads/manager.c @@ -445,7 +445,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr, new_thread = ((pthread_descr) (new_thread_bottom + stacksize + guardsize)) - 1; # endif -# elif _STACK_GROWS_DOWN +# elif defined _STACK_GROWS_DOWN guardaddr = map_addr; if (guardsize > 0) mprotect (guardaddr, guardsize, PROT_NONE); @@ -456,7 +456,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr, # else new_thread = ((pthread_descr) (new_thread_bottom + stacksize)) - 1; # endif -# elif _STACK_GROWS_UP +# elif defined _STACK_GROWS_UP guardaddr = map_addr + stacksize; if (guardsize > 0) mprotect (guardaddr, guardsize, PROT_NONE); @@ -744,7 +744,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, (char *)stack_addr - new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM | __pthread_sig_cancel, new_thread); -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP pid = __clone(pthread_start_thread_event, (void *) new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM | __pthread_sig_cancel, new_thread); @@ -785,7 +785,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, (char *)stack_addr - new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM | __pthread_sig_cancel, new_thread); -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP pid = __clone(pthread_start_thread, (void *) new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM | __pthread_sig_cancel, new_thread); @@ -806,7 +806,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, - new_thread_bottom); munmap((caddr_t)new_thread_bottom, 2 * stacksize + new_thread->p_guardsize); -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP # ifdef USE_TLS size_t stacksize = guardaddr - stack_addr; munmap(stack_addr, stacksize + guardsize); diff --git a/libpthread/linuxthreads/ptcleanup.c b/libpthread/linuxthreads/ptcleanup.c index 6213b56f3..75bb7d599 100644 --- a/libpthread/linuxthreads/ptcleanup.c +++ b/libpthread/linuxthreads/ptcleanup.c @@ -49,13 +49,13 @@ void __pthread_cleanup_upto (__jmp_buf target, char *targetframe) c != NULL && __JMPBUF_UNWINDS(target, c, demangle_ptr); c = c->__prev) { -#if _STACK_GROWS_DOWN +#ifdef _STACK_GROWS_DOWN if ((char *) c <= targetframe) { c = NULL; break; } -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP if ((char *) c >= targetframe) { c = NULL; diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c index db436342f..c3e28c6ac 100644 --- a/libpthread/linuxthreads/pthread.c +++ b/libpthread/linuxthreads/pthread.c @@ -750,7 +750,7 @@ int __pthread_initialize_manager(void) THREAD_MANAGER_STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr); -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP pid = __clone(__pthread_manager_event, (void **) __pthread_manager_thread_bos, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, @@ -789,7 +789,7 @@ int __pthread_initialize_manager(void) pid = __clone2(__pthread_manager, (void **) __pthread_manager_thread_bos, THREAD_MANAGER_STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr); -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP pid = __clone(__pthread_manager, (void **) __pthread_manager_thread_bos, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | CLONE_SYSVSEM, mgr); #else diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index 1c549cee1..6a4e252e8 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -316,10 +316,10 @@ change_stack_perm (struct pthread *pd + (((((pd->stackblock_size - pd->guardsize) / 2) & pagemask) + pd->guardsize) & pagemask)); size_t len = pd->stackblock + pd->stackblock_size - stack; -#elif _STACK_GROWS_DOWN +#elif defined _STACK_GROWS_DOWN void *stack = pd->stackblock + pd->guardsize; size_t len = pd->stackblock_size - pd->guardsize; -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP void *stack = pd->stackblock; size_t len = (uintptr_t) pd - pd->guardsize - (uintptr_t) pd->stackblock; #else @@ -591,9 +591,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, { #ifdef NEED_SEPARATE_REGISTER_STACK char *guard = mem + (((size - guardsize) / 2) & ~pagesize_m1); -#elif _STACK_GROWS_DOWN +#elif defined _STACK_GROWS_DOWN char *guard = mem; -# elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP char *guard = (char *) (((uintptr_t) pd - guardsize) & ~pagesize_m1); #endif if (mprotect (guard, guardsize, PROT_NONE) != 0) @@ -641,11 +641,11 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, oldguard + pd->guardsize - guard - guardsize, prot) != 0) goto mprot_error; -#elif _STACK_GROWS_DOWN +#elif defined _STACK_GROWS_DOWN if (mprotect ((char *) mem + guardsize, pd->guardsize - guardsize, prot) != 0) goto mprot_error; -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP if (mprotect ((char *) pd - pd->guardsize, pd->guardsize - guardsize, prot) != 0) goto mprot_error; @@ -688,9 +688,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, #ifdef NEED_SEPARATE_REGISTER_STACK *stack = pd->stackblock; *stacksize = stacktop - *stack; -#elif _STACK_GROWS_DOWN +#elif defined _STACK_GROWS_DOWN *stack = stacktop; -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP *stack = pd->stackblock; assert (*stack > 0); #endif diff --git a/libpthread/nptl/pt-cleanup.c b/libpthread/nptl/pt-cleanup.c index 97673b6c5..d7394ae44 100644 --- a/libpthread/nptl/pt-cleanup.c +++ b/libpthread/nptl/pt-cleanup.c @@ -39,13 +39,13 @@ __pthread_cleanup_upto (__jmp_buf target, char *targetframe) cbuf != NULL && _JMPBUF_UNWINDS_ADJ (target, cbuf, adj); cbuf = cbuf->__prev) { -#if _STACK_GROWS_DOWN +#ifdef _STACK_GROWS_DOWN if ((uintptr_t) cbuf - adj <= targetframe_adj) { cbuf = NULL; break; } -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP if ((uintptr_t) cbuf - adj >= targetframe_adj) { cbuf = NULL; diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c index c7e01e764..0322a6023 100644 --- a/libpthread/nptl/unwind.c +++ b/libpthread/nptl/unwind.c @@ -30,7 +30,7 @@ #ifdef _STACK_GROWS_DOWN # define FRAME_LEFT(frame, other, adj) \ ((uintptr_t) frame - adj >= (uintptr_t) other - adj) -#elif _STACK_GROWS_UP +#elif defined _STACK_GROWS_UP # define FRAME_LEFT(frame, other, adj) \ ((uintptr_t) frame - adj <= (uintptr_t) other - adj) #else -- cgit v1.2.3 From de71e42c04a7d35cf663b1c84ac1de5b6b93b052 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 26 Feb 2011 19:26:30 +0100 Subject: syntax fixes Avoid compile warnings about the use of undefined constants Signed-off-by: Peter S. Mazinger --- libpthread/nptl/allocatestack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c index 6a4e252e8..e30fe41a2 100644 --- a/libpthread/nptl/allocatestack.c +++ b/libpthread/nptl/allocatestack.c @@ -122,7 +122,7 @@ static uintptr_t in_flight_stack; list_t __stack_user __attribute__ ((nocommon)); hidden_data_def (__stack_user) -#if COLORING_INCREMENT != 0 +#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0 /* Number of threads created. */ static unsigned int nptl_ncreated; #endif @@ -443,7 +443,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, void *mem = 0; const int prot = (PROT_READ | PROT_WRITE); -#if COLORING_INCREMENT != 0 +#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0 /* Add one more page for stack coloring. Don't do it for stacks with 16 times pagesize or larger. This might just cause unnecessary misalignment. */ @@ -474,7 +474,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, adjust the allocated stack size if necessary. This way allocations directly following each other will not have aliasing problems. */ -#if MULTI_PAGE_ALIASING != 0 +#if defined MULTI_PAGE_ALIASING && MULTI_PAGE_ALIASING != 0 if ((size % MULTI_PAGE_ALIASING) == 0) size += pagesize_m1 + 1; #endif @@ -494,7 +494,7 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, So we can never get a null pointer back from mmap. */ assert (mem != NULL); -#if COLORING_INCREMENT != 0 +#if defined COLORING_INCREMENT && COLORING_INCREMENT != 0 /* Atomically increment NCREATED. */ unsigned int ncreated = atomic_increment_val (&nptl_ncreated); -- cgit v1.2.3 From 1fc68eae4846de4a1e276e68aee743ef731f3e91 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 26 Feb 2011 19:31:39 +0100 Subject: add missing prototypes Add some missing prototypes Signed-off-by: Peter S. Mazinger --- libpthread/nptl/sysdeps/generic/dl-tls.c | 2 ++ libpthread/nptl/sysdeps/generic/libc-tls.c | 1 + libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c | 1 + 3 files changed, 4 insertions(+) (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/generic/dl-tls.c b/libpthread/nptl/sysdeps/generic/dl-tls.c index 4acfa4ba7..904da8b8d 100644 --- a/libpthread/nptl/sysdeps/generic/dl-tls.c +++ b/libpthread/nptl/sysdeps/generic/dl-tls.c @@ -66,6 +66,7 @@ oom (void) # endif +void *_dl_memalign(size_t alignment, size_t bytes); void *_dl_memalign(size_t alignment, size_t bytes) { return _dl_malloc(bytes); @@ -836,6 +837,7 @@ __tls_get_addr (GET_ADDR_ARGS) +void _dl_add_to_slotinfo (struct link_map *l); void _dl_add_to_slotinfo (struct link_map *l) { diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c index b78d96483..c45e76120 100644 --- a/libpthread/nptl/sysdeps/generic/libc-tls.c +++ b/libpthread/nptl/sysdeps/generic/libc-tls.c @@ -110,6 +110,7 @@ init_static_tls (size_t memsz, size_t align) GL(dl_tls_static_nelem) = GL(dl_tls_max_dtv_idx); } +void __libc_setup_tls (size_t tcbsize, size_t tcbalign); void __libc_setup_tls (size_t tcbsize, size_t tcbalign) { diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c index f2795510a..642198bad 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c @@ -25,6 +25,7 @@ extern void __pthread_cleanup_upto (__jmp_buf env, char *targetframe); #pragma weak __pthread_cleanup_upto +void _longjmp_unwind (jmp_buf env, int val); void _longjmp_unwind (jmp_buf env, int val) { -- cgit v1.2.3 From 380b5c5b31bdbf5e171ce035009e5e53b0ea230d Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 26 Feb 2011 19:33:21 +0100 Subject: use common sigthread.h NPTL build did not use the correct bits/sigthread.h, use a common version avoiding this. Signed-off-by: Peter S. Mazinger --- libpthread/nptl/sysdeps/pthread/bits/sigthread.h | 44 ------------------------ 1 file changed, 44 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/pthread/bits/sigthread.h b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h index 9a524e57d..e69de29bb 100644 --- a/libpthread/nptl/sysdeps/pthread/bits/sigthread.h +++ b/libpthread/nptl/sysdeps/pthread/bits/sigthread.h @@ -1,44 +0,0 @@ -/* Signal handling function for threaded programs. - Copyright (C) 1998, 1999, 2000, 2002, 2009 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; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -#ifndef _BITS_SIGTHREAD_H -#define _BITS_SIGTHREAD_H 1 - -#if !defined _SIGNAL_H && !defined _PTHREAD_H -# error "Never include this file directly. Use instead" -#endif - -/* Functions for handling signals. */ - -/* Modify the signal mask for the calling thread. The arguments have - the same meaning as for sigprocmask(2). */ -extern int pthread_sigmask (int __how, - __const __sigset_t *__restrict __newmask, - __sigset_t *__restrict __oldmask)__THROW; - -/* Send signal SIGNO to the given thread. */ -extern int pthread_kill (pthread_t __threadid, int __signo) __THROW; - -#ifdef __USE_GNU -/* Queue signal and data to a thread. */ -extern int pthread_sigqueue (pthread_t __threadid, int __signo, - const union sigval __value) __THROW; -#endif - -#endif /* bits/sigthread.h */ -- cgit v1.2.3 From f00e553e4b084007781df5e4b5accc2e152da231 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Sat, 26 Feb 2011 19:41:29 +0100 Subject: add missing prototypes Add some missing prototypes Signed-off-by: Peter S. Mazinger --- libpthread/nptl/init.c | 1 + libpthread/nptl/pthreadP.h | 16 ++++++++++++++-- libpthread/nptl/sysdeps/generic/libc-tls.c | 1 + libpthread/nptl/unwind.c | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c index 911293a65..c8ca09637 100644 --- a/libpthread/nptl/init.c +++ b/libpthread/nptl/init.c @@ -257,6 +257,7 @@ extern void **__libc_dl_error_tsd (void) __attribute__ ((const)); /* This can be set by the debugger before initialization is complete. */ static bool __nptl_initial_report_events __attribute_used__; +void __pthread_initialize_minimal_internal (void) attribute_hidden; void __pthread_initialize_minimal_internal (void) { diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h index fbac7d08f..fb354eaa3 100644 --- a/libpthread/nptl/pthreadP.h +++ b/libpthread/nptl/pthreadP.h @@ -179,7 +179,13 @@ extern struct pthread_key_struct __pthread_keys[PTHREAD_KEYS_MAX]; hidden_proto (__pthread_keys) /* Number of threads running. */ -extern unsigned int __nptl_nthreads attribute_hidden; +extern unsigned int __nptl_nthreads +#ifdef SHARED + attribute_hidden +#else + __attribute ((weak)) +#endif + ; #ifndef __ASSUME_SET_ROBUST_LIST /* Negative if we do not have the system call and we can use it. */ @@ -563,7 +569,13 @@ extern void _pthread_cleanup_push_defer (struct _pthread_cleanup_buffer *buffer, extern void _pthread_cleanup_pop_restore (struct _pthread_cleanup_buffer *buffer, int execute); -extern void __nptl_deallocate_tsd (void) attribute_hidden; +extern void __nptl_deallocate_tsd (void) +#ifdef SHARED + attribute_hidden +#else + __attribute ((weak)) +#endif + ; extern int __nptl_setxid (struct xid_command *cmdp) attribute_hidden; diff --git a/libpthread/nptl/sysdeps/generic/libc-tls.c b/libpthread/nptl/sysdeps/generic/libc-tls.c index c45e76120..e14fc26c6 100644 --- a/libpthread/nptl/sysdeps/generic/libc-tls.c +++ b/libpthread/nptl/sysdeps/generic/libc-tls.c @@ -242,6 +242,7 @@ _dl_tls_setup (void) return 0; } +extern void __pthread_initialize_minimal(void) __attribute__((weak)); /* This is the minimal initialization function used when libpthread is not used. */ diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c index 0322a6023..8f60ae410 100644 --- a/libpthread/nptl/unwind.c +++ b/libpthread/nptl/unwind.c @@ -117,6 +117,9 @@ unwind_cleanup (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc) void attribute_protected __cleanup_fct_attribute __attribute ((noreturn)) +#if !defined SHARED && !defined IS_IN_LIBPTHREAD +weak_function +#endif __pthread_unwind (__pthread_unwind_buf_t *buf) { struct pthread_unwind_buf *ibuf = (struct pthread_unwind_buf *) buf; -- cgit v1.2.3 From 5e22e71adfef5ad46119cea98fccf4ae998ad0d8 Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Wed, 2 Mar 2011 21:59:58 +0100 Subject: remove ucontext.h and guard sigstack structure with SUSV4_LEGACY and STRICT_HEADERS Remove ucontext.h if SUSV4_LEGACY is not set and fix it's references. Guard sigstack structure with SUSV4_LEGACY and STRICT_HEADERS. Disable sigstack function prototype, it is not provided by uClibc. Signed-off-by: Peter S. Mazinger --- libpthread/linuxthreads.old/signals.c | 1 - libpthread/linuxthreads/signals.c | 1 - 2 files changed, 2 deletions(-) (limited to 'libpthread') diff --git a/libpthread/linuxthreads.old/signals.c b/libpthread/linuxthreads.old/signals.c index 2a451f3d2..23d838eb8 100644 --- a/libpthread/linuxthreads.old/signals.c +++ b/libpthread/linuxthreads.old/signals.c @@ -20,7 +20,6 @@ #include "pthread.h" #include "internals.h" #include "spinlock.h" -#include #include /* mods for uClibc: __libc_sigaction is not in any standard headers */ diff --git a/libpthread/linuxthreads/signals.c b/libpthread/linuxthreads/signals.c index 02bf1c64b..c08125579 100644 --- a/libpthread/linuxthreads/signals.c +++ b/libpthread/linuxthreads/signals.c @@ -19,7 +19,6 @@ #include "pthread.h" #include "internals.h" #include "spinlock.h" -#include /* mods for uClibc: __libc_sigaction is not in any standard headers */ extern __typeof(sigaction) __libc_sigaction; -- cgit v1.2.3 From 37525c04e45bb37bbc1532e11b5ab821a10f3cf4 Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Fri, 4 Mar 2011 13:04:13 +0100 Subject: nptl: fix use of IS_IN_LIBPTHREAD macro IS_IN_LIBPTHREAD should be IS_IN_libpthread instead. Signed-off-by: Carmelo Amoroso --- libpthread/nptl/unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpthread') diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c index 8f60ae410..671d70208 100644 --- a/libpthread/nptl/unwind.c +++ b/libpthread/nptl/unwind.c @@ -117,7 +117,7 @@ unwind_cleanup (_Unwind_Reason_Code reason, struct _Unwind_Exception *exc) void attribute_protected __cleanup_fct_attribute __attribute ((noreturn)) -#if !defined SHARED && !defined IS_IN_LIBPTHREAD +#if !defined SHARED && !defined IS_IN_libpthread weak_function #endif __pthread_unwind (__pthread_unwind_buf_t *buf) -- cgit v1.2.3 From f4eebb6146ea3f6917481d5d24f3d99e97236399 Mon Sep 17 00:00:00 2001 From: "Bernd Schmidt bernds_cb1@t-online.de" Date: Wed, 2 Mar 2011 18:22:01 +0100 Subject: Add Makefile support for DSBT ELF. This adds support for a new binary format, DSBT ELF, to the Makefiles. Every shared library is assigned a DSBT index, and the link.so macro is adjusted to ensure the correct linker argument is passed. Configuration and ldso support will follow in separate commits. Signed-off-by: Bernd Schmidt Signed-off-by: Bernhard Reutner-Fischer --- libpthread/linuxthreads.old/Makefile.in | 1 + 1 file changed, 1 insertion(+) (limited to 'libpthread') diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in index d2e29c72d..f599b1697 100644 --- a/libpthread/linuxthreads.old/Makefile.in +++ b/libpthread/linuxthreads.old/Makefile.in @@ -18,6 +18,7 @@ LDFLAGS-libpthread.so := $(LDFLAGS_NOSTRIP) -Wl,-z,defs else LDFLAGS-libpthread.so := $(LDFLAGS) endif +LDFLAGS-$(UCLIBC_FORMAT_DSBT_ELF)-libpthread.so := -Wl,--dsbt-index=10 LIBS-libpthread.so := $(LIBS) $(ldso) -- cgit v1.2.3 From 817f685f4c65ed1af6eef79749b1f158eedd5bfc Mon Sep 17 00:00:00 2001 From: Bernd Schmidt Date: Wed, 23 Feb 2011 02:57:49 +0100 Subject: Allow ABIs where SP points below the stack frame. On C6X, the stack pointer points to a word that is not part of the current function's stack frame. It may be overwritten by callees. Take this into account when creating the stack for a cloned thread. Signed-off-by: Bernd Schmidt --- libpthread/linuxthreads.old/manager.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'libpthread') diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c index 52c1ea9b6..85fee5ec5 100644 --- a/libpthread/linuxthreads.old/manager.c +++ b/libpthread/linuxthreads.old/manager.c @@ -35,6 +35,9 @@ #include "semaphore.h" #include "debug.h" /* PDEBUG, added by StS */ +#ifndef THREAD_STACK_OFFSET +#define THREAD_STACK_OFFSET 0 +#endif /* poll() is not supported in kernel <= 2.0, therefore is __NR_poll is * not available, we assume an old Linux kernel is in use and we will @@ -476,6 +479,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, int pid; pthread_descr new_thread; char * new_thread_bottom; + char * new_thread_top; pthread_t new_thread_id; char *guardaddr = NULL; size_t guardsize = 0; @@ -561,7 +565,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, /* Do the cloning. We have to use two different functions depending on whether we are debugging or not. */ pid = 0; /* Note that the thread never can have PID zero. */ - + new_thread_top = ((char *)new_thread - THREAD_STACK_OFFSET); /* ******************************************************** */ /* This code was moved from below to cope with running threads @@ -588,12 +592,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, /* We have to report this event. */ #ifdef __ia64__ - pid = __clone2(pthread_start_thread_event, (void **) new_thread, - (char *)new_thread - new_thread_bottom, + pid = __clone2(pthread_start_thread_event, new_thread_top, + new_thread_top - new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | __pthread_sig_cancel, new_thread); #else - pid = clone(pthread_start_thread_event, (void **) new_thread, + pid = clone(pthread_start_thread_event, new_thread_top, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | __pthread_sig_cancel, new_thread); #endif @@ -626,12 +630,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, { PDEBUG("cloning new_thread = %p\n", new_thread); #ifdef __ia64__ - pid = __clone2(pthread_start_thread, (void **) new_thread, - (char *)new_thread - new_thread_bottom, + pid = __clone2(pthread_start_thread, new_thread_top, + new_thread_top - new_thread_bottom, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | __pthread_sig_cancel, new_thread); #else - pid = clone(pthread_start_thread, (void **) new_thread, + pid = clone(pthread_start_thread, new_thread_top, CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND | __pthread_sig_cancel, new_thread); #endif -- cgit v1.2.3 From 46d6a24872b7fa2717f8f71b5e0598a14d38e1f6 Mon Sep 17 00:00:00 2001 From: Aurelien Jacquiot Date: Wed, 23 Feb 2011 13:04:59 +0100 Subject: The C6X port This adds support for the TI C6X family of processors. Signed-off-by: Mark Salter Signed-off-by: Aurelien Jacquiot Signed-off-by: Bernd Schmidt --- .../linuxthreads.old/sysdeps/c6x/pt-machine.h | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h (limited to 'libpthread') diff --git a/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h new file mode 100644 index 000000000..cabd4e33c --- /dev/null +++ b/libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h @@ -0,0 +1,64 @@ +/* Machine-dependent pthreads configuration and inline functions. + C6x version. + Copyright (C) 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Aurelien Jacquiot . + + 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; see the file COPYING.LIB. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef _PT_MACHINE_H +#define _PT_MACHINE_H 1 + +#ifndef PT_EI +# define PT_EI extern inline +#endif + +extern int __compare_and_swap (long int *p, long int oldval, long int newval); + +/* Spinlock implementation; required. */ +static inline long int +testandset (int *spinlock) +{ + register unsigned int ret = 1; + int dummy; + __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tand .s2 -2, %0, %0\n\tmvc .s2 %0, CSR\n" + : "=b" (dummy)); + + if (*spinlock == 0) { + *spinlock = 1; + ret = 0; + } + __asm__ __volatile__ ("mvc .s2 CSR, %0\n\tor .s2 1, %0, %0\n\tmvc .s2 %0, CSR\n" + : "=b" (dummy)); + return ret; +} + +#define WRITE_MEMORY_BARRIER() +#define READ_MEMORY_BARRIER() + +/* Get some notion of the current stack. Need not be exactly the top + of the stack, just something somewhere in the current frame. */ +#define CURRENT_STACK_FRAME get_stack_pointer() +static inline char * get_stack_pointer(void) +{ + char *sp; + __asm__ __volatile__ ("mv .d2 B15, %0" : "=b" (sp)); + return sp; +} + +#define THREAD_STACK_OFFSET 8 + +#endif /* pt-machine.h */ -- cgit v1.2.3 From 526af41956be03b56e1bf33ec144e797256c1255 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Tue, 8 Mar 2011 02:12:11 -0600 Subject: nptl: fix compilation on x86_64 This commit gives us a fully functioning NPTL on x86-64 by using the GOTOFF macro as needed. Signed-off-by: William Pitcock Signed-off-by: Khem Raj --- libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S | 2 +- .../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S | 2 +- .../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S | 10 +--------- .../unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S | 2 +- .../unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S | 2 +- libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S | 2 +- 6 files changed, 6 insertions(+), 14 deletions(-) (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S index f87532359..e59bdda44 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S @@ -163,7 +163,7 @@ __lll_timedlock_wait: cfi_startproc # ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S index 2eb8e29fa..5cc4256a5 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S @@ -118,7 +118,7 @@ __lll_robust_timedlock_wait: cfi_startproc # ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S index 3a965ad0b..645436f99 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S @@ -98,7 +98,7 @@ __pthread_cond_timedwait: 22: #ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif @@ -437,14 +437,6 @@ __pthread_cond_timedwait: /* Only clocks 0 and 1 are allowed so far. Both are handled in the kernel. */ leaq 32(%rsp), %rsi -# ifdef SHARED - movq __vdso_clock_gettime@GOTPCREL(%rip), %rax - movq (%rax), %rax - PTR_DEMANGLE (%rax) - jz 26f - call *%rax - jmp 27f -# endif 26: movl $__NR_clock_gettime, %eax syscall 27: diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S index 3629ffbe5..15edd6149 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S @@ -96,7 +96,7 @@ pthread_rwlock_timedrdlock: 11: #ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S index 23e1ee155..3c4a27912 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S @@ -93,7 +93,7 @@ pthread_rwlock_timedwrlock: 11: #ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S index 704a2223a..3ff34120c 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S @@ -61,7 +61,7 @@ sem_timedwait: #ifndef __ASSUME_FUTEX_CLOCK_REALTIME # ifdef __PIC__ - cmpl $0, __have_futex_clock_realtime(%rip) + cmpl $0, __have_futex_clock_realtime@GOTOFF(%rip) # else cmpl $0, __have_futex_clock_realtime # endif -- cgit v1.2.3 From 1dd9275091d6cbb14d6b149770fc90cef53577cf Mon Sep 17 00:00:00 2001 From: "Peter S. Mazinger" Date: Wed, 9 Mar 2011 13:32:30 +0100 Subject: remove trailing ';' from _syscallX() Signed-off-by: Peter S. Mazinger --- libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpthread') diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c index 08710f1c8..79faf54bf 100644 --- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c +++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c @@ -2,4 +2,4 @@ #include int gettimeofday (struct timeval *, struct timezone *) attribute_hidden; -_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz); +_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz) -- cgit v1.2.3