diff options
Diffstat (limited to 'libpthread')
27 files changed, 305 insertions, 188 deletions
diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in index 47a4f8d98..249e2f6cb 100644 --- a/libpthread/linuxthreads.old/Makefile.in +++ b/libpthread/linuxthreads.old/Makefile.in @@ -1,12 +1,12 @@ # Makefile for uClibc # # Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org> -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # -CFLAGS-linuxthreads.old := -DNOT_IN_libc $(SSP_ALL_CFLAGS) +CFLAGS-linuxthreads.old := -DNOT_IN_libc -DIS_IN_libpthread $(SSP_ALL_CFLAGS) CFLAGS-libpthread/linuxthreads.old/sysdeps/$(TARGET_ARCH)/ := $(CFLAGS-linuxthreads.old) @@ -21,7 +21,7 @@ else LDFLAGS-libpthread.so := $(LDFLAGS) endif -LIBS-libpthread.so := $(LIBS) +LIBS-libpthread.so := $(LIBS) $(ldso) START_FILE-libpthread.so := $(SHARED_START_FILES) END_FILE-libpthread.so := $(SHARED_END_FILES) @@ -40,12 +40,9 @@ libpthread_SRC := \ ifeq ($(UCLIBC_HAS_XLOCALE),y) libpthread_SRC += locale.c endif -ifneq ($(DOMULTI),n) -libpthread_NO_MULTI := manager.c pt-machine.c -libpthread_SRC := $(filter-out $(libpthread_NO_MULTI),$(libpthread_SRC)) -endif libpthread_SPEC_SRC := pthread.c +libpthread_SPEC_SRC := $(patsubst %.c,$(libpthread_DIR)/%.c,$(libpthread_SPEC_SRC)) # remove generic sources, if arch specific version is present ifneq ($(strip $(libpthread_ARCH_SRC)),) @@ -63,10 +60,11 @@ CFLAGS-forward.c := -DIS_IN_libc CFLAGS-libc_pthread_init.c := -DIS_IN_libc libpthread_libc_CSRC := forward.c libc_pthread_init.c libpthread_libc_OBJ := $(patsubst %.c, $(libpthread_OUT)/%.o,$(libpthread_libc_CSRC)) +libc-static-y += $(libpthread_OUT)/libc_pthread_init.o libc-shared-y += $(libpthread_libc_OBJ:.o=.oS) -libpthread-static-y += $(patsubst %.c,$(libpthread_OUT)/%.o,$(libpthread_SPEC_SRC)) -libpthread-shared-y += $(patsubst %.c,$(libpthread_OUT)/%.oS,$(libpthread_SPEC_SRC)) +libpthread-static-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.o,$(libpthread_SPEC_SRC)) +libpthread-shared-y += $(patsubst $(libpthread_DIR)/%.c,$(libpthread_OUT)/%.oS,$(libpthread_SPEC_SRC)) ifeq ($(DOPIC),y) libpthread-a-y += $(libpthread_OBJ:.o=.os) $(libpthread-static-y:.o=.os) @@ -75,17 +73,19 @@ libpthread-a-y += $(libpthread_OBJ) $(libpthread-static-y) endif libpthread-so-y += $(libpthread_OBJ:.o=.os) $(libpthread-shared-y) -libpthread-multi-y += $(libpthread_SRC) -libpthread-nomulti-y += $(patsubst %.c,$(libpthread_OUT)/%.o,$(libpthread_NO_MULTI)) - lib-a-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.a lib-so-$(UCLIBC_HAS_THREADS) += $(top_builddir)lib/libpthread.so objclean-y += libpthread_clean headers-$(UCLIBC_HAS_THREADS) += linuxthreads_headers headers_clean-y += linuxthreads_headers_clean +#ifeq ($(DOMULTI),n) $(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread_so.a $(libc) $(call link.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION)) +#else +#$(top_builddir)lib/libpthread.so: $(libpthread_OUT)/libpthread.oS | $(libc) +# $(call linkm.so,$(libpthread_FULL_NAME),$(MAJOR_VERSION)) +#endif $(libpthread_OUT)/libpthread_so.a: $(libpthread-so-y) $(Q)$(RM) $@ @@ -96,6 +96,15 @@ else endif $(do_ar) +$(libpthread_OUT)/libpthread.oS: $(libpthread_SRC) $(libpthread_SPEC_SRC) + $(Q)$(RM) $@ + $(compile-m) +ifeq ($(PTHREADS_DEBUG_SUPPORT),y) + $(do_t_strip:-x=-X --strip-debug) +else + $(do_t_strip) +endif + $(top_builddir)lib/libpthread.a: $(libpthread-a-y) $(Q)$(INSTALL) -d $(dir $@) $(Q)$(RM) $@ @@ -107,10 +116,10 @@ endif $(do_ar) linuxthreads_headers: - $(LN) -sf ../$(PTDIR)/sysdeps/pthread/pthread.h $(top_builddir)include/ - $(LN) -sf ../$(PTDIR)/semaphore.h $(top_builddir)include/ - $(INSTALL) -d $(top_builddir)include/bits - $(LN) -sf ../../$(PTDIR)/sysdeps/pthread/bits/pthreadtypes.h $(top_builddir)include/bits/ + $(Q)$(LN) -sf ../$(PTDIR)/sysdeps/pthread/pthread.h $(top_builddir)include/ + $(Q)$(LN) -sf ../$(PTDIR)/semaphore.h $(top_builddir)include/ + $(Q)$(INSTALL) -d $(top_builddir)include/bits + $(Q)$(LN) -sf ../../$(PTDIR)/sysdeps/pthread/bits/pthreadtypes.h $(top_builddir)include/bits/ linuxthreads_headers_clean: $(RM) $(top_builddir)include/pthread.h $(top_builddir)include/semaphore.h \ diff --git a/libpthread/linuxthreads.old/attr.c b/libpthread/linuxthreads.old/attr.c index a8dfb335e..9deeee0ef 100644 --- a/libpthread/linuxthreads.old/attr.c +++ b/libpthread/linuxthreads.old/attr.c @@ -25,8 +25,6 @@ #include "pthread.h" #include "internals.h" -extern int __getpagesize(void); - /* NOTE: With uClibc I don't think we need this versioning stuff. * Therefore, define the function pthread_attr_init() here using * a strong symbol. */ @@ -34,7 +32,7 @@ extern int __getpagesize(void); //int __pthread_attr_init_2_1(pthread_attr_t *attr) int pthread_attr_init(pthread_attr_t *attr) { - size_t ps = __getpagesize (); + size_t ps = getpagesize (); attr->__detachstate = PTHREAD_CREATE_JOINABLE; attr->__schedpolicy = SCHED_OTHER; @@ -50,7 +48,7 @@ int pthread_attr_init(pthread_attr_t *attr) /* uClibc: leave out this for now. */ #if DO_PTHREAD_VERSIONING_WITH_UCLIBC -#if defined __HAVE_ELF__ && defined __PIC__ && defined DO_VERSIONING +#if defined __PIC__ && defined DO_VERSIONING default_symbol_version (__pthread_attr_init_2_1, pthread_attr_init, GLIBC_2.1); int __pthread_attr_init_2_0(pthread_attr_t *attr) @@ -156,7 +154,7 @@ int pthread_attr_getscope(const pthread_attr_t *attr, int *scope) int __pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize) { - size_t ps = __getpagesize (); + size_t ps = getpagesize (); /* First round up the guard size. */ guardsize = roundup (guardsize, ps); diff --git a/libpthread/linuxthreads.old/condvar.c b/libpthread/linuxthreads.old/condvar.c index c5a4f81da..62df907c1 100644 --- a/libpthread/linuxthreads.old/condvar.c +++ b/libpthread/linuxthreads.old/condvar.c @@ -96,7 +96,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) pthread_exit(PTHREAD_CANCELED); } - pthread_mutex_unlock(mutex); + __pthread_mutex_unlock(mutex); spurious_wakeup_count = 0; while (1) @@ -121,7 +121,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) if (THREAD_GETMEM(self, p_woken_by_cancel) && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) { THREAD_SETMEM(self, p_woken_by_cancel, 0); - pthread_mutex_lock(mutex); + __pthread_mutex_lock(mutex); pthread_exit(PTHREAD_CANCELED); } @@ -129,7 +129,7 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) while (spurious_wakeup_count--) restart(self); - pthread_mutex_lock(mutex); + __pthread_mutex_lock(mutex); return 0; } @@ -171,7 +171,7 @@ pthread_cond_timedwait_relative(pthread_cond_t *cond, pthread_exit(PTHREAD_CANCELED); } - pthread_mutex_unlock(mutex); + __pthread_mutex_unlock(mutex); spurious_wakeup_count = 0; while (1) @@ -188,7 +188,7 @@ pthread_cond_timedwait_relative(pthread_cond_t *cond, if (was_on_queue) { __pthread_set_own_extricate_if(self, 0); - pthread_mutex_lock(mutex); + __pthread_mutex_lock(mutex); return ETIMEDOUT; } @@ -215,7 +215,7 @@ pthread_cond_timedwait_relative(pthread_cond_t *cond, if (THREAD_GETMEM(self, p_woken_by_cancel) && THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE) { THREAD_SETMEM(self, p_woken_by_cancel, 0); - pthread_mutex_lock(mutex); + __pthread_mutex_lock(mutex); pthread_exit(PTHREAD_CANCELED); } @@ -223,7 +223,7 @@ pthread_cond_timedwait_relative(pthread_cond_t *cond, while (spurious_wakeup_count--) restart(self); - pthread_mutex_lock(mutex); + __pthread_mutex_lock(mutex); return 0; } diff --git a/libpthread/linuxthreads.old/forward.c b/libpthread/linuxthreads.old/forward.c index 90ec6ef3a..87101a15b 100644 --- a/libpthread/linuxthreads.old/forward.c +++ b/libpthread/linuxthreads.old/forward.c @@ -17,12 +17,14 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <dlfcn.h> -#include "internals.h" +#include <features.h> #include <stdlib.h> +#include <dlfcn.h> -#include <libc-internal.h> +/* psm: keep this before internals.h */ +libc_hidden_proto(exit) +#include "internals.h" /* Pointers to the libc functions. */ struct pthread_functions __libc_pthread_functions attribute_hidden; @@ -101,8 +103,8 @@ FORWARD (pthread_equal, (pthread_t thread1, pthread_t thread2), /* Use an alias to avoid warning, as pthread_exit is declared noreturn. */ -FORWARD2 (__pthread_exit, void, (void *retval), (retval), __exit (EXIT_SUCCESS)) -strong_alias (__pthread_exit, pthread_exit); +FORWARD2 (__pthread_exit, void, (void *retval), (retval), exit (EXIT_SUCCESS)) +strong_alias (__pthread_exit, pthread_exit) FORWARD (pthread_getschedparam, @@ -118,16 +120,16 @@ FORWARD (pthread_mutex_destroy, (pthread_mutex_t *mutex), (mutex), 0) FORWARD (pthread_mutex_init, (pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexattr), (mutex, mutexattr), 0) -hidden_strong_alias(pthread_mutex_init, __pthread_mutex_init) +strong_alias(pthread_mutex_init, __pthread_mutex_init) FORWARD (pthread_mutex_lock, (pthread_mutex_t *mutex), (mutex), 0) -hidden_strong_alias(pthread_mutex_lock, __pthread_mutex_lock) +strong_alias(pthread_mutex_lock, __pthread_mutex_lock) FORWARD (pthread_mutex_trylock, (pthread_mutex_t *mutex), (mutex), 0) -hidden_strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock) +strong_alias(pthread_mutex_trylock, __pthread_mutex_trylock) FORWARD (pthread_mutex_unlock, (pthread_mutex_t *mutex), (mutex), 0) -hidden_strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock) +strong_alias(pthread_mutex_unlock, __pthread_mutex_unlock) FORWARD2 (pthread_self, pthread_t, (void), (), return 0) diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h index 8422db58f..17b724e64 100644 --- a/libpthread/linuxthreads.old/internals.h +++ b/libpthread/linuxthreads.old/internals.h @@ -25,6 +25,7 @@ #include <signal.h> #include <unistd.h> #include <sys/types.h> +#include <sys/wait.h> #include "pt-machine.h" #include "semaphore.h" #include "../linuxthreads.old_db/thread_dbP.h" @@ -257,7 +258,7 @@ extern pthread_descr __pthread_main_thread; * the bounds a-priori. -StS */ extern char *__pthread_initial_thread_bos; -#ifndef __ARCH_HAS_MMU__ +#ifndef __ARCH_USE_MMU__ extern char *__pthread_initial_thread_tos; #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) \ if ((tos)>=__pthread_initial_thread_bos \ @@ -265,7 +266,7 @@ extern char *__pthread_initial_thread_tos; __pthread_initial_thread_bos = (tos)+1 #else #define NOMMU_INITIAL_THREAD_BOUNDS(tos,bos) /* empty */ -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ /* Indicate whether at least one thread has a user-defined stack (if 1), @@ -329,7 +330,7 @@ extern size_t __pagesize; THREAD_SELF implementation is used, this must be a power of two and a multiple of PAGE_SIZE. */ #ifndef STACK_SIZE -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ #define STACK_SIZE (2 * 1024 * 1024) #else #define STACK_SIZE (4 * __pagesize) @@ -366,7 +367,7 @@ extern size_t __pagesize; all outstanding operations which modify memory. Some architectures distinguish between full, read and write barriers. */ #ifndef MEMORY_BARRIER -#define MEMORY_BARRIER() asm ("" : : : "memory") +#define MEMORY_BARRIER() __asm__ ("" : : : "memory") #endif #ifndef READ_MEMORY_BARRIER #define READ_MEMORY_BARRIER() MEMORY_BARRIER() @@ -386,7 +387,7 @@ static inline pthread_descr thread_self (void) return THREAD_SELF; #else char *sp = CURRENT_STACK_FRAME; -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ if (sp >= __pthread_initial_thread_bos) return &__pthread_initial_thread; else if (sp >= __pthread_manager_thread_bos @@ -419,7 +420,7 @@ static inline pthread_descr thread_self (void) else { return __pthread_find_self(); } -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ #endif } @@ -469,6 +470,12 @@ void __fresetlockfiles(void); void __pthread_manager_adjust_prio(int thread_prio); void __pthread_initialize_minimal (void); +extern void __pthread_exit (void *retval) +#if defined NOT_IN_libc && defined IS_IN_libpthread + attribute_noreturn +#endif + ; + extern int __pthread_attr_setguardsize __P ((pthread_attr_t *__attr, size_t __guardsize)); extern int __pthread_attr_getguardsize __P ((__const pthread_attr_t *__attr, @@ -483,17 +490,15 @@ extern int __pthread_attr_getstacksize __P ((__const pthread_attr_t *__attr, size_t *__stacksize)); extern int __pthread_getconcurrency __P ((void)); extern int __pthread_setconcurrency __P ((int __level)); -extern int __pthread_mutexattr_gettype __P ((__const pthread_mutexattr_t *__attr, - int *__kind)); extern void __pthread_kill_other_threads_np __P ((void)); extern void __pthread_restart_old(pthread_descr th); extern void __pthread_suspend_old(pthread_descr self); -extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abs); +extern int __pthread_timedsuspend_old(pthread_descr self, const struct timespec *abstime); extern void __pthread_restart_new(pthread_descr th); extern void __pthread_suspend_new(pthread_descr self); -extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abs); +extern int __pthread_timedsuspend_new(pthread_descr self, const struct timespec *abstime); extern void __pthread_wait_for_restart_signal(pthread_descr self); @@ -504,12 +509,17 @@ extern void (*__pthread_suspend)(pthread_descr); /* Prototypes for the function without cancelation support when the normal version has it. */ -extern int __libc_close (int fd); -extern int __libc_nanosleep (const struct timespec *requested_time, - struct timespec *remaining); -extern ssize_t __libc_read (int fd, void *buf, size_t count); -extern pid_t __libc_waitpid (pid_t pid, int *stat_loc, int options); -extern ssize_t __libc_write (int fd, const void *buf, size_t count); +extern __typeof(close) __libc_close; +extern __typeof(nanosleep) __libc_nanosleep; +extern __typeof(read) __libc_read; +extern __typeof(waitpid) __libc_waitpid; +extern __typeof(write) __libc_write; + +extern __typeof(pthread_mutex_init) __pthread_mutex_init attribute_hidden; +extern __typeof(pthread_mutex_destroy) __pthread_mutex_destroy attribute_hidden; +extern __typeof(pthread_mutex_lock) __pthread_mutex_lock attribute_hidden; +extern __typeof(pthread_mutex_trylock) __pthread_mutex_trylock attribute_hidden; +extern __typeof(pthread_mutex_unlock) __pthread_mutex_attribute_hidden; /* Prototypes for some of the new semaphore functions. */ extern int __new_sem_post (sem_t * sem); diff --git a/libpthread/linuxthreads.old/join.c b/libpthread/linuxthreads.old/join.c index a1172fa34..6a8a9d982 100644 --- a/libpthread/linuxthreads.old/join.c +++ b/libpthread/linuxthreads.old/join.c @@ -15,7 +15,6 @@ /* Thread termination and joining */ #include <features.h> -#define __USE_GNU #include <errno.h> #include <sched.h> #include <unistd.h> diff --git a/libpthread/linuxthreads.old/libc_pthread_init.c b/libpthread/linuxthreads.old/libc_pthread_init.c index 647a19323..0ef3b47fc 100644 --- a/libpthread/linuxthreads.old/libc_pthread_init.c +++ b/libpthread/linuxthreads.old/libc_pthread_init.c @@ -17,7 +17,6 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _GNU_SOURCE #include <features.h> #include <locale.h> #include <stdlib.h> @@ -25,8 +24,10 @@ #include "internals.h" #include "sysdeps/pthread/pthread-functions.h" +libc_hidden_proto(memcpy) + #if !(USE_TLS && HAVE___THREAD) && defined __UCLIBC_HAS_XLOCALE__ -extern __locale_t __uselocale (__locale_t __dataset) __THROW attribute_hidden; +libc_hidden_proto(uselocale) #endif int __libc_multiple_threads attribute_hidden __attribute__((nocommon)); @@ -39,14 +40,14 @@ __libc_pthread_init (functions) /* We copy the content of the variable pointed to by the FUNCTIONS parameter to one in libc.so since this means access to the array can be done with one memory access instead of two. */ - __memcpy (&__libc_pthread_functions, functions, + memcpy (&__libc_pthread_functions, functions, sizeof (__libc_pthread_functions)); #endif #if !(USE_TLS && HAVE___THREAD) && defined __UCLIBC_HAS_XLOCALE__ /* Initialize thread-locale current locale to point to the global one. With __thread support, the variable's initializer takes care of this. */ - __uselocale (LC_GLOBAL_LOCALE); + uselocale (LC_GLOBAL_LOCALE); #endif return &__libc_multiple_threads; diff --git a/libpthread/linuxthreads.old/locale.c b/libpthread/linuxthreads.old/locale.c index c3ebbc285..c0879d0ce 100644 --- a/libpthread/linuxthreads.old/locale.c +++ b/libpthread/linuxthreads.old/locale.c @@ -15,7 +15,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define _GNU_SOURCE #include <features.h> #include "pthread.h" #include "internals.h" diff --git a/libpthread/linuxthreads.old/lockfile.c b/libpthread/linuxthreads.old/lockfile.c index 7bd2155ac..d054b62cb 100644 --- a/libpthread/linuxthreads.old/lockfile.c +++ b/libpthread/linuxthreads.old/lockfile.c @@ -20,20 +20,24 @@ #include <stdio.h> #include <pthread.h> +extern __typeof(pthread_mutexattr_init) __pthread_mutexattr_init attribute_hidden; +extern __typeof(pthread_mutexattr_settype) __pthread_mutexattr_settype attribute_hidden; +extern __typeof(pthread_mutexattr_destroy) __pthread_mutexattr_destroy attribute_hidden; + /* Note: glibc puts flockfile, funlockfile, and ftrylockfile in both * libc and libpthread. In uClibc, they are now in libc only. */ -void -__fresetlockfiles (void) +void __fresetlockfiles (void); +void __fresetlockfiles (void) { FILE *fp; pthread_mutexattr_t attr; - pthread_mutexattr_init(&attr); - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); + __pthread_mutexattr_init(&attr); + __pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); for (fp = _stdio_openlist; fp != NULL; fp = fp->__nextopen) __pthread_mutex_init(&fp->__lock, &attr); - pthread_mutexattr_destroy(&attr); + __pthread_mutexattr_destroy(&attr); } diff --git a/libpthread/linuxthreads.old/manager.c b/libpthread/linuxthreads.old/manager.c index 3e42ccb85..df26344e7 100644 --- a/libpthread/linuxthreads.old/manager.c +++ b/libpthread/linuxthreads.old/manager.c @@ -14,12 +14,7 @@ /* The "thread manager" thread: manages creation and termination of threads */ -/* mods for uClibc: getpwd and getpagesize are the syscalls */ -#define __getpid getpid -#define __getpagesize getpagesize - #include <features.h> -#define __USE_GNU #include <errno.h> #include <sched.h> #include <stddef.h> @@ -49,6 +44,8 @@ # define USE_SELECT #endif +libpthread_hidden_proto(waitpid) +libpthread_hidden_proto(raise) /* Array of active threads. Entry 0 is reserved for the initial thread. */ struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX] = @@ -107,13 +104,13 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, int report_events, td_thr_events_t *event_maskp); static void pthread_handle_free(pthread_t th_id); -static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode); +static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode) attribute_noreturn; static void pthread_reap_children(void); static void pthread_kill_all_threads(int sig, int main_thread_also); /* The server thread managing requests for thread creation and termination */ -int __pthread_manager(void *arg) +int attribute_noreturn __pthread_manager(void *arg) { int reqfd = (int) (long int) arg; #ifdef USE_SELECT @@ -270,7 +267,7 @@ int __pthread_manager_event(void *arg) /* Process creation */ static int -__attribute__ ((noreturn)) +attribute_noreturn pthread_start_thread(void *arg) { pthread_descr self = (pthread_descr) arg; @@ -283,7 +280,7 @@ pthread_start_thread(void *arg) PDEBUG("\n"); /* Make sure our pid field is initialized, just in case we get there before our father has initialized it. */ - THREAD_SETMEM(self, p_pid, __getpid()); + THREAD_SETMEM(self, p_pid, getpid()); /* Initial signal mask is that of the creating thread. (Otherwise, we'd just inherit the mask of the thread manager.) */ sigprocmask(SIG_SETMASK, &self->p_start_args.mask, NULL); @@ -318,7 +315,7 @@ pthread_start_thread(void *arg) } static int -__attribute__ ((noreturn)) +attribute_noreturn pthread_start_thread_event(void *arg) { pthread_descr self = (pthread_descr) arg; @@ -328,7 +325,7 @@ pthread_start_thread_event(void *arg) #endif /* Make sure our pid field is initialized, just in case we get there before our father has initialized it. */ - THREAD_SETMEM(self, p_pid, __getpid()); + THREAD_SETMEM(self, p_pid, getpid()); /* Get the lock the manager will free once all is correctly set up. */ __pthread_lock (THREAD_GETMEM(self, p_lock), NULL); /* Free it immediately. */ @@ -363,7 +360,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr, } else { -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ stacksize = STACK_SIZE - pagesize; if (attr != NULL) stacksize = MIN (stacksize, roundup(attr->__stacksize, pagesize)); @@ -453,7 +450,7 @@ static int pthread_allocate_stack(const pthread_attr_t *attr, /* on non-MMU systems we always have non-standard stack frames */ __pthread_nonstandard_stacks = 1; -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ } /* Clear the thread data structure. */ @@ -478,7 +475,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, pthread_t new_thread_id; char *guardaddr = NULL; size_t guardsize = 0; - int pagesize = __getpagesize(); + int pagesize = getpagesize(); int saved_errno = 0; /* First check whether we have to change the policy and if yes, whether @@ -498,7 +495,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, &new_thread, &new_thread_bottom, &guardaddr, &guardsize) == 0) break; -#ifndef __ARCH_HAS_MMU__ +#ifndef __ARCH_USE_MMU__ else /* When there is MMU, mmap () is used to allocate the stack. If one * segment is already mapped, we should continue to see if we can @@ -635,14 +632,14 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr, /* Free the stack if we allocated it */ if (attr == NULL || !attr->__stackaddr_set) { -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ if (new_thread->p_guardsize != 0) munmap(new_thread->p_guardaddr, new_thread->p_guardsize); munmap((caddr_t)((char *)(new_thread+1) - INITIAL_STACK_SIZE), INITIAL_STACK_SIZE); #else free(new_thread_bottom); -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ } __pthread_handles[sseg].h_descr = NULL; __pthread_handles[sseg].h_bottom = NULL; @@ -719,7 +716,7 @@ static void pthread_free(pthread_descr th) /* If initial thread, nothing to free */ if (th == &__pthread_initial_thread) return; -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ if (!th->p_userstack) { /* Free the stack and thread descriptor area */ @@ -732,7 +729,7 @@ static void pthread_free(pthread_descr th) if (!th->p_userstack) { free(h_bottom_save); } -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ } /* Handle threads that have exited */ diff --git a/libpthread/linuxthreads.old/mutex.c b/libpthread/linuxthreads.old/mutex.c index ca470cd75..890841452 100644 --- a/libpthread/linuxthreads.old/mutex.c +++ b/libpthread/linuxthreads.old/mutex.c @@ -24,7 +24,7 @@ #include "queue.h" #include "restart.h" -int __pthread_mutex_init(pthread_mutex_t * mutex, +int attribute_hidden __pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t * mutex_attr) { __pthread_init_lock(&mutex->__m_lock); @@ -35,9 +35,8 @@ int __pthread_mutex_init(pthread_mutex_t * mutex, return 0; } strong_alias (__pthread_mutex_init, pthread_mutex_init) -hidden_def (__pthread_mutex_init) -int __pthread_mutex_destroy(pthread_mutex_t * mutex) +int attribute_hidden __pthread_mutex_destroy(pthread_mutex_t * mutex) { switch (mutex->__m_kind) { case PTHREAD_MUTEX_ADAPTIVE_NP: @@ -55,9 +54,8 @@ int __pthread_mutex_destroy(pthread_mutex_t * mutex) } } strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy) -hidden_def (__pthread_mutex_destroy) -int __pthread_mutex_trylock(pthread_mutex_t * mutex) +int attribute_hidden __pthread_mutex_trylock(pthread_mutex_t * mutex) { pthread_descr self; int retcode; @@ -92,9 +90,8 @@ int __pthread_mutex_trylock(pthread_mutex_t * mutex) } } strong_alias (__pthread_mutex_trylock, pthread_mutex_trylock) -hidden_def (__pthread_mutex_trylock) -int __pthread_mutex_lock(pthread_mutex_t * mutex) +int attribute_hidden __pthread_mutex_lock(pthread_mutex_t * mutex) { pthread_descr self; @@ -126,9 +123,8 @@ int __pthread_mutex_lock(pthread_mutex_t * mutex) } } strong_alias (__pthread_mutex_lock, pthread_mutex_lock) -hidden_def (__pthread_mutex_lock) -int __pthread_mutex_timedlock (pthread_mutex_t *mutex, +int pthread_mutex_timedlock (pthread_mutex_t *mutex, const struct timespec *abstime) { pthread_descr self; @@ -170,10 +166,8 @@ int __pthread_mutex_timedlock (pthread_mutex_t *mutex, return EINVAL; } } -strong_alias (__pthread_mutex_timedlock, pthread_mutex_timedlock) -hidden_def (__pthread_mutex_timedlock) -int __pthread_mutex_unlock(pthread_mutex_t * mutex) +int attribute_hidden __pthread_mutex_unlock(pthread_mutex_t * mutex) { switch (mutex->__m_kind) { case PTHREAD_MUTEX_ADAPTIVE_NP: @@ -203,22 +197,21 @@ int __pthread_mutex_unlock(pthread_mutex_t * mutex) } } strong_alias (__pthread_mutex_unlock, pthread_mutex_unlock) -hidden_def (__pthread_mutex_unlock) -int __pthread_mutexattr_init(pthread_mutexattr_t *attr) +int attribute_hidden __pthread_mutexattr_init(pthread_mutexattr_t *attr) { attr->__mutexkind = PTHREAD_MUTEX_TIMED_NP; return 0; } -strong_alias (__pthread_mutexattr_init, pthread_mutexattr_init) +strong_alias(__pthread_mutexattr_init,pthread_mutexattr_init) -int __pthread_mutexattr_destroy(pthread_mutexattr_t *attr attribute_unused) +int attribute_hidden __pthread_mutexattr_destroy(pthread_mutexattr_t *attr attribute_unused) { return 0; } -strong_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy) +strong_alias(__pthread_mutexattr_destroy,pthread_mutexattr_destroy) -int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind) +int attribute_hidden __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind) { if (kind != PTHREAD_MUTEX_ADAPTIVE_NP && kind != PTHREAD_MUTEX_RECURSIVE_NP @@ -228,10 +221,11 @@ int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind) attr->__mutexkind = kind; return 0; } -weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype) -strong_alias ( __pthread_mutexattr_settype, __pthread_mutexattr_setkind_np) +strong_alias(__pthread_mutexattr_settype,pthread_mutexattr_settype) +strong_alias (__pthread_mutexattr_settype, __pthread_mutexattr_setkind_np) weak_alias (__pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np) +int __pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind) attribute_hidden; int __pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind) { *kind = attr->__mutexkind; @@ -242,6 +236,8 @@ strong_alias (__pthread_mutexattr_gettype, __pthread_mutexattr_getkind_np) weak_alias (__pthread_mutexattr_getkind_np, pthread_mutexattr_getkind_np) int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr attribute_unused, + int *pshared) attribute_hidden; +int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr attribute_unused, int *pshared) { *pshared = PTHREAD_PROCESS_PRIVATE; @@ -249,6 +245,7 @@ int __pthread_mutexattr_getpshared (const pthread_mutexattr_t *attr attribute_un } weak_alias (__pthread_mutexattr_getpshared, pthread_mutexattr_getpshared) +int __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr attribute_unused, int pshared) attribute_hidden; int __pthread_mutexattr_setpshared (pthread_mutexattr_t *attr attribute_unused, int pshared) { if (pshared != PTHREAD_PROCESS_PRIVATE && pshared != PTHREAD_PROCESS_SHARED) @@ -278,9 +275,9 @@ static void pthread_once_cancelhandler(void *arg) { pthread_once_t *once_control = arg; - pthread_mutex_lock(&once_masterlock); + __pthread_mutex_lock(&once_masterlock); *once_control = NEVER; - pthread_mutex_unlock(&once_masterlock); + __pthread_mutex_unlock(&once_masterlock); pthread_cond_broadcast(&once_finished); } @@ -298,7 +295,7 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void)) state_changed = 0; - pthread_mutex_lock(&once_masterlock); + __pthread_mutex_lock(&once_masterlock); /* If this object was left in an IN_PROGRESS state in a parent process (indicated by stale generation field), reset it to NEVER. */ @@ -313,16 +310,16 @@ int __pthread_once(pthread_once_t * once_control, void (*init_routine)(void)) /* Here *once_control is stable and either NEVER or DONE. */ if (*once_control == NEVER) { *once_control = IN_PROGRESS | fork_generation; - pthread_mutex_unlock(&once_masterlock); + __pthread_mutex_unlock(&once_masterlock); pthread_cleanup_push(pthread_once_cancelhandler, once_control); init_routine(); pthread_cleanup_pop(0); - pthread_mutex_lock(&once_masterlock); + __pthread_mutex_lock(&once_masterlock); WRITE_MEMORY_BARRIER(); *once_control = DONE; state_changed = 1; } - pthread_mutex_unlock(&once_masterlock); + __pthread_mutex_unlock(&once_masterlock); if (state_changed) pthread_cond_broadcast(&once_finished); @@ -341,19 +338,22 @@ strong_alias (__pthread_once, pthread_once) * and reset them back to NEVER. */ +void __pthread_once_fork_prepare(void); void __pthread_once_fork_prepare(void) { - pthread_mutex_lock(&once_masterlock); + __pthread_mutex_lock(&once_masterlock); } +void __pthread_once_fork_parent(void); void __pthread_once_fork_parent(void) { - pthread_mutex_unlock(&once_masterlock); + __pthread_mutex_unlock(&once_masterlock); } +void __pthread_once_fork_child(void); void __pthread_once_fork_child(void) { - pthread_mutex_init(&once_masterlock, NULL); + __pthread_mutex_init(&once_masterlock, NULL); pthread_cond_init(&once_finished, NULL); if (fork_generation <= INT_MAX - 4) fork_generation += 4; /* leave least significant two bits zero */ diff --git a/libpthread/linuxthreads.old/oldsemaphore.c b/libpthread/linuxthreads.old/oldsemaphore.c index 6817e8e7c..6e91dc3c7 100644 --- a/libpthread/linuxthreads.old/oldsemaphore.c +++ b/libpthread/linuxthreads.old/oldsemaphore.c @@ -53,6 +53,7 @@ static inline int sem_compare_and_swap(old_sem_t *sem, long oldval, long newval) static void sem_restart_list(pthread_descr waiting); +int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value); int __old_sem_init(old_sem_t *sem, int pshared, unsigned int value) { if (value > SEM_VALUE_MAX) { @@ -77,6 +78,7 @@ static int old_sem_extricate_func(void *obj attribute_unused, pthread_descr th a return 1; } +int __old_sem_wait(old_sem_t * sem); int __old_sem_wait(old_sem_t * sem) { long oldstatus, newstatus; @@ -139,6 +141,7 @@ int __old_sem_wait(old_sem_t * sem) } } +int __old_sem_trywait(old_sem_t * sem); int __old_sem_trywait(old_sem_t * sem) { long oldstatus, newstatus; @@ -155,6 +158,7 @@ int __old_sem_trywait(old_sem_t * sem) return 0; } +int __old_sem_post(old_sem_t * sem); int __old_sem_post(old_sem_t * sem) { long oldstatus, newstatus; @@ -178,6 +182,7 @@ int __old_sem_post(old_sem_t * sem) return 0; } +int __old_sem_getvalue(old_sem_t * sem, int * sval); int __old_sem_getvalue(old_sem_t * sem, int * sval) { long status = sem->sem_status; @@ -188,6 +193,7 @@ int __old_sem_getvalue(old_sem_t * sem, int * sval) return 0; } +int __old_sem_destroy(old_sem_t * sem); int __old_sem_destroy(old_sem_t * sem) { if ((sem->sem_status & 1) == 0) { diff --git a/libpthread/linuxthreads.old/ptfork.c b/libpthread/linuxthreads.old/ptfork.c index 8c0b464d2..184508a3d 100644 --- a/libpthread/linuxthreads.old/ptfork.c +++ b/libpthread/linuxthreads.old/ptfork.c @@ -18,7 +18,7 @@ #include <errno.h> -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ #include <stddef.h> #include <stdlib.h> @@ -61,14 +61,14 @@ int pthread_atfork(void (*prepare)(void), struct handler_list_block * block = (struct handler_list_block *) malloc(sizeof(struct handler_list_block)); if (block == NULL) return ENOMEM; - pthread_mutex_lock(&pthread_atfork_lock); + __pthread_mutex_lock(&pthread_atfork_lock); /* "prepare" handlers are called in LIFO */ pthread_insert_list(&pthread_atfork_prepare, prepare, &block->prepare, 0); /* "parent" handlers are called in FIFO */ pthread_insert_list(&pthread_atfork_parent, parent, &block->parent, 1); /* "child" handlers are called in FIFO */ pthread_insert_list(&pthread_atfork_child, child, &block->child, 1); - pthread_mutex_unlock(&pthread_atfork_lock); + __pthread_mutex_unlock(&pthread_atfork_lock); return 0; } //strong_alias (__pthread_atfork, pthread_atfork) @@ -78,18 +78,19 @@ static inline void pthread_call_handlers(struct handler_list * list) for (/*nothing*/; list != NULL; list = list->next) (list->handler)(); } -extern int __libc_fork(void); +extern __typeof(fork) __libc_fork; +pid_t __fork(void) attribute_hidden; pid_t __fork(void) { pid_t pid; struct handler_list * prepare, * child, * parent; - pthread_mutex_lock(&pthread_atfork_lock); + __pthread_mutex_lock(&pthread_atfork_lock); prepare = pthread_atfork_prepare; child = pthread_atfork_child; parent = pthread_atfork_parent; - pthread_mutex_unlock(&pthread_atfork_lock); + __pthread_mutex_unlock(&pthread_atfork_lock); pthread_call_handlers(prepare); pid = __libc_fork(); if (pid == 0) { @@ -101,13 +102,12 @@ pid_t __fork(void) } return pid; } -weak_alias (__fork, fork) +strong_alias(__fork,fork) -pid_t __vfork(void) +pid_t vfork(void) { return __fork(); } -weak_alias (__vfork, vfork) #else diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c index d7411f04b..4adf66cd6 100644 --- a/libpthread/linuxthreads.old/pthread.c +++ b/libpthread/linuxthreads.old/pthread.c @@ -16,7 +16,6 @@ #define __FORCE_GLIBC #include <features.h> -#define __USE_GNU #include <errno.h> #include <netdb.h> /* for h_errno */ #include <stddef.h> @@ -39,12 +38,10 @@ #include <sys/types.h> #include <sys/syscall.h> -/* mods for uClibc: getpwd and getpagesize are the syscalls */ -#define __getpid getpid -#define __getpagesize getpagesize /* mods for uClibc: __libc_sigaction is not in any standard headers */ -extern int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact); - +extern __typeof(sigaction) __libc_sigaction; +libpthread_hidden_proto(waitpid) +libpthread_hidden_proto(raise) /* These variables are used by the setup code. */ extern int _errno; @@ -175,9 +172,9 @@ char *__pthread_initial_thread_bos = NULL; * This is adapted when other stacks are malloc'ed since we don't know * the bounds a-priori. -StS */ -#ifndef __ARCH_HAS_MMU__ +#ifndef __ARCH_USE_MMU__ char *__pthread_initial_thread_tos = NULL; -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ /* File descriptor for sending requests to the thread manager. */ /* Initially -1, meaning that the thread manager is not running. */ @@ -268,6 +265,7 @@ int __libc_current_sigrtmax (void) /* Allocate real-time signal with highest/lowest available priority. Please note that we don't use a lock since we assume this function to be called at program start. */ +int __libc_allocate_rtsig (int high); int __libc_allocate_rtsig (int high) { if (current_rtmin == -1 || current_rtmin > current_rtmax) @@ -320,11 +318,11 @@ struct pthread_functions __pthread_functions = .ptr___pthread_exit = pthread_exit, .ptr_pthread_getschedparam = pthread_getschedparam, .ptr_pthread_setschedparam = pthread_setschedparam, - .ptr_pthread_mutex_destroy = pthread_mutex_destroy, - .ptr_pthread_mutex_init = pthread_mutex_init, - .ptr_pthread_mutex_lock = pthread_mutex_lock, - .ptr_pthread_mutex_trylock = pthread_mutex_trylock, - .ptr_pthread_mutex_unlock = pthread_mutex_unlock, + .ptr_pthread_mutex_destroy = __pthread_mutex_destroy, + .ptr_pthread_mutex_init = __pthread_mutex_init, + .ptr_pthread_mutex_lock = __pthread_mutex_lock, + .ptr_pthread_mutex_trylock = __pthread_mutex_trylock, + .ptr_pthread_mutex_unlock = __pthread_mutex_unlock, .ptr_pthread_self = pthread_self, .ptr_pthread_setcancelstate = pthread_setcancelstate, .ptr_pthread_setcanceltype = pthread_setcanceltype, @@ -365,8 +363,10 @@ static void pthread_initialize(void) { struct sigaction sa; sigset_t mask; +#ifdef __ARCH_USE_MMU__ struct rlimit limit; rlim_t max_stack; +#endif /* If already done (e.g. by a constructor called earlier!), bail out */ if (__pthread_initial_thread_bos != NULL) return; @@ -380,7 +380,7 @@ static void pthread_initialize(void) __pthread_initial_thread_bos = (char *)(((long)CURRENT_STACK_FRAME - 2 * STACK_SIZE) & ~(STACK_SIZE - 1)); /* Update the descriptor for the initial thread. */ - __pthread_initial_thread.p_pid = __getpid(); + __pthread_initial_thread.p_pid = getpid(); /* If we have special thread_self processing, initialize that for the main thread now. */ #ifdef INIT_THREAD_SELF @@ -410,11 +410,11 @@ static void pthread_initialize(void) beyond STACK_SIZE minus two pages (one page for the thread descriptor immediately beyond, and one page to act as a guard page). */ -#ifdef __ARCH_HAS_MMU__ +#ifdef __ARCH_USE_MMU__ /* We cannot allocate a huge chunk of memory to mmap all thread stacks later * on a non-MMU system. Thus, we don't need the rlimit either. -StS */ getrlimit(RLIMIT_STACK, &limit); - max_stack = STACK_SIZE - 2 * __getpagesize(); + max_stack = STACK_SIZE - 2 * getpagesize(); if (limit.rlim_cur > max_stack) { limit.rlim_cur = max_stack; setrlimit(RLIMIT_STACK, &limit); @@ -425,11 +425,11 @@ static void pthread_initialize(void) * malloc other stack frames such that they don't overlap. -StS */ __pthread_initial_thread_tos = - (char *)(((long)CURRENT_STACK_FRAME + __getpagesize()) & ~(__getpagesize() - 1)); + (char *)(((long)CURRENT_STACK_FRAME + getpagesize()) & ~(getpagesize() - 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); -#endif /* __ARCH_HAS_MMU__ */ +#endif /* __ARCH_USE_MMU__ */ /* Setup signal handlers for the initial thread. Since signal handlers are shared between threads, these settings @@ -462,6 +462,7 @@ static void pthread_initialize(void) on_exit(pthread_onexit_process, NULL); } +void __pthread_initialize(void); void __pthread_initialize(void) { pthread_initialize(); @@ -848,7 +849,7 @@ void __pthread_reset_main_thread() } /* Update the pid of the main thread */ - THREAD_SETMEM(self, p_pid, __getpid()); + THREAD_SETMEM(self, p_pid, getpid()); /* Make the forked thread the main thread */ __pthread_main_thread = self; THREAD_SETMEM(self, p_nextlive, self); @@ -1090,7 +1091,7 @@ void __pthread_message(char * fmt, ...) { char buffer[1024]; va_list args; - sprintf(buffer, "%05d : ", __getpid()); + sprintf(buffer, "%05d : ", getpid()); va_start(args, fmt); vsnprintf(buffer + 8, sizeof(buffer) - 8, fmt, args); va_end(args); diff --git a/libpthread/linuxthreads.old/ptlongjmp.c b/libpthread/linuxthreads.old/ptlongjmp.c index c0ea8223a..055a217d3 100644 --- a/libpthread/linuxthreads.old/ptlongjmp.c +++ b/libpthread/linuxthreads.old/ptlongjmp.c @@ -21,11 +21,8 @@ /* These functions are not declared anywhere since they shouldn't be used at another place but here. */ -extern void __libc_siglongjmp (sigjmp_buf env, int val) - __attribute__ ((noreturn)); -extern void __libc_longjmp (sigjmp_buf env, int val) - __attribute__ ((noreturn)); - +extern __typeof(siglongjmp) __libc_siglongjmp attribute_noreturn; +extern __typeof(longjmp) __libc_longjmp attribute_noreturn; static void pthread_cleanup_upto(__jmp_buf target) { @@ -42,14 +39,14 @@ static void pthread_cleanup_upto(__jmp_buf target) THREAD_SETMEM(self, p_in_sighandler, NULL); } -void siglongjmp(sigjmp_buf env, int val) +void attribute_noreturn siglongjmp(sigjmp_buf env, int val) { pthread_cleanup_upto(env->__jmpbuf); __libc_siglongjmp(env, val); } -void longjmp(jmp_buf env, int val) +void attribute_noreturn longjmp(jmp_buf env, int val) { pthread_cleanup_upto(env->__jmpbuf); - __libc_siglongjmp(env, val); + __libc_longjmp(env, val); } diff --git a/libpthread/linuxthreads.old/semaphore.c b/libpthread/linuxthreads.old/semaphore.c index 0a156e123..a44f52411 100644 --- a/libpthread/linuxthreads.old/semaphore.c +++ b/libpthread/linuxthreads.old/semaphore.c @@ -15,7 +15,6 @@ /* Semaphores a la POSIX 1003.1b */ #include <features.h> -#define __USE_GNU #include <errno.h> #include "pthread.h" #include "semaphore.h" @@ -24,6 +23,7 @@ #include "restart.h" #include "queue.h" +int __new_sem_init(sem_t *sem, int pshared, unsigned int value); int __new_sem_init(sem_t *sem, int pshared, unsigned int value) { if (value > SEM_VALUE_MAX) { @@ -56,6 +56,7 @@ static int new_sem_extricate_func(void *obj, pthread_descr th) return did_remove; } +int __new_sem_wait(sem_t * sem); int __new_sem_wait(sem_t * sem) { volatile pthread_descr self = thread_self(); @@ -118,6 +119,7 @@ int __new_sem_wait(sem_t * sem) return 0; } +int __new_sem_trywait(sem_t * sem); int __new_sem_trywait(sem_t * sem) { int retval; @@ -134,6 +136,7 @@ int __new_sem_trywait(sem_t * sem) return retval; } +int __new_sem_post(sem_t * sem); int __new_sem_post(sem_t * sem) { pthread_descr self = thread_self(); @@ -175,12 +178,14 @@ int __new_sem_post(sem_t * sem) return 0; } +int __new_sem_getvalue(sem_t * sem, int * sval); int __new_sem_getvalue(sem_t * sem, int * sval) { *sval = sem->__sem_value; return 0; } +int __new_sem_destroy(sem_t * sem); int __new_sem_destroy(sem_t * sem) { if (sem->__sem_waiting != NULL) { diff --git a/libpthread/linuxthreads.old/signals.c b/libpthread/linuxthreads.old/signals.c index 0ac858139..23ba9778f 100644 --- a/libpthread/linuxthreads.old/signals.c +++ b/libpthread/linuxthreads.old/signals.c @@ -24,7 +24,7 @@ #include <bits/sigcontextinfo.h> /* mods for uClibc: __libc_sigaction is not in any standard headers */ -extern int __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact); +extern __typeof(sigaction) __libc_sigaction; int pthread_sigmask(int how, const sigset_t * newmask, sigset_t * oldmask) { @@ -131,7 +131,8 @@ static void pthread_sighandler_rt(int signo, struct siginfo *si, /* The wrapper around sigaction. Install our own signal handler around the signal. */ -int __sigaction(int sig, const struct sigaction * act, +libpthread_hidden_proto(sigaction) +int sigaction(int sig, const struct sigaction * act, struct sigaction * oact) { struct sigaction newact; @@ -162,7 +163,7 @@ printf(__FUNCTION__": pthreads wrapper!\n"); if (__libc_sigaction(sig, newactp, oact) == -1) return -1; #ifdef DEBUG_PT -printf(__FUNCTION__": signahdler installed, __sigaction successful\n"); +printf(__FUNCTION__": sighandler installed, sigaction successful\n"); #endif if (sig > 0 && sig < NSIG) { @@ -175,7 +176,7 @@ printf(__FUNCTION__": signahdler installed, __sigaction successful\n"); } return 0; } -strong_alias(__sigaction, sigaction) +libpthread_hidden_def(sigaction) /* A signal handler that does nothing */ static void pthread_null_sighandler(int sig attribute_unused) { } @@ -236,6 +237,7 @@ int sigwait(const sigset_t * set, int * sig) /* Redefine raise() to send signal to calling thread only, as per POSIX 1003.1c */ +libpthread_hidden_proto(raise) int raise (int sig) { int retcode = pthread_kill(pthread_self(), sig); @@ -246,3 +248,4 @@ int raise (int sig) return -1; } } +libpthread_hidden_def(raise) diff --git a/libpthread/linuxthreads.old/specific.c b/libpthread/linuxthreads.old/specific.c index 509ee6665..72409b30b 100644 --- a/libpthread/linuxthreads.old/specific.c +++ b/libpthread/linuxthreads.old/specific.c @@ -15,7 +15,6 @@ /* Thread-specific data */ #include <features.h> -#define __USE_GNU #include <errno.h> #include <stddef.h> #include <stdlib.h> @@ -43,18 +42,18 @@ int pthread_key_create(pthread_key_t * key, destr_function destr) { int i; - pthread_mutex_lock(&pthread_keys_mutex); + __pthread_mutex_lock(&pthread_keys_mutex); for (i = 0; i < PTHREAD_KEYS_MAX; i++) { if (! pthread_keys[i].in_use) { /* Mark key in use */ pthread_keys[i].in_use = 1; pthread_keys[i].destr = destr; - pthread_mutex_unlock(&pthread_keys_mutex); + __pthread_mutex_unlock(&pthread_keys_mutex); *key = i; return 0; } } - pthread_mutex_unlock(&pthread_keys_mutex); + __pthread_mutex_unlock(&pthread_keys_mutex); return EAGAIN; } @@ -63,9 +62,9 @@ int pthread_key_delete(pthread_key_t key) { pthread_descr self = thread_self(); - pthread_mutex_lock(&pthread_keys_mutex); + __pthread_mutex_lock(&pthread_keys_mutex); if (key >= PTHREAD_KEYS_MAX || !pthread_keys[key].in_use) { - pthread_mutex_unlock(&pthread_keys_mutex); + __pthread_mutex_unlock(&pthread_keys_mutex); return EINVAL; } pthread_keys[key].in_use = 0; @@ -91,7 +90,7 @@ int pthread_key_delete(pthread_key_t key) } while (th != self); } - pthread_mutex_unlock(&pthread_keys_mutex); + __pthread_mutex_unlock(&pthread_keys_mutex); return 0; } diff --git a/libpthread/linuxthreads.old/spinlock.c b/libpthread/linuxthreads.old/spinlock.c index cdf45f195..e00bc3156 100644 --- a/libpthread/linuxthreads.old/spinlock.c +++ b/libpthread/linuxthreads.old/spinlock.c @@ -26,13 +26,15 @@ #include "spinlock.h" #include "restart.h" +libpthread_hidden_proto(nanosleep) + static void __pthread_acquire(int * spinlock); static inline void __pthread_release(int * spinlock) { WRITE_MEMORY_BARRIER(); *spinlock = __LT_SPINLOCK_INIT; - __asm __volatile ("" : "=m" (*spinlock) : "m" (*spinlock)); + __asm __volatile__ ("" : "=m" (*spinlock) : "m" (*spinlock)); } diff --git a/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h new file mode 100644 index 000000000..ad83147cb --- /dev/null +++ b/libpthread/linuxthreads.old/sysdeps/h8300/pt-machine.h @@ -0,0 +1,58 @@ +/* Machine-dependent pthreads configuration and inline functions. + H8/300 version. + Copyright (C) 1996, 1998, 2000, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Richard Henderson <rth@tamu.edu>. + + 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 long int testandset (int *spinlock); + +/* Spinlock implementation; required. */ +PT_EI long int +testandset (int *spinlock) +{ + char ret; + + __asm__ __volatile__( + "sub.w %0,%0\n\t" + "stc ccr,@-sp\n\t" + "orc #0x80,ccr\n\t" + "bld #0,@%2\n\t" + "bset #0,@%2\n\t" + "rotxl.w %0\n\t" + "ldc @sp+,ccr\n\t" + :"=r"(ret),"=m"(*spinlock) + :"g"(spinlock) + :"cc"); + + return ret; +} + + +/* 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 stack_pointer +register char * stack_pointer __asm__ ("%sp"); + +#endif /* pt-machine.h */ diff --git a/libpthread/linuxthreads.old/wrapsyscall.c b/libpthread/linuxthreads.old/wrapsyscall.c index 6b8a00bb5..369c190d5 100644 --- a/libpthread/linuxthreads.old/wrapsyscall.c +++ b/libpthread/linuxthreads.old/wrapsyscall.c @@ -102,9 +102,11 @@ CANCELABLE_SYSCALL (int, msync, (__ptr_t addr, size_t length, int flags), /* nanosleep(2). */ +libpthread_hidden_proto(nanosleep) CANCELABLE_SYSCALL (int, nanosleep, (const struct timespec *requested_time, struct timespec *remaining), (requested_time, remaining)) +libpthread_hidden_def(nanosleep) /* open(2). */ @@ -167,9 +169,11 @@ CANCELABLE_SYSCALL (__pid_t, wait, (__WAIT_STATUS_DEFN stat_loc), (stat_loc)) /* waitpid(2). */ +libpthread_hidden_proto(waitpid) CANCELABLE_SYSCALL (__pid_t, waitpid, (__pid_t pid, int *stat_loc, int options), (pid, stat_loc, options)) +libpthread_hidden_def(waitpid) /* write(2). */ diff --git a/libpthread/linuxthreads.old_db/Makefile.in b/libpthread/linuxthreads.old_db/Makefile.in index c203232e7..acdcd69e3 100644 --- a/libpthread/linuxthreads.old_db/Makefile.in +++ b/libpthread/linuxthreads.old_db/Makefile.in @@ -1,14 +1,17 @@ # Makefile for uClibc # -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # # Get the thread include dependencies and shared object name -CFLAGS-linuxthreads.old_db := -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\"" +CFLAGS-linuxthreads.old_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\"" -LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) -s --warn-unresolved-symbols +LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) $(call check_ld,--warn-unresolved-symbols) +ifneq ($(NOSTRIP),y) +LDFLAGS-libthread_db.so += -s +endif LIBS-libthread_db.so := $(LIBS) @@ -28,26 +31,34 @@ else libthread_db-a-y := $(libthread_db_OBJ) endif -libthread_db-multi-y := $(libthread_db_SRC) - lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so objclean-y += libthread_db_clean headers-$(PTHREADS_DEBUG_SUPPORT) += linuxthreads_db_headers headers_clean-y += linuxthreads_db_headers_clean +#ifeq ($(DOMULTI),n) ifeq ($(DOPIC),y) $(top_builddir)lib/libthread_db.so: $(top_builddir)lib/libthread_db.a $(libc) else $(top_builddir)lib/libthread_db.so: $(libthread_db_OUT)/libthread_db_so.a $(libc) endif $(call link.so,$(libthread_db_FULL_NAME),1) +#else +#$(top_builddir)lib/libthread_db.so: $(libthread_db_OUT)/libthread_db.oS | $(libc) +# $(call linkm.so,$(libthread_db_FULL_NAME),1) +#endif $(libthread_db_OUT)/libthread_db_so.a: $(libthread_db-so-y) $(Q)$(RM) $@ $(do_strip) $(do_ar) +$(libthread_db_OUT)/libthread_db.oS: $(libthread_db_SRC) + $(Q)$(RM) $@ + $(compile-m) + $(do_t_strip) + $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) $(Q)$(INSTALL) -d $(dir $@) $(Q)$(RM) $@ @@ -55,10 +66,10 @@ $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) $(do_ar) linuxthreads_db_headers: - $(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/ + $(Q)$(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/ linuxthreads_db_headers_clean: $(RM) $(top_builddir)include/thread_db.h libthread_db_clean: - $(RM) $(libthread_db_OUT)/*.{o,os,a} + $(RM) $(libthread_db_OUT)/*.{o,os,oS,a} diff --git a/libpthread/linuxthreads.old_db/td_init.c b/libpthread/linuxthreads.old_db/td_init.c index d714f1ba0..6f0e1584c 100644 --- a/libpthread/linuxthreads.old_db/td_init.c +++ b/libpthread/linuxthreads.old_db/td_init.c @@ -20,8 +20,9 @@ #include "thread_dbP.h" +#ifndef NDEBUG int __td_debug; - +#endif td_err_e td_init (void) diff --git a/libpthread/linuxthreads.old_db/thread_dbP.h b/libpthread/linuxthreads.old_db/thread_dbP.h index 257beb2e9..f08c43206 100644 --- a/libpthread/linuxthreads.old_db/thread_dbP.h +++ b/libpthread/linuxthreads.old_db/thread_dbP.h @@ -11,7 +11,7 @@ #include "internals.h" -/* Indeces for the symbol names. */ +/* Indices for the symbol names. */ enum { PTHREAD_THREADS_EVENTS = 0, @@ -33,8 +33,8 @@ enum /* Comment out the following for less verbose output. */ #ifndef NDEBUG -# define LOG(c) if (__td_debug) __libc_write (2, c "\n", strlen (c "\n")) -extern int __td_debug; +# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n")) +extern int __td_debug attribute_hidden; #else # define LOG(c) #endif @@ -86,7 +86,7 @@ struct agent_list }; /* List of all known descriptors. */ -extern struct agent_list *__td_agent_list; +extern struct agent_list *__td_agent_list attribute_hidden; /* Function used to test for correct thread agent pointer. */ static inline int @@ -105,6 +105,6 @@ ta_ok (const td_thragent_t *ta) /* Internal wrapper around ps_pglobal_lookup. */ -extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr); +extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr) attribute_hidden; #endif /* thread_dbP.h */ diff --git a/libpthread/linuxthreads_db/Makefile.in b/libpthread/linuxthreads_db/Makefile.in index 7833e1bad..1dd2b02b0 100644 --- a/libpthread/linuxthreads_db/Makefile.in +++ b/libpthread/linuxthreads_db/Makefile.in @@ -1,15 +1,17 @@ # Makefile for uClibc # -# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> +# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org> # # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. # # Get the thread include dependencies and shared object name -CFLAGS-linuxthreads_db := -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\"" -CFLAGS-linuxthreads_db += -D_GNU_SOURCE +CFLAGS-linuxthreads_db := -DNOT_IN_libc -DLIBPTHREAD_SO="\"libpthread.so.$(MAJOR_VERSION)\"" -LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) -s --warn-unresolved-symbols +LDFLAGS-libthread_db.so := $(LDFLAGS_NOSTRIP) $(call check_ld,--warn-unresolved-symbols) +ifneq ($(NOSTRIP),y) +LDFLAGS-libthread_db.so += -s +endif LIBS-libthread_db.so := $(LIBS) @@ -29,26 +31,34 @@ else libthread_db-a-y := $(libthread_db_OBJ) endif -libthread_db-multi-y := $(libthread_db_SRC) - lib-a-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.a lib-so-$(PTHREADS_DEBUG_SUPPORT) += $(top_builddir)lib/libthread_db.so objclean-y += libthread_db_clean headers-$(PTHREADS_DEBUG_SUPPORT) += linuxthreads_db_headers headers_clean-y += linuxthreads_db_headers_clean +#ifeq ($(DOMULTI),n) ifeq ($(DOPIC),y) $(top_builddir)lib/libthread_db.so: $(top_builddir)lib/libthread_db.a $(libc) else $(top_builddir)lib/libthread_db.so: $(libthread_db_OUT)/libthread_db_so.a $(libc) endif $(call link.so,$(libthread_db_FULL_NAME),1) +#else +#$(top_builddir)lib/libthread_db.so: $(libthread_db_OUT)/libthread_db.oS | $(libc) +# $(call linkm.so,$(libthread_db_FULL_NAME),1) +#endif $(libthread_db_OUT)/libthread_db_so.a: $(libthread_db-so-y) $(Q)$(RM) $@ $(do_strip) $(do_ar) +$(libthread_db_OUT)/libthread_db.oS: $(libthread_db_SRC) + $(Q)$(RM) $@ + $(compile-m) + $(do_t_strip) + $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) $(Q)$(INSTALL) -d $(dir $@) $(Q)$(RM) $@ @@ -56,10 +66,10 @@ $(top_builddir)lib/libthread_db.a: $(libthread_db-a-y) $(do_ar) linuxthreads_db_headers: - $(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/ + $(Q)$(LN) -sf ../$(PTDIR)_db/thread_db.h $(top_builddir)include/ linuxthreads_db_headers_clean: $(RM) $(top_builddir)include/thread_db.h libthread_db_clean: - $(RM) $(libthread_db_OUT)/*.{o,os,a} + $(RM) $(libthread_db_OUT)/*.{o,os,oS,a} diff --git a/libpthread/linuxthreads_db/td_init.c b/libpthread/linuxthreads_db/td_init.c index d714f1ba0..6f0e1584c 100644 --- a/libpthread/linuxthreads_db/td_init.c +++ b/libpthread/linuxthreads_db/td_init.c @@ -20,8 +20,9 @@ #include "thread_dbP.h" +#ifndef NDEBUG int __td_debug; - +#endif td_err_e td_init (void) diff --git a/libpthread/linuxthreads_db/thread_dbP.h b/libpthread/linuxthreads_db/thread_dbP.h index 63b408afc..30bdae451 100644 --- a/libpthread/linuxthreads_db/thread_dbP.h +++ b/libpthread/linuxthreads_db/thread_dbP.h @@ -9,7 +9,7 @@ #include "../linuxthreads/descr.h" -/* Indeces for the symbol names. */ +/* Indices for the symbol names. */ enum { PTHREAD_THREADS_EVENTS = 0, @@ -32,7 +32,7 @@ enum /* Comment out the following for less verbose output. */ #ifndef NDEBUG # define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n")) -extern int __td_debug; +extern int __td_debug attribute_hidden; #else # define LOG(c) #endif @@ -84,7 +84,7 @@ struct agent_list }; /* List of all known descriptors. */ -extern struct agent_list *__td_agent_list; +extern struct agent_list *__td_agent_list attribute_hidden; /* Function used to test for correct thread agent pointer. */ static inline int @@ -103,6 +103,6 @@ ta_ok (const td_thragent_t *ta) /* Internal wrapper around ps_pglobal_lookup. */ -extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr); +extern int td_lookup (struct ps_prochandle *ps, int idx, psaddr_t *sym_addr) attribute_hidden; #endif /* thread_dbP.h */ |