summaryrefslogtreecommitdiffstats
path: root/libpthread/linuxthreads
diff options
context:
space:
mode:
author"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-23 22:10:27 +0000
committer"Steven J. Hill" <sjhill@realitydiluted.com>2005-07-23 22:10:27 +0000
commit1d2230a7d275706c5f0de850e15527aae3744310 (patch)
tree55f15700b16f705aa953d5c4051b2e63ca72041a /libpthread/linuxthreads
parent6fa52ec791e030081b7102f50222a13af7fa0d49 (diff)
downloaduClibc-alpine-1d2230a7d275706c5f0de850e15527aae3744310.tar.bz2
uClibc-alpine-1d2230a7d275706c5f0de850e15527aae3744310.tar.xz
Merge from trunk.
Diffstat (limited to 'libpthread/linuxthreads')
-rw-r--r--libpthread/linuxthreads/Makefile3
-rw-r--r--libpthread/linuxthreads/debug.h8
-rw-r--r--libpthread/linuxthreads/join.c10
-rw-r--r--libpthread/linuxthreads/manager.c40
-rw-r--r--libpthread/linuxthreads/pthread.c9
-rw-r--r--libpthread/linuxthreads/spinlock.c2
-rw-r--r--libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h38
-rw-r--r--libpthread/linuxthreads/sysdeps/x86_64/tls.h9
8 files changed, 51 insertions, 68 deletions
diff --git a/libpthread/linuxthreads/Makefile b/libpthread/linuxthreads/Makefile
index 2929544ed..cca65d51c 100644
--- a/libpthread/linuxthreads/Makefile
+++ b/libpthread/linuxthreads/Makefile
@@ -33,14 +33,15 @@ SYSDEPS_DIR:=$(TARGET_ARCH)/sparc32
else
SYSDEPS_DIR:=$(TARGET_ARCH)
endif
+CFLAGS += $(SSP_ALL_CFLAGS)
#This stuff will not compile without at least -O1
CFLAGS :=$(CFLAGS:-O0=-O1)
# set up system dependencies include dirs (NOTE: order matters!)
+PTDIR = $(TOPDIR)libpthread/linuxthreads/
SYSDEPINC = -I$(PTDIR)sysdeps/pthread \
-I$(PTDIR)sysdeps/$(TARGET_ARCH) \
- -I$(PTDIR)sysdeps \
-I$(TOPDIR)libc/sysdeps/linux/$(TARGET_ARCH)
CFLAGS += $(SYSDEPINC)
diff --git a/libpthread/linuxthreads/debug.h b/libpthread/linuxthreads/debug.h
index 79acb23c0..a2ac5113a 100644
--- a/libpthread/linuxthreads/debug.h
+++ b/libpthread/linuxthreads/debug.h
@@ -23,13 +23,19 @@
#ifndef _PT_DEBUG_H
#define _PT_DEBUG_H
+#include <features.h>
+
+#ifdef __DODEBUG_PT__
+# define DEBUG_PT
+#endif
+
/* include asserts for now */
#define DO_ASSERT
/* define the PDEBUG macro here */
#undef PDEBUG
#ifdef DEBUG_PT
-# define PDEBUG(fmt, args...) __pthread_message(__FUNCTION__": " fmt, ## args)
+# define PDEBUG(fmt, args...) __pthread_message("%s: " fmt, __FUNCTION__, ## args)
#else
# define PDEBUG(fmt, args...) /* debug switched off */
#endif
diff --git a/libpthread/linuxthreads/join.c b/libpthread/linuxthreads/join.c
index f6c0e602c..5aeec6a20 100644
--- a/libpthread/linuxthreads/join.c
+++ b/libpthread/linuxthreads/join.c
@@ -31,7 +31,7 @@ void pthread_exit(void * retval)
pthread_descr self = thread_self();
pthread_descr joining;
struct pthread_request request;
-PDEBUG("self=%p, pid=%d\n", self, self->p_pid);
+ PDEBUG("self=%p, pid=%d\n", self, self->p_pid);
/* Reset the cancellation flag to avoid looping if the cleanup handlers
contain cancellation points */
@@ -67,7 +67,7 @@ PDEBUG("self=%p, pid=%d\n", self, self->p_pid);
THREAD_SETMEM(self, p_terminated, 1);
/* See if someone is joining on us */
joining = THREAD_GETMEM(self, p_joining);
-PDEBUG("joining = %p, pid=%d\n", joining, joining->p_pid);
+ PDEBUG("joining = %p, pid=%d\n", joining, joining->p_pid);
__pthread_unlock(THREAD_GETMEM(self, p_lock));
/* Restart joining thread if any */
if (joining != NULL) restart(joining);
@@ -117,7 +117,7 @@ int pthread_join(pthread_t thread_id, void ** thread_return)
pthread_descr th;
pthread_extricate_if extr;
int already_canceled = 0;
-PDEBUG("\n");
+ PDEBUG("\n");
/* Set up extrication interface */
extr.pu_object = handle;
@@ -154,9 +154,9 @@ PDEBUG("\n");
pthread_exit(PTHREAD_CANCELED);
}
-PDEBUG("before suspend\n");
+ PDEBUG("before suspend\n");
suspend(self);
-PDEBUG("after suspend\n");
+ PDEBUG("after suspend\n");
/* Deregister extrication interface */
__pthread_set_own_extricate_if(self, 0);
diff --git a/libpthread/linuxthreads/manager.c b/libpthread/linuxthreads/manager.c
index 11ec6f18c..204344aef 100644
--- a/libpthread/linuxthreads/manager.c
+++ b/libpthread/linuxthreads/manager.c
@@ -165,9 +165,9 @@ int __pthread_manager(void *arg)
FD_SET (reqfd, &fd);
n = select (reqfd + 1, &fd, NULL, NULL, &tv);
#else
-PDEBUG("before poll\n");
+ PDEBUG("before poll\n");
n = poll(&ufd, 1, 2000);
-PDEBUG("after poll\n");
+ PDEBUG("after poll\n");
#endif
/* Check for termination of the main thread */
if (getppid() == 1) {
@@ -187,13 +187,13 @@ PDEBUG("after poll\n");
#endif
{
-PDEBUG("before __libc_read\n");
+ PDEBUG("before __libc_read\n");
n = __libc_read(reqfd, (char *)&request, sizeof(request));
-PDEBUG("after __libc_read, n=%d\n", n);
+ PDEBUG("after __libc_read, n=%d\n", n);
ASSERT(n == sizeof(request));
switch(request.req_kind) {
case REQ_CREATE:
-PDEBUG("got REQ_CREATE\n");
+ PDEBUG("got REQ_CREATE\n");
request.req_thread->p_retcode =
pthread_handle_create((pthread_t *) &request.req_thread->p_retval,
request.req_args.create.attr,
@@ -201,23 +201,23 @@ PDEBUG("got REQ_CREATE\n");
request.req_args.create.arg,
&request.req_args.create.mask,
request.req_thread->p_pid,
- request.req_thread->p_report_events,
- &request.req_thread->p_eventbuf.eventmask);
-PDEBUG("restarting %d\n", request.req_thread);
+ request.req_thread->p_report_events,
+ &request.req_thread->p_eventbuf.eventmask);
+ PDEBUG("restarting %d\n", request.req_thread);
restart(request.req_thread);
break;
case REQ_FREE:
-PDEBUG("got REQ_FREE\n");
- pthread_handle_free(request.req_args.free.thread_id);
+ PDEBUG("got REQ_FREE\n");
+ pthread_handle_free(request.req_args.free.thread_id);
break;
case REQ_PROCESS_EXIT:
-PDEBUG("got REQ_PROCESS_EXIT from %d, exit code = %d\n",
- request.req_thread, request.req_args.exit.code);
+ PDEBUG("got REQ_PROCESS_EXIT from %d, exit code = %d\n",
+ request.req_thread, request.req_args.exit.code);
pthread_handle_exit(request.req_thread,
request.req_args.exit.code);
break;
case REQ_MAIN_THREAD_EXIT:
-PDEBUG("got REQ_MAIN_THREAD_EXIT\n");
+ PDEBUG("got REQ_MAIN_THREAD_EXIT\n");
main_thread_exiting = 1;
/* Reap children in case all other threads died and the signal handler
went off before we set main_thread_exiting to 1, and therefore did
@@ -233,15 +233,15 @@ PDEBUG("got REQ_MAIN_THREAD_EXIT\n");
}
break;
case REQ_POST:
-PDEBUG("got REQ_POST\n");
+ PDEBUG("got REQ_POST\n");
__new_sem_post(request.req_args.post);
break;
case REQ_DEBUG:
-PDEBUG("got REQ_DEBUG\n");
+ PDEBUG("got REQ_DEBUG\n");
/* Make gdb aware of new thread and gdb will restart the
new thread when it is ready to handle the new thread. */
if (__pthread_threads_debug && __pthread_sig_debug > 0) {
-PDEBUG("about to call raise(__pthread_sig_debug)\n");
+ PDEBUG("about to call raise(__pthread_sig_debug)\n");
raise(__pthread_sig_debug);
}
case REQ_KICK:
@@ -280,7 +280,7 @@ pthread_start_thread(void *arg)
#ifdef INIT_THREAD_SELF
INIT_THREAD_SELF(self, self->p_nr);
#endif
-PDEBUG("\n");
+ 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());
@@ -608,7 +608,7 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
}
if (pid == 0)
{
-PDEBUG("cloning new_thread = %p\n", new_thread);
+ PDEBUG("cloning new_thread = %p\n", new_thread);
pid = clone(pthread_start_thread, (void **) new_thread,
CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND |
__pthread_sig_cancel, new_thread);
@@ -641,7 +641,7 @@ PDEBUG("cloning new_thread = %p\n", new_thread);
__pthread_handles_num--;
return errno;
}
-PDEBUG("new thread pid = %d\n", pid);
+ PDEBUG("new thread pid = %d\n", pid);
#if 0
/* ***********************************************************
@@ -783,7 +783,7 @@ static void pthread_reap_children(void)
{
pid_t pid;
int status;
-PDEBUG("\n");
+ PDEBUG("\n");
while ((pid = __libc_waitpid(-1, &status, WNOHANG | __WCLONE)) > 0) {
pthread_exited(pid);
diff --git a/libpthread/linuxthreads/pthread.c b/libpthread/linuxthreads/pthread.c
index afc785d14..fed3d8c72 100644
--- a/libpthread/linuxthreads/pthread.c
+++ b/libpthread/linuxthreads/pthread.c
@@ -376,6 +376,7 @@ static void pthread_initialize(void)
sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_restart, &sa, NULL);
sa.sa_handler = pthread_handle_sigcancel;
+ sigaddset(&sa.sa_mask, __pthread_sig_restart);
// sa.sa_flags = 0;
__libc_sigaction(__pthread_sig_cancel, &sa, NULL);
if (__pthread_sig_debug > 0) {
@@ -512,7 +513,7 @@ int __pthread_initialize_manager(void)
__pthread_wait_for_restart_signal(thread_self());
}
/* Synchronize debugging of the thread manager */
-PDEBUG("send REQ_DEBUG to manager thread\n");
+ PDEBUG("send REQ_DEBUG to manager thread\n");
request.req_kind = REQ_DEBUG;
TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
(char *) &request, sizeof(request)));
@@ -539,9 +540,9 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
PDEBUG("write REQ_CREATE to manager thread\n");
TEMP_FAILURE_RETRY(__libc_write(__pthread_manager_request,
(char *) &request, sizeof(request)));
-PDEBUG("before suspend(self)\n");
+ PDEBUG("before suspend(self)\n");
suspend(self);
-PDEBUG("after suspend(self)\n");
+ PDEBUG("after suspend(self)\n");
if (THREAD_GETMEM(self, p_retcode) == 0)
*thread = (pthread_t) THREAD_GETMEM(self, p_retval);
return THREAD_GETMEM(self, p_retcode);
@@ -576,7 +577,7 @@ pthread_descr __pthread_find_self()
#ifdef DEBUG_PT
if (h->h_descr == NULL) {
- printf("*** "__FUNCTION__" ERROR descriptor is NULL!!!!! ***\n\n");
+ printf("*** %s ERROR descriptor is NULL!!!!! ***\n\n", __FUNCTION__);
_exit(1);
}
#endif
diff --git a/libpthread/linuxthreads/spinlock.c b/libpthread/linuxthreads/spinlock.c
index 5d4bd20e4..c0e7a368f 100644
--- a/libpthread/linuxthreads/spinlock.c
+++ b/libpthread/linuxthreads/spinlock.c
@@ -32,7 +32,7 @@ static inline void __pthread_release(int * spinlock)
{
WRITE_MEMORY_BARRIER();
*spinlock = __LT_SPINLOCK_INIT;
- __asm __volatile ("" : "=m" (*spinlock) : "0" (*spinlock));
+ __asm __volatile ("" : "=m" (*spinlock) : "m" (*spinlock));
}
diff --git a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
index d1daef07a..db4c3790c 100644
--- a/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
+++ b/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
@@ -25,9 +25,8 @@
/* Fast locks (not abstract because mutexes and conditions aren't abstract). */
struct _pthread_fastlock
{
- long int __status; /* "Free" or "taken" or head of waiting list */
- int __spinlock; /* Used by compare_and_swap emulation. Also,
- adaptive SMP lock stores spin count here. */
+ long int __status; /* "Free" or "taken" or head of waiting list */
+ int __spinlock; /* For compare-and-swap emulation */
};
#ifndef _PTHREAD_DESCR_DEFINED
@@ -38,7 +37,7 @@ typedef struct _pthread_descr_struct *_pthread_descr;
/* Attributes for threads. */
-typedef struct __pthread_attr_s
+typedef struct
{
int __detachstate;
int __schedpolicy;
@@ -53,20 +52,10 @@ typedef struct __pthread_attr_s
/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
-
-#ifdef __GLIBC_HAVE_LONG_LONG
-__extension__ typedef long long __pthread_cond_align_t;
-#else
-typedef long __pthread_cond_align_t;
-#endif
-
typedef struct
{
struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
_pthread_descr __c_waiting; /* Threads waiting on this condition */
- char __padding[48 - sizeof (struct _pthread_fastlock)
- - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
- __pthread_cond_align_t __align;
} pthread_cond_t;
@@ -104,7 +93,7 @@ typedef struct
typedef int pthread_once_t;
-#if defined __USE_UNIX98 || defined __USE_XOPEN2K
+#ifdef __USE_UNIX98
/* Read-write locks. */
typedef struct _pthread_rwlock_t
{
@@ -126,25 +115,6 @@ typedef struct
} pthread_rwlockattr_t;
#endif
-#ifdef __USE_XOPEN2K
-/* POSIX spinlock data type. */
-typedef volatile int pthread_spinlock_t;
-
-/* POSIX barrier. */
-typedef struct {
- struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
- int __ba_required; /* Threads needed for completion */
- int __ba_present; /* Threads waiting */
- _pthread_descr __ba_waiting; /* Queue of waiting threads */
-} pthread_barrier_t;
-
-/* barrier attribute */
-typedef struct {
- int __pshared;
-} pthread_barrierattr_t;
-
-#endif
-
/* Thread identifiers */
typedef unsigned long int pthread_t;
diff --git a/libpthread/linuxthreads/sysdeps/x86_64/tls.h b/libpthread/linuxthreads/sysdeps/x86_64/tls.h
index 63feebdb2..d67275c10 100644
--- a/libpthread/linuxthreads/sysdeps/x86_64/tls.h
+++ b/libpthread/linuxthreads/sysdeps/x86_64/tls.h
@@ -1,5 +1,5 @@
/* Definitions for thread-local data handling. linuxthreads/x86-64 version.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -23,13 +23,18 @@
#ifndef __ASSEMBLER__
# include <pt-machine.h>
+# include <stdbool.h>
# include <stddef.h>
/* Type for the dtv. */
typedef union dtv
{
size_t counter;
- void *pointer;
+ struct
+ {
+ void *val;
+ bool is_static;
+ } pointer;
} dtv_t;