Browse Source

Assorted fixed to get nptl compiling on ARM

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Khem Raj 14 years ago
parent
commit
94f3c30dc2

+ 6 - 0
include/libc-symbols.h

@@ -99,6 +99,12 @@
 # define attribute_noreturn
 # define attribute_noreturn
 #endif
 #endif
 
 
+#define libc_freeres_ptr(decl) \
+      __make_section_unallocated ("__libc_freeres_ptrs, \"aw\", %nobits") \
+  decl __attribute__ ((section ("__libc_freeres_ptrs" __sec_comment)))
+#define __libc_freeres_fn_section \
+      __attribute__ ((section ("__libc_freeres_fn")))
+
 #ifndef NOT_IN_libc
 #ifndef NOT_IN_libc
 # define IS_IN_libc 1
 # define IS_IN_libc 1
 #endif
 #endif

+ 5 - 0
libc/sysdeps/linux/arm/sysdep.h

@@ -359,4 +359,9 @@ __local_syscall_error:						\
 #endif
 #endif
 
 
 #endif	/* __ASSEMBLER__ */
 #endif	/* __ASSEMBLER__ */
+
+/* Pointer mangling is not yet supported for ARM.  */
+#define PTR_MANGLE(var) (void) (var)
+#define PTR_DEMANGLE(var) (void) (var)
+
 #endif /* linux/arm/sysdep.h */
 #endif /* linux/arm/sysdep.h */

+ 0 - 5
libc/sysdeps/linux/common/bits/kernel-features.h

@@ -448,8 +448,3 @@
 #if __LINUX_KERNEL_VERSION >= 0x020609 && defined __alpha__
 #if __LINUX_KERNEL_VERSION >= 0x020609 && defined __alpha__
 #define __ASSUME_IEEE_RAISE_EXCEPTION	1
 #define __ASSUME_IEEE_RAISE_EXCEPTION	1
 #endif
 #endif
-
-/* This header was added somewhere around 2.6.13  */
-#if __LINUX_KERNEL_VERSION >= 132621
-# define HAVE_LINUX_CPUMASK_H	1
-#endif

+ 51 - 10
libc/sysdeps/linux/common/not-cancel.h

@@ -1,19 +1,60 @@
-/* By default we have none.  Map the name to the normal functions.  */
+/* Uncancelable versions of cancelable interfaces.  Linux version.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   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 <sysdep.h>
+
+/* Uncancelable open.  */
 #define open_not_cancel(name, flags, mode) \
 #define open_not_cancel(name, flags, mode) \
-  open (name, flags, mode)
+   INLINE_SYSCALL (open, 3, (const char *) (name), (flags), (mode))
 #define open_not_cancel_2(name, flags) \
 #define open_not_cancel_2(name, flags) \
-  open (name, flags)
+   INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
+
+/* Uncancelable close.  */
 #define close_not_cancel(fd) \
 #define close_not_cancel(fd) \
-  close (fd)
+  INLINE_SYSCALL (close, 1, fd)
 #define close_not_cancel_no_status(fd) \
 #define close_not_cancel_no_status(fd) \
-  (void) close (fd)
+  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
+	    INTERNAL_SYSCALL (close, err, 1, (fd)); })
+
+/* Uncancelable read.  */
 #define read_not_cancel(fd, buf, n) \
 #define read_not_cancel(fd, buf, n) \
-  read (fd, buf, n)
+  INLINE_SYSCALL (read, 3, (fd), (buf), (n))
+
+/* Uncancelable write.  */
 #define write_not_cancel(fd, buf, n) \
 #define write_not_cancel(fd, buf, n) \
-  write (fd, buf, n)
+  INLINE_SYSCALL (write, 3, (fd), (buf), (n))
+
+/* Uncancelable writev.  */
 #define writev_not_cancel_no_status(fd, iov, n) \
 #define writev_not_cancel_no_status(fd, iov, n) \
-  (void) writev (fd, iov, n)
+  (void) ({ INTERNAL_SYSCALL_DECL (err);				      \
+	    INTERNAL_SYSCALL (writev, err, 3, (fd), (iov), (n)); })
+
+/* Uncancelable fcntl.  */
 #define fcntl_not_cancel(fd, cmd, val) \
 #define fcntl_not_cancel(fd, cmd, val) \
-  fcntl (fd, cmd, val)
+  __fcntl_nocancel (fd, cmd, val)
+
+/* Uncancelable waitpid.  */
+#ifdef __NR_waitpid
 # define waitpid_not_cancel(pid, stat_loc, options) \
 # define waitpid_not_cancel(pid, stat_loc, options) \
-  waitpid (pid, stat_loc, options)
+  INLINE_SYSCALL (waitpid, 3, pid, stat_loc, options)
+#else
+# define waitpid_not_cancel(pid, stat_loc, options) \
+  INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
+#endif

+ 0 - 3
libc/unistd/sysconf.c

@@ -38,9 +38,6 @@
 #include <sysdep.h>
 #include <sysdep.h>
 #endif
 #endif
 
 
-#ifdef HAVE_LINUX_CPUMASK_H
-# include <linux/cpumask.h>
-#endif
 #ifndef num_present_cpus
 #ifndef num_present_cpus
 # define num_present_cpus() (1)
 # define num_present_cpus() (1)
 #endif
 #endif

+ 1 - 0
libpthread/nptl/descr.h

@@ -37,6 +37,7 @@
 #define __need_res_state
 #define __need_res_state
 #include <resolv.h>
 #include <resolv.h>
 #include <bits/kernel-features.h>
 #include <bits/kernel-features.h>
+#include "uClibc-glue.h"
 
 
 #ifndef TCB_ALIGNMENT
 #ifndef TCB_ALIGNMENT
 # define TCB_ALIGNMENT	sizeof (double)
 # define TCB_ALIGNMENT	sizeof (double)

+ 0 - 8
libpthread/nptl/init.c

@@ -410,14 +410,6 @@ __pthread_initialize_minimal_internal (void)
   *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
   *__libc_dl_error_tsd () = *(*GL(dl_error_catch_tsd)) ();
   GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
   GL(dl_error_catch_tsd) = &__libc_dl_error_tsd;
 
 
-  /* Make __rtld_lock_{,un}lock_recursive use pthread_mutex_{,un}lock,
-     keep the lock count from the ld.so implementation.  */
-  GL(dl_rtld_lock_recursive) = (void *) INTUSE (__pthread_mutex_lock);
-  GL(dl_rtld_unlock_recursive) = (void *) INTUSE (__pthread_mutex_unlock);
-  unsigned int rtld_lock_count = GL(dl_load_lock).mutex.__data.__count;
-  GL(dl_load_lock).mutex.__data.__count = 0;
-  while (rtld_lock_count-- > 0)
-    INTUSE (__pthread_mutex_lock) (&GL(dl_load_lock).mutex);
 #endif
 #endif
 
 
   GL(dl_init_static_tls) = &__pthread_init_static_tls;
   GL(dl_init_static_tls) = &__pthread_init_static_tls;

+ 2 - 1
libpthread/nptl/pthread_create.c

@@ -302,8 +302,9 @@ start_thread (void *arg)
   __nptl_deallocate_tsd ();
   __nptl_deallocate_tsd ();
 
 
   /* Clean up any state libc stored in thread-local variables.  */
   /* Clean up any state libc stored in thread-local variables.  */
+  /* disable for now
   __libc_thread_freeres ();
   __libc_thread_freeres ();
-
+  */
   /* If this is the last thread we terminate the process now.  We
   /* If this is the last thread we terminate the process now.  We
      do not notify the debugger, it might just irritate it if there
      do not notify the debugger, it might just irritate it if there
      is no thread left.  */
      is no thread left.  */

+ 1 - 1
libpthread/nptl/pthread_getattr_np.c

@@ -98,7 +98,7 @@ pthread_getattr_np (
 
 
 	      while (! feof_unlocked (fp))
 	      while (! feof_unlocked (fp))
 		{
 		{
-		  if (__getdelim (&line, &linelen, '\n', fp) <= 0)
+		  if (getdelim (&line, &linelen, '\n', fp) <= 0)
 		    break;
 		    break;
 
 
 		  uintptr_t from;
 		  uintptr_t from;

+ 24 - 4
libpthread/nptl/sysdeps/arm/tls.h

@@ -1,5 +1,5 @@
 /* Definition for thread-local data handling.  NPTL/ARM version.
 /* Definition for thread-local data handling.  NPTL/ARM version.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005,2007 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    This file is part of the GNU C Library.
 
 
    The GNU C Library is free software; you can redistribute it and/or
    The GNU C Library is free software; you can redistribute it and/or
@@ -50,9 +50,6 @@ typedef union dtv
 /* Signal that TLS support is available.  */
 /* Signal that TLS support is available.  */
 #define USE_TLS	1
 #define USE_TLS	1
 
 
-/* Like all other modern NPTL ports, ARM uses forced unwinding.  */
-#define HAVE_FORCED_UNWIND
-
 #ifndef __ASSEMBLER__
 #ifndef __ASSEMBLER__
 
 
 /* Get system call information.  */
 /* Get system call information.  */
@@ -134,6 +131,29 @@ typedef struct
    is not available.  */
    is not available.  */
 #define TLS_INIT_TP_EXPENSIVE 1
 #define TLS_INIT_TP_EXPENSIVE 1
 
 
+/* Get and set the global scope generation counter in struct pthread.  */
+#define THREAD_GSCOPE_FLAG_UNUSED 0
+#define THREAD_GSCOPE_FLAG_USED   1
+#define THREAD_GSCOPE_FLAG_WAIT   2
+#define THREAD_GSCOPE_RESET_FLAG() \
+  do									     \
+    { int __res								     \
+	= atomic_exchange_rel (&THREAD_SELF->header.gscope_flag,	     \
+			       THREAD_GSCOPE_FLAG_UNUSED);		     \
+      if (__res == THREAD_GSCOPE_FLAG_WAIT)				     \
+	lll_futex_wake (&THREAD_SELF->header.gscope_flag, 1, LLL_PRIVATE);   \
+    }									     \
+  while (0)
+#define THREAD_GSCOPE_SET_FLAG() \
+  do									     \
+    {									     \
+      THREAD_SELF->header.gscope_flag = THREAD_GSCOPE_FLAG_USED;	     \
+      atomic_write_barrier ();						     \
+    }									     \
+  while (0)
+#define THREAD_GSCOPE_WAIT() \
+  GL(dl_wait_lookup_done) ()
+
 #endif /* __ASSEMBLER__ */
 #endif /* __ASSEMBLER__ */
 
 
 #endif	/* tls.h */
 #endif	/* tls.h */

+ 1 - 1
libpthread/nptl/sysdeps/pthread/Makefile.in

@@ -63,7 +63,6 @@ endif
 
 
 
 
 CFLAGS-pt-common = -DNOT_IN_libc=1 $(SSP_ALL_CFLAGS)
 CFLAGS-pt-common = -DNOT_IN_libc=1 $(SSP_ALL_CFLAGS)
-
 CFLAGS-pthread_barrier_wait.c = -D_GNU_SOURCE $(CFLAGS-pt-common)	\
 CFLAGS-pthread_barrier_wait.c = -D_GNU_SOURCE $(CFLAGS-pt-common)	\
 				-DIS_IN_libpthread=1
 				-DIS_IN_libpthread=1
 CFLAGS-pthread_cond_broadcast.c = $(CFLAGS-pt-common) -DIS_IN_libpthread=1
 CFLAGS-pthread_cond_broadcast.c = $(CFLAGS-pt-common) -DIS_IN_libpthread=1
@@ -94,6 +93,7 @@ CFLAGS-librt-cancellation.c = -DIS_IN_librt=1 $(CFLAGS-pt-common)	\
 			      -fexceptions -fasynchronous-unwind-tables
 			      -fexceptions -fasynchronous-unwind-tables
 CFLAGS-rt-unwind-resume.c = -DIS_IN_librt=1 $(CFLAGS-pt-common)		\
 CFLAGS-rt-unwind-resume.c = -DIS_IN_librt=1 $(CFLAGS-pt-common)		\
 			    -fexceptions -fasynchronous-unwind-tables
 			    -fexceptions -fasynchronous-unwind-tables
+CFLAGS-tpp.c = $(CFLAGS-pt-common) -DIS_IN_libpthread=1
 
 
 #CFLAGS:=$(CFLAGS:-O1=-O2)
 #CFLAGS:=$(CFLAGS:-O1=-O2)
 
 

+ 6 - 2
libpthread/nptl/sysdeps/pthread/bits/libc-lock.h

@@ -61,6 +61,10 @@ typedef struct __libc_rwlock_opaque__ __libc_rwlock_t;
 /* Type for key to thread-specific data.  */
 /* Type for key to thread-specific data.  */
 typedef pthread_key_t __libc_key_t;
 typedef pthread_key_t __libc_key_t;
 
 
+# define __libc_freeres_fn_section \
+      __attribute__ ((section ("__libc_freeres_fn")))
+
+
 /* Define a lock variable NAME with storage class CLASS.  The lock must be
 /* Define a lock variable NAME with storage class CLASS.  The lock must be
    initialized with __libc_lock_init before it can be used (or define it
    initialized with __libc_lock_init before it can be used (or define it
    with __libc_lock_define_initialized, below).  Use `extern' for CLASS to
    with __libc_lock_define_initialized, below).  Use `extern' for CLASS to
@@ -545,7 +549,7 @@ weak_extern (__pthread_key_create)
 weak_extern (__pthread_setspecific)
 weak_extern (__pthread_setspecific)
 weak_extern (__pthread_getspecific)
 weak_extern (__pthread_getspecific)
 weak_extern (__pthread_once)
 weak_extern (__pthread_once)
-weak_extern (__pthread_initialize)
+//weak_extern (__pthread_initialize)
 weak_extern (__pthread_atfork)
 weak_extern (__pthread_atfork)
 #ifdef SHARED
 #ifdef SHARED
 weak_extern (_pthread_cleanup_push_defer)
 weak_extern (_pthread_cleanup_push_defer)
@@ -571,7 +575,7 @@ weak_extern (pthread_setcancelstate)
 #  pragma weak __pthread_setspecific
 #  pragma weak __pthread_setspecific
 #  pragma weak __pthread_getspecific
 #  pragma weak __pthread_getspecific
 #  pragma weak __pthread_once
 #  pragma weak __pthread_once
-#  pragma weak __pthread_initialize
+//#  pragma weak __pthread_initialize
 #  pragma weak __pthread_atfork
 #  pragma weak __pthread_atfork
 #  pragma weak _pthread_cleanup_push_defer
 #  pragma weak _pthread_cleanup_push_defer
 #  pragma weak _pthread_cleanup_pop_restore
 #  pragma weak _pthread_cleanup_pop_restore

+ 1 - 1
libpthread/nptl/sysdeps/pthread/tpp.c

@@ -24,7 +24,7 @@
 #include <pthreadP.h>
 #include <pthreadP.h>
 #include <sched.h>
 #include <sched.h>
 #include <stdlib.h>
 #include <stdlib.h>
-
+#include "uClibc-glue.h"
 
 
 int __sched_fifo_min_prio = -1;
 int __sched_fifo_min_prio = -1;
 int __sched_fifo_max_prio = -1;
 int __sched_fifo_max_prio = -1;

+ 47 - 0
libpthread/nptl/sysdeps/pthread/uClibc-glue.h

@@ -0,0 +1,47 @@
+#ifndef _UCLIBC_GLUE_H
+#define _UCLIBC_GLUE_H 1
+
+#include <features.h>
+#include <sys/cdefs.h>
+#include <bits/uClibc_page.h>
+
+#ifdef IS_IN_libpthread
+#include <bits/kernel-features.h>
+
+#ifndef __GLIBC_HAVE_LONG_LONG
+# define __GLIBC_HAVE_LONG_LONG
+#endif
+
+#define __getpagesize getpagesize
+#define __sched_get_priority_max sched_get_priority_max
+#define __sched_get_priority_min sched_get_priority_min
+#define __sched_getscheduler sched_getscheduler
+#define __sched_setscheduler sched_setscheduler
+#define __sched_getparam sched_getparam
+#define __getpid getpid
+#define __gettimeofday gettimeofday
+#define __poll poll
+#define __sysctl sysctl
+#define __open open
+#define __read read
+#define __close close
+#define __on_exit on_exit
+#define __libc_current_sigrtmin_private __libc_current_sigrtmin
+#define __clone clone
+
+extern void *__libc_stack_end;
+extern int __cxa_atexit (void (*func) (void *), void *arg, void *d);
+
+#endif /* IS_IN_libpthread */
+
+#ifdef __UCLIBC_HAS_XLOCALE__
+# define __uselocale(x) uselocale(x)
+#else
+# define __uselocale(x) ((void)0)
+#endif
+
+/* Use a funky version in a probably vein attempt at preventing gdb
+ * from dlopen()'ing glibc's libthread_db library... */
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
+
+#endif

+ 4 - 0
libpthread/nptl/sysdeps/pthread/unwind-forcedunwind.c

@@ -24,6 +24,10 @@
 #include <sysdep.h>
 #include <sysdep.h>
 #include <libgcc_s.h>
 #include <libgcc_s.h>
 
 
+#define __libc_dlopen(x)        dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym            dlsym
+#define __libc_dlclose		dlclose
+
 static void *libgcc_s_handle;
 static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
 static _Unwind_Reason_Code (*libgcc_s_personality)

+ 4 - 0
libpthread/nptl/sysdeps/pthread/unwind-resume.c

@@ -23,6 +23,10 @@
 #include <unwind.h>
 #include <unwind.h>
 #include <libgcc_s.h>
 #include <libgcc_s.h>
 
 
+#define __libc_dlopen(x)        dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym            dlsym
+#define __libc_dlclose          dlclose
+
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
 static _Unwind_Reason_Code (*libgcc_s_personality)
   (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,
   (int, _Unwind_Action, _Unwind_Exception_Class, struct _Unwind_Exception *,

+ 47 - 39
libpthread/nptl/sysdeps/unix/sysv/linux/Makefile.in

@@ -5,14 +5,15 @@
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 #
 #
 
 
-libpthread_CSRC = pthread_attr_getaffinity.c			\
+libpthread_CSRC = pthread_attr_getaffinity.c				\
 		  pthread_attr_setaffinity.c pthread_getaffinity.c	\
 		  pthread_attr_setaffinity.c pthread_getaffinity.c	\
 		  pthread_getcpuclockid.c pthread_kill.c		\
 		  pthread_getcpuclockid.c pthread_kill.c		\
 		  pthread_mutex_cond_lock.c pthread_setaffinity.c	\
 		  pthread_mutex_cond_lock.c pthread_setaffinity.c	\
 		  pthread_yield.c sem_post.c sem_timedwait.c		\
 		  pthread_yield.c sem_post.c sem_timedwait.c		\
-		  pthread_sigqueue.c \
+		  pthread_sigqueue.c 					\
 		  sem_trywait.c sem_wait.c pt-fork.c			\
 		  sem_trywait.c sem_wait.c pt-fork.c			\
-		  sigtimedwait.c sigwaitinfo.c sigwait.c pt-sleep.c
+		  sigtimedwait.c sigwaitinfo.c sigwait.c pt-sleep.c	\
+		  lowlevelrobustlock.c
 
 
 libpthread_SSRC = #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
 libpthread_SSRC = #ptw-close.S ptw-open.S ptw-waitid.S ptw-waidpid.S ptw-write.S
 
 
@@ -146,77 +147,77 @@ headers_clean-y += nptl_linux_headers_clean
 #
 #
 # Create header files.
 # Create header files.
 #
 #
-CFLAGS-lowlevelbarrier.c = -S
-CFLAGS-lowlevelcond.c = -S
-CFLAGS-lowlevelrwlock.c = -S
-CFLAGS-lowlevelrobustlock.c = -S
-CFLAGS-unwindbuf.c = -S
-CFLAGS-structsem.c = -S
-CFLAGS-pthread-pi-defines.c = -S
-
-$(PTHREAD_LINUX_OUT)/lowlevelbarrier.c: $(PTHREAD_LINUX_DIR)/lowlevelbarrier.sym
+CFLAGS-gen_lowlevelbarrier.c = -S
+CFLAGS-gen_llowlevelcond.c = -S
+CFLAGS-gen_llowlevelrwlock.c = -S
+CFLAGS-gen_llowlevelrobustlock.c = -S
+CFLAGS-gen_lunwindbuf.c = -S
+CFLAGS-gen_lstructsem.c = -S
+CFLAGS-gen_lpthread-pi-defines.c = -S
+
+$(PTHREAD_LINUX_OUT)/gen_llowlevelbarrier.c: $(PTHREAD_LINUX_DIR)/lowlevelbarrier.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelcond.c: $(PTHREAD_LINUX_DIR)/lowlevelcond.sym
+$(PTHREAD_LINUX_OUT)/gen_llowlevelcond.c: $(PTHREAD_LINUX_DIR)/lowlevelcond.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrwlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrwlock.sym
+$(PTHREAD_LINUX_OUT)/gen_llowlevelrwlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrwlock.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrobustlock.sym
+$(PTHREAD_LINUX_OUT)/gen_llowlevelrobustlock.c: $(PTHREAD_LINUX_DIR)/lowlevelrobustlock.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/unwindbuf.c: $(PTHREAD_LINUX_DIR)/unwindbuf.sym
+$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c: $(PTHREAD_LINUX_DIR)/unwindbuf.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/structsem.c: $(PTHREAD_LINUX_DIR)/structsem.sym
+$(PTHREAD_LINUX_OUT)/gen_lstructsem.c: $(PTHREAD_LINUX_DIR)/structsem.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/pthread-pi-defines.c: $(PTHREAD_LINUX_DIR)/pthread-pi-defines.sym
+$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c: $(PTHREAD_LINUX_DIR)/pthread-pi-defines.sym
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 	$(do_awk) $(top_srcdir)extra/scripts/gen-as-const.awk $< > $@
 
 
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelbarrier.s: $(PTHREAD_LINUX_OUT)/lowlevelbarrier.c
+$(PTHREAD_LINUX_OUT)/gen_llowlevelbarrier.s: $(PTHREAD_LINUX_OUT)/gen_llowlevelbarrier.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelcond.s: $(PTHREAD_LINUX_OUT)/lowlevelcond.c
+$(PTHREAD_LINUX_OUT)/gen_llowlevelcond.s: $(PTHREAD_LINUX_OUT)/gen_llowlevelcond.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrwlock.s: $(PTHREAD_LINUX_OUT)/lowlevelrwlock.c
+$(PTHREAD_LINUX_OUT)/gen_llowlevelrwlock.s: $(PTHREAD_LINUX_OUT)/gen_llowlevelrwlock.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.s: $(PTHREAD_LINUX_OUT)/lowlevelrobustlock.c
+$(PTHREAD_LINUX_OUT)/gen_llowlevelrobustlock.s: $(PTHREAD_LINUX_OUT)/gen_llowlevelrobustlock.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/unwindbuf.s: $(PTHREAD_LINUX_OUT)/unwindbuf.c
+$(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/structsem.s: $(PTHREAD_LINUX_OUT)/structsem.c
+$(PTHREAD_LINUX_OUT)/gen_lstructsem.s: $(PTHREAD_LINUX_OUT)/gen_lstructsem.c
 	$(compile.c)
 	$(compile.c)
 
 
-$(PTHREAD_LINUX_OUT)/pthread-pi-defines.s: $(PTHREAD_LINUX_OUT)/pthread-pi-defines.c
+$(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.c
 	$(compile.c)
 	$(compile.c)
 
 
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h: $(PTHREAD_LINUX_OUT)/lowlevelbarrier.s
+$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h: $(PTHREAD_LINUX_OUT)/gen_llowlevelbarrier.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelcond.h: $(PTHREAD_LINUX_OUT)/lowlevelcond.s
+$(PTHREAD_LINUX_OUT)/lowlevelcond.h: $(PTHREAD_LINUX_OUT)/gen_llowlevelcond.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h: $(PTHREAD_LINUX_OUT)/lowlevelrwlock.s
+$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h: $(PTHREAD_LINUX_OUT)/gen_llowlevelrwlock.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h: $(PTHREAD_LINUX_OUT)/lowlevelrobustlock.s
+$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h: $(PTHREAD_LINUX_OUT)/gen_llowlevelrobustlock.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/unwindbuf.h: $(PTHREAD_LINUX_OUT)/unwindbuf.s
+$(PTHREAD_LINUX_OUT)/unwindbuf.h: $(PTHREAD_LINUX_OUT)/gen_lunwindbuf.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/structsem.h: $(PTHREAD_LINUX_OUT)/structsem.s
+$(PTHREAD_LINUX_OUT)/structsem.h: $(PTHREAD_LINUX_OUT)/gen_lstructsem.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
-$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h: $(PTHREAD_LINUX_OUT)/pthread-pi-defines.s
+$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h: $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines.s
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 	$(do_sed) -n "s/^.*@@@name@@@\([^@]*\)@@@value@@@[^0-9Xxa-fA-F-]*\([0-9Xxa-fA-F-][0-9Xxa-fA-F-]*\).*@@@end@@@.*$\/#define \1 \2/p" $< > $@
 
 
 nptl_linux_headers: $(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
 nptl_linux_headers: $(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
@@ -234,13 +235,20 @@ $(ALL_HEADERS_BITS_PTHREAD):
 	$(do_ln) ../../$(PTHREAD_LINUX_DIR)/bits/$(@F) $(top_builddir)$@
 	$(do_ln) ../../$(PTHREAD_LINUX_DIR)/bits/$(@F) $(top_builddir)$@
 
 
 nptl_linux_headers_clean:
 nptl_linux_headers_clean:
-	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/lowlevelbarrier., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/lowlevelcond., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/lowlevelrwlock., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/lowlevelrobustlock., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/unwindbuf., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/structsem., c h s) \
-	$(addprefix $(PTHREAD_LINUX_OUT)/pthread-pi-defines., c h s)
+	$(do_rm) $(addprefix $(PTHREAD_LINUX_OUT)/gen_llowlevelbarrier., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lowlevelcond., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_llowlevelrwlock., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_llowlevelrobustlock., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lunwindbuf., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lstructsem., c s) \
+	$(addprefix $(PTHREAD_LINUX_OUT)/gen_lpthread-pi-defines., c s) \
+	$(PTHREAD_LINUX_OUT)/lowlevelbarrier.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelcond.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelrwlock.h \
+	$(PTHREAD_LINUX_OUT)/lowlevelrobustlock.h \
+	$(PTHREAD_LINUX_OUT)/unwindbuf.h \
+	$(PTHREAD_LINUX_OUT)/structsem.h \
+	$(PTHREAD_LINUX_OUT)/pthread-pi-defines.h
 
 
 
 
 nptl_linux_clean:
 nptl_linux_clean:

+ 1 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch

@@ -9,7 +9,7 @@ libpthread_SSRC = pt-vfork.S
 libpthread_CSRC = pthread_once.c lowlevellock.c \
 libpthread_CSRC = pthread_once.c lowlevellock.c \
                   pt-__syscall_rt_sigaction.c pt-__syscall_error.c
                   pt-__syscall_rt_sigaction.c pt-__syscall_error.c
 
 
-libc_a_CSRC = fork.c
+libc_a_CSRC = fork.c lowlevellock.c
 libc_a_SSRC = clone.S vfork.S
 libc_a_SSRC = clone.S vfork.S
 
 
 ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)
 ifeq ($(UCLIBC_HAS_STDIO_FUTEXES),y)

+ 1 - 0
libpthread/nptl/sysdeps/unix/sysv/linux/arm/lowlevellock.c

@@ -21,6 +21,7 @@
 #include <sysdep.h>
 #include <sysdep.h>
 #include <lowlevellock.h>
 #include <lowlevellock.h>
 #include <sys/time.h>
 #include <sys/time.h>
+#include <tls.h>
 
 
 void
 void
 __lll_lock_wait_private (int *futex)
 __lll_lock_wait_private (int *futex)

+ 4 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-forcedunwind.c

@@ -21,6 +21,9 @@
 #include <stdio.h>
 #include <stdio.h>
 #include <unwind.h>
 #include <unwind.h>
 #include <pthreadP.h>
 #include <pthreadP.h>
+#define __libc_dlopen(x)        dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym            dlsym
+#define __libc_dlclose          dlclose
 
 
 static void *libgcc_s_handle;
 static void *libgcc_s_handle;
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
@@ -59,7 +62,7 @@ pthread_cancel_init (void)
 	 == NULL
 	 == NULL
       || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
       || (getcfa = __libc_dlsym (handle, "_Unwind_GetCFA")) == NULL
       )
       )
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+      fprintf(stderr, "libgcc_s.so.1 must be installed for pthread_cancel to work\n");
 
 
   libgcc_s_resume = resume;
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
   libgcc_s_personality = personality;

+ 4 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/arm/unwind-resume.c

@@ -20,6 +20,9 @@
 #include <dlfcn.h>
 #include <dlfcn.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <unwind.h>
 #include <unwind.h>
+#define __libc_dlopen(x)        dlopen(x, (RTLD_LOCAL | RTLD_LAZY))
+#define __libc_dlsym            dlsym
+#define __libc_dlclose		dlclose
 
 
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static void (*libgcc_s_resume) (struct _Unwind_Exception *exc);
 static _Unwind_Reason_Code (*libgcc_s_personality)
 static _Unwind_Reason_Code (*libgcc_s_personality)
@@ -42,7 +45,7 @@ init (void)
       || (sjlj_unregister = __libc_dlsym (handle, "_Unwind_SjLj_Unregister")) == NULL
       || (sjlj_unregister = __libc_dlsym (handle, "_Unwind_SjLj_Unregister")) == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_SjLj_Resume")) == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_SjLj_Resume")) == NULL
       || (personality = __libc_dlsym (handle, "__gcc_personality_sj0")) == NULL)
       || (personality = __libc_dlsym (handle, "__gcc_personality_sj0")) == NULL)
-    __libc_fatal ("libgcc_s.so.1 must be installed for pthread_cancel to work\n");
+      fprintf(stderr, "libgcc_s.so.1 must be installed for pthread_cancel to work\n");
 
 
   libgcc_s_resume = resume;
   libgcc_s_resume = resume;
   libgcc_s_personality = personality;
   libgcc_s_personality = personality;

+ 1 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/internaltypes.h

@@ -21,7 +21,7 @@
 #define _INTERNALTYPES_H	1
 #define _INTERNALTYPES_H	1
 
 
 #include <stdint.h>
 #include <stdint.h>
-
+#include <sched.h>
 
 
 struct pthread_attr
 struct pthread_attr
 {
 {

+ 46 - 1
libpthread/nptl/sysdeps/unix/sysv/linux/not-cancel.h

@@ -1,5 +1,5 @@
 /* Uncancelable versions of cancelable interfaces.  Linux version.
 /* Uncancelable versions of cancelable interfaces.  Linux version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
 
@@ -18,6 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
    02111-1307 USA.  */
 
 
+#include <sys/types.h>
 #include <sysdep.h>
 #include <sysdep.h>
 
 
 /* Uncancelable open.  */
 /* Uncancelable open.  */
@@ -26,6 +27,28 @@
 #define open_not_cancel_2(name, flags) \
 #define open_not_cancel_2(name, flags) \
    INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
    INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
 
 
+/* Uncancelable openat.  */
+#if !defined NOT_IN_libc || defined IS_IN_libpthread || defined IS_IN_librt
+extern int __openat_nocancel (int fd, const char *fname, int oflag,
+			      mode_t mode) attribute_hidden;
+extern int __openat64_nocancel (int fd, const char *fname, int oflag,
+				mode_t mode) attribute_hidden;
+#else
+# define __openat_nocancel(fd, fname, oflag, mode) \
+  openat (fd, fname, oflag, mode)
+# define __openat64_nocancel(fd, fname, oflag, mode) \
+  openat64 (fd, fname, oflag, mode)
+#endif
+
+#define openat_not_cancel(fd, fname, oflag, mode) \
+  __openat_nocancel (fd, fname, oflag, mode)
+#define openat_not_cancel_3(fd, fname, oflag) \
+  __openat_nocancel (fd, fname, oflag, 0)
+#define openat64_not_cancel(fd, fname, oflag, mode) \
+  __openat64_nocancel (fd, fname, oflag, mode)
+#define openat64_not_cancel_3(fd, fname, oflag) \
+  __openat64_nocancel (fd, fname, oflag, 0)
+
 /* Uncancelable close.  */
 /* Uncancelable close.  */
 #define close_not_cancel(fd) \
 #define close_not_cancel(fd) \
   INLINE_SYSCALL (close, 1, fd)
   INLINE_SYSCALL (close, 1, fd)
@@ -58,3 +81,25 @@
 # define waitpid_not_cancel(pid, stat_loc, options) \
 # define waitpid_not_cancel(pid, stat_loc, options) \
   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
   INLINE_SYSCALL (wait4, 4, pid, stat_loc, options, NULL)
 #endif
 #endif
+
+/* Uncancelable pause.  */
+#ifdef __NR_pause
+# define pause_not_cancel() \
+  INLINE_SYSCALL (pause, 0)
+#else
+# define pause_not_cancel() \
+  __pause_nocancel ()
+#endif
+
+/* Uncancelable nanosleep.  */
+#ifdef __NR_nanosleep
+# define nanosleep_not_cancel(requested_time, remaining) \
+  INLINE_SYSCALL (nanosleep, 2, requested_time, remaining)
+#else
+# define nanosleep_not_cancel(requested_time, remaining) \
+  __nanosleep_nocancel (requested_time, remaining)
+#endif
+
+/* Uncancelable sigsuspend.  */
+#define sigsuspend_not_cancel(set) \
+  __sigsuspend_nocancel (set)

+ 1 - 0
libpthread/nptl/sysdeps/unix/sysv/linux/sem_post.c

@@ -23,6 +23,7 @@
 #include <lowlevellock.h>
 #include <lowlevellock.h>
 #include <internaltypes.h>
 #include <internaltypes.h>
 #include <semaphore.h>
 #include <semaphore.h>
+#include <tls.h>
 
 
 int
 int
 __new_sem_post (sem_t *sem)
 __new_sem_post (sem_t *sem)