summaryrefslogtreecommitdiff
path: root/libpthread
diff options
context:
space:
mode:
Diffstat (limited to 'libpthread')
-rw-r--r--libpthread/linuxthreads.old/Makefile.in1
-rw-r--r--libpthread/linuxthreads.old/internals.h24
-rw-r--r--libpthread/linuxthreads.old/manager.c18
-rw-r--r--libpthread/linuxthreads.old/pthread.c23
-rw-r--r--libpthread/linuxthreads.old/signals.c1
-rw-r--r--libpthread/linuxthreads.old/sysdeps/c6x/pt-machine.h64
-rw-r--r--libpthread/linuxthreads/cancel.c2
-rw-r--r--libpthread/linuxthreads/manager.c10
-rw-r--r--libpthread/linuxthreads/ptcleanup.c4
-rw-r--r--libpthread/linuxthreads/pthread.c4
-rw-r--r--libpthread/linuxthreads/signals.c1
-rw-r--r--libpthread/nptl/allocatestack.c24
-rw-r--r--libpthread/nptl/init.c1
-rw-r--r--libpthread/nptl/pt-cleanup.c4
-rw-r--r--libpthread/nptl/pthreadP.h16
-rw-r--r--libpthread/nptl/sysdeps/generic/dl-tls.c2
-rw-r--r--libpthread/nptl/sysdeps/generic/libc-tls.c2
-rw-r--r--libpthread/nptl/sysdeps/pthread/bits/sigthread.h44
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/bits/atomic.h122
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/pt-gettimeofday.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/sysdep-cancel.h2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/jmp-unwind.c1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S10
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S2
-rw-r--r--libpthread/nptl/unwind.c5
30 files changed, 163 insertions, 236 deletions
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)
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/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
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);
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 <ucontext.h>
#include <bits/sigcontextinfo.h>
/* mods for uClibc: __libc_sigaction is not in any standard headers */
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 <aurelien.jacquiot@jaluna.com>.
+
+ 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 */
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/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 <ucontext.h>
/* mods for uClibc: __libc_sigaction is not in any standard headers */
extern __typeof(sigaction) __libc_sigaction;
diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c
index 1c549cee1..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
@@ -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
@@ -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);
@@ -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/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/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/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/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..e14fc26c6 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)
{
@@ -241,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/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 <pthread.h> 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 */
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 <stdint.h>
-#include <sysdep.h>
-
-
-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; })
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 <sys/time.h>
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)
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"
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)
{
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
diff --git a/libpthread/nptl/unwind.c b/libpthread/nptl/unwind.c
index c7e01e764..671d70208 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
@@ -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;