summaryrefslogtreecommitdiffstats
path: root/libpthread/linuxthreads.old
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2008-11-17 09:45:29 +0000
committerCarmelo Amoroso <carmelo.amoroso@st.com>2008-11-17 09:45:29 +0000
commit9584b4e582b293ead79d8bb0ff85c1ef12a888d9 (patch)
tree7eaf3bc76dd05e6d9a9c7002e7a9d5e23d5cd5fd /libpthread/linuxthreads.old
parentcf8c7b558c1c33cafe557ced361554461485af6c (diff)
downloaduClibc-alpine-9584b4e582b293ead79d8bb0ff85c1ef12a888d9.tar.bz2
uClibc-alpine-9584b4e582b293ead79d8bb0ff85c1ef12a888d9.tar.xz
Synch with trunk @ 24071.
Step 1 linuxthreads - linuxthreads_db - linuxthread.old - linuxthreads.old_db
Diffstat (limited to 'libpthread/linuxthreads.old')
-rw-r--r--libpthread/linuxthreads.old/Makefile.in18
-rw-r--r--libpthread/linuxthreads.old/forward.c11
-rw-r--r--libpthread/linuxthreads.old/internals.h4
-rw-r--r--libpthread/linuxthreads.old/ptfork.c50
-rw-r--r--libpthread/linuxthreads.old/pthread.c6
-rw-r--r--libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h2
-rw-r--r--libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h38
-rw-r--r--libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch4
-rw-r--r--libpthread/linuxthreads.old/wrapsyscall.c6
9 files changed, 106 insertions, 33 deletions
diff --git a/libpthread/linuxthreads.old/Makefile.in b/libpthread/linuxthreads.old/Makefile.in
index fe29f2cd1..d504b9999 100644
--- a/libpthread/linuxthreads.old/Makefile.in
+++ b/libpthread/linuxthreads.old/Makefile.in
@@ -1,7 +1,7 @@
# Makefile for uClibc
#
# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -71,9 +71,6 @@ libpthread-so-y += $(libpthread_OBJ:.o=.os) $(libpthread-shared-y)
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.depend)
@@ -111,13 +108,16 @@ include/semaphore.h:
$(do_ln) ../$(PTDIR)/$(@F) $(top_builddir)$@
include/bits/pthreadtypes.h: | include/bits
$(do_ln) ../../$(PTDIR)/sysdeps/pthread/bits/$(@F) $(top_builddir)$@
-linuxthreads_headers: include/pthread.h include/semaphore.h \
+
+linuxthreads_headers := include/pthread.h include/semaphore.h \
include/bits/pthreadtypes.h
+$(linuxthreads_headers): $(wildcard $(addprefix include/config/linuxthreads/,old.h new.h))
+headers-$(UCLIBC_HAS_THREADS) += $(linuxthreads_headers)
+objclean-y += libpthread_clean
+headers_clean-y += linuxthreads_headers_clean
linuxthreads_headers_clean:
- $(RM) $(top_builddir)include/pthread.h \
- $(top_builddir)include/semaphore.h \
- $(top_builddir)include/bits/pthreadtypes.h
+ $(do_rm) $(addprefix $(top_builddir),$(linuxthreads_headers))
libpthread_clean:
- $(RM) $(libpthread_OUT)/*.{o,os,oS,a}
+ $(do_rm) $(addprefix $(libpthread_OUT)/*., o os oS a)
diff --git a/libpthread/linuxthreads.old/forward.c b/libpthread/linuxthreads.old/forward.c
index eeaefd7a3..5dc9cf4c0 100644
--- a/libpthread/linuxthreads.old/forward.c
+++ b/libpthread/linuxthreads.old/forward.c
@@ -23,20 +23,21 @@
/* psm: keep this before internals.h */
libc_hidden_proto(exit)
-/* vda: here's why:
+#if 0
+vda: here is why:
In libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
adding libc_hidden_proto(foo) just before weak_extern (__pthread_initialize)
will not warn:
- //libc_hidden_proto(foo)
+ /* libc_hidden_proto(foo) */
weak_extern (__pthread_initialize)
- //libc_hidden_proto(foo)
+ /* libc_hidden_proto(foo) */
but adding after will! Which is extremely strange -
weak_extern expands into just "#pragma weak __pthread_initialize".
TODO: determine whether it is a gcc bug or what
-(see gcc.gnu.org/bugzilla/show_bug.cgi?id=36282).
+(see gcc.gnu.org/PR36282).
For now, just include all headers before internals.h
(they are again included in internals.h - maybe remove them there later)
-*/
+#endif
#include <string.h>
#include <limits.h>
#include <setjmp.h>
diff --git a/libpthread/linuxthreads.old/internals.h b/libpthread/linuxthreads.old/internals.h
index 38290a5fe..0cb97357c 100644
--- a/libpthread/linuxthreads.old/internals.h
+++ b/libpthread/linuxthreads.old/internals.h
@@ -36,9 +36,7 @@
/* Use a funky version in a probably vein attempt at preventing gdb
* from dlopen()'ing glibc's libthread_db library... */
-#define STRINGIFY(s) STRINGIFY2 (s)
-#define STRINGIFY2(s) #s
-#define VERSION STRINGIFY(__UCLIBC_MAJOR__) "." STRINGIFY(__UCLIBC_MINOR__) "." STRINGIFY(__UCLIBC_SUBLEVEL__)
+#define VERSION __stringify(__UCLIBC_MAJOR__) "." __stringify(__UCLIBC_MINOR__) "." __stringify(__UCLIBC_SUBLEVEL__)
#ifndef THREAD_GETMEM
# define THREAD_GETMEM(descr, member) descr->member
diff --git a/libpthread/linuxthreads.old/ptfork.c b/libpthread/linuxthreads.old/ptfork.c
index c34ea8104..7a5749efc 100644
--- a/libpthread/linuxthreads.old/ptfork.c
+++ b/libpthread/linuxthreads.old/ptfork.c
@@ -20,6 +20,7 @@
#ifdef __ARCH_USE_MMU__
+#include <bits/uClibc_mutex.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
@@ -36,6 +37,16 @@ static struct handler_list * pthread_atfork_prepare = NULL;
static struct handler_list * pthread_atfork_parent = NULL;
static struct handler_list * pthread_atfork_child = NULL;
+#ifdef __MALLOC__
+__UCLIBC_MUTEX_EXTERN(__malloc_heap_lock);
+__UCLIBC_MUTEX_EXTERN(__malloc_sbrk_lock);
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+__UCLIBC_MUTEX_EXTERN(__malloc_mmb_heap_lock);
+#endif
+#elif defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+__UCLIBC_MUTEX_EXTERN(__malloc_lock);
+#endif
+
static void pthread_insert_list(struct handler_list ** list,
void (*handler)(void),
struct handler_list * newlist,
@@ -78,6 +89,10 @@ static __inline__ void pthread_call_handlers(struct handler_list * list)
for (/*nothing*/; list != NULL; list = list->next) (list->handler)();
}
+void __pthread_once_fork_prepare(void);
+void __pthread_once_fork_child(void);
+void __pthread_once_fork_parent(void);
+
extern __typeof(fork) __libc_fork;
pid_t __fork(void) attribute_hidden;
@@ -90,14 +105,47 @@ pid_t __fork(void)
prepare = pthread_atfork_prepare;
child = pthread_atfork_child;
parent = pthread_atfork_parent;
- __pthread_mutex_unlock(&pthread_atfork_lock);
pthread_call_handlers(prepare);
+
+ __pthread_once_fork_prepare();
+#ifdef __MALLOC__
+ __pthread_mutex_lock(&__malloc_sbrk_lock);
+ __pthread_mutex_lock(&__malloc_heap_lock);
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __pthread_mutex_lock(&__malloc_mmb_heap_lock);
+#endif
+#elif defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __pthread_mutex_lock(&__malloc_lock);
+#endif
+
pid = __libc_fork();
if (pid == 0) {
+#if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __libc_lock_init_recursive(__malloc_lock);
+#elif defined(__MALLOC__)
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __libc_lock_init_adaptive(__malloc_mmb_heap_lock);
+#endif
+ __libc_lock_init_adaptive(__malloc_heap_lock);
+ __libc_lock_init(__malloc_sbrk_lock);
+#endif
+ __libc_lock_init_adaptive(pthread_atfork_lock);
__pthread_reset_main_thread();
__fresetlockfiles();
+ __pthread_once_fork_child();
pthread_call_handlers(child);
} else {
+#if defined(__MALLOC_STANDARD__) || defined(__MALLOC_SIMPLE__)
+ __pthread_mutex_unlock(&__malloc_lock);
+#elif defined(__MALLOC__)
+#ifdef __UCLIBC_UCLINUX_BROKEN_MUNMAP__
+ __pthread_mutex_unlock(&__malloc_mmb_heap_lock);
+#endif
+ __pthread_mutex_unlock(&__malloc_heap_lock);
+ __pthread_mutex_unlock(&__malloc_sbrk_lock);
+#endif
+ __pthread_mutex_unlock(&pthread_atfork_lock);
+ __pthread_once_fork_parent();
pthread_call_handlers(parent);
}
return pid;
diff --git a/libpthread/linuxthreads.old/pthread.c b/libpthread/linuxthreads.old/pthread.c
index 35de4b731..e96f3ab6a 100644
--- a/libpthread/linuxthreads.old/pthread.c
+++ b/libpthread/linuxthreads.old/pthread.c
@@ -477,12 +477,12 @@ static void pthread_initialize(void)
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
sa.sa_handler = pthread_handle_sigcancel;
sigaddset(&sa.sa_mask, __pthread_sig_restart);
- // sa.sa_flags = 0;
+ /* sa.sa_flags = 0; */
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0) {
sa.sa_handler = pthread_handle_sigdebug;
sigemptyset(&sa.sa_mask);
- // sa.sa_flags = 0;
+ /* sa.sa_flags = 0; */
__libc_sigaction(__pthread_sig_debug, &sa, NULL);
}
/* Initially, block __pthread_sig_restart. Will be unblocked on demand. */
@@ -530,7 +530,7 @@ int __pthread_initialize_manager(void)
__pthread_manager_thread_bos, __pthread_manager_thread_tos);
#if 0
PDEBUG("initial stack: estimate bos=%p, tos=%p\n",
- __pthread_initial_thread_bos, __pthread_initial_thread_tos);
+ __pthread_initial_thread_bos, __pthread_initial_thread_tos);
#endif
/* Setup pipe to communicate with thread manager */
diff --git a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
index cd45d5faf..5735d0ea2 100644
--- a/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
+++ b/libpthread/linuxthreads.old/sysdeps/avr32/pt-machine.h
@@ -15,7 +15,7 @@
# define PT_EI __extern_always_inline
#endif
-static inline int
+static __inline__ int
_test_and_set (int *p, int v)
{
int result;
diff --git a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
index 740e793be..78593ac11 100644
--- a/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
+++ b/libpthread/linuxthreads.old/sysdeps/pthread/bits/libc-lock.h
@@ -30,7 +30,7 @@
/* Mutex type. */
#if defined(_LIBC) || defined(_IO_MTSAFE_IO)
typedef pthread_mutex_t __libc_lock_t;
-typedef struct { pthread_mutex_t mutex; } __libc_lock_recursive_t;
+typedef pthread_mutex_t __libc_lock_recursive_t;
# ifdef __USE_UNIX98
typedef pthread_rwlock_t __libc_rwlock_t;
# else
@@ -132,15 +132,39 @@ typedef pthread_key_t __libc_key_t;
#define __libc_rwlock_init(NAME) \
(__libc_maybe_call (__pthread_rwlock_init, (&(NAME), NULL), 0));
+/* Same as last but this time we initialize an adaptive mutex. */
+#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
+#define __libc_lock_init_adaptive(NAME) \
+ ({ \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_ADAPTIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ 0; })
+#else
+#define __libc_lock_init_adaptive(NAME) \
+ do { \
+ if (__pthread_mutex_init != NULL) \
+ { \
+ pthread_mutexattr_t __attr; \
+ __pthread_mutexattr_init (&__attr); \
+ __pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_ADAPTIVE_NP); \
+ __pthread_mutex_init (&(NAME), &__attr); \
+ __pthread_mutexattr_destroy (&__attr); \
+ } \
+ } while (0);
+#endif
+
/* Same as last but this time we initialize a recursive mutex. */
#if defined _LIBC && !defined NOT_IN_libc && defined SHARED
#define __libc_lock_init_recursive(NAME) \
({ \
- (NAME).mutex.__m_count = 0; \
- (NAME).mutex.__m_owner = NULL; \
- (NAME).mutex.__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
- (NAME).mutex.__m_lock.__status = 0; \
- (NAME).mutex.__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
+ (NAME).__m_count = 0; \
+ (NAME).__m_owner = NULL; \
+ (NAME).__m_kind = PTHREAD_MUTEX_RECURSIVE_NP; \
+ (NAME).__m_lock.__status = 0; \
+ (NAME).__m_lock.__spinlock = __LT_SPINLOCK_INIT; \
0; })
#else
#define __libc_lock_init_recursive(NAME) \
@@ -150,7 +174,7 @@ typedef pthread_key_t __libc_key_t;
pthread_mutexattr_t __attr; \
__pthread_mutexattr_init (&__attr); \
__pthread_mutexattr_settype (&__attr, PTHREAD_MUTEX_RECURSIVE_NP); \
- __pthread_mutex_init (&(NAME).mutex, &__attr); \
+ __pthread_mutex_init (&(NAME), &__attr); \
__pthread_mutexattr_destroy (&__attr); \
} \
} while (0);
diff --git a/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch b/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch
index e4cb95b76..bf57e803c 100644
--- a/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch
+++ b/libpthread/linuxthreads.old/sysdeps/sh64/Makefile.arch
@@ -1,7 +1,7 @@
# Makefile for uClibc
#
# Copyright (C) 2003 Paul Mundt <lethal@linux-sh.org>
-# Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
+# Copyright (C) 2000-2008 Erik Andersen <andersen@uclibc.org>
#
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
@@ -27,4 +27,4 @@ $(libpthread_ARCH_OBJ:.o=.os): %.os : %.c
$(compile.c:32media=compact)
libpthread_arch_objclean:
- $(RM) $(libpthread_ARCH_OUT)/*.{o,os}
+ $(do_rm) $(addprefix $(libpthread_ARCH_OUT)/*., o os)
diff --git a/libpthread/linuxthreads.old/wrapsyscall.c b/libpthread/linuxthreads.old/wrapsyscall.c
index c1ddcb8fe..713e7e548 100644
--- a/libpthread/linuxthreads.old/wrapsyscall.c
+++ b/libpthread/linuxthreads.old/wrapsyscall.c
@@ -96,7 +96,8 @@ CANCELABLE_SYSCALL (off64_t, lseek64, (int fd, off64_t offset, int whence),
(fd, offset, whence))
#endif
-#ifdef __NR_msync
+#if defined(__NR_msync) && defined(__ARCH_USE_MMU__)
+
/* msync(2). */
CANCELABLE_SYSCALL (int, msync, (void *addr, size_t length, int flags),
(addr, length, flags))
@@ -182,7 +183,7 @@ libpthread_hidden_def(waitpid)
CANCELABLE_SYSCALL (ssize_t, write, (int fd, const void *buf, size_t n),
(fd, buf, n))
-
+#if defined __UCLIBC_HAS_SOCKET__
/* The following system calls are thread cancellation points specified
in XNS. */
@@ -224,3 +225,4 @@ CANCELABLE_SYSCALL (ssize_t, sendto, (int fd, const __ptr_t buf, size_t n,
int flags, __CONST_SOCKADDR_ARG addr,
socklen_t addr_len),
(fd, buf, n, flags, addr, addr_len))
+#endif /* __UCLIBC_HAS_SOCKET__ */