aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-06-29 12:44:22 +0000
committerUlrich Drepper <drepper@redhat.com>1998-06-29 12:44:22 +0000
commitfdacb17d4819c7112a147195c5ce3c82147f4b46 (patch)
treed1c400488d3bc8dfe707645a0fc38916e223614c /linuxthreads
parentba488034eabd1affd6b4b3e8838abde0f4d0504e (diff)
downloadglibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.zip
glibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.tar.gz
glibc-fdacb17d4819c7112a147195c5ce3c82147f4b46.tar.bz2
Update.
1998-06-29 12:27 Ulrich Drepper <drepper@cygnus.com> * argp/argp.h: Use __PMT instead of __P for function pointer. * iconv/gconv.h: Likewise. * io/fts.h: Likewise. * io/ftw.h: Likewise. * libio/libio.h: Likewise. * malloc/mcheck.h: Likewise. * misc/search.h: Likewise. * posix/glob.h: Likewise. * resolv/resolv.h: Likewise. * signal/signal.h: Likewise. * stdlib/stdlib.h: Likewise. * sysdeps/unix/sysv/linux/bits/sigaction.h: Likewise. * sysdeps/unix/sysv/linux/bits/siginfo.h: Likewise. 1998-06-26 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makeconfig (CPPFLAGS): Use $($(subdir)-CPPFLAGS) only once. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/wordexp.c (parse_param): Fix memory leak. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * libc.map: Export _IO_ftrylockfile. 1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/aio_sigqueue.c: Use get[pu]id instead of __get[pu]id. 1998-06-28 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * elf/dl-misc.c (_dl_debug_message): Don't cache the pid. * elf/dl-runtime.c (_dl_object_relocation_scope): Avoid adding the same search list twice. 1998-06-29 Andreas Jaeger <aj@arthur.rhein-neckar.de> * login/programs/utmpd.c (handle_requests): Set and use maximal fd used to optimize loop/select. 1998-06-24 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/init-first.c: Don't define __libc_pid. * sysdeps/unix/sysv/linux/init-first.c: Likewise. * sysdeps/mach/hurd/i386/init-first.c: Likewise. * sysdeps/mach/hurd/mips/init-first.c: Likewise. * sysdeps/arm/init-first.c: Likewise. * posix/getopt_init.c: Don't use __libc_pid. * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/sigqueue.c: Likewise. * libc.map: Remove __libc_uid and __libc_pid.
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog27
-rw-r--r--linuxthreads/internals.h6
-rw-r--r--linuxthreads/join.c4
-rw-r--r--linuxthreads/libpthread.map18
-rw-r--r--linuxthreads/manager.c61
-rw-r--r--linuxthreads/pthread.c5
-rw-r--r--linuxthreads/sysdeps/pthread/pthread.h26
7 files changed, 83 insertions, 64 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index ead990b..05c842a 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,30 @@
+1998-06-29 12:34 Ulrich Drepper <drepper@cygnus.com>
+
+ * sysdeps/pthread/pthread.h: Use __PMT not __P for function pointers.
+
+ * sysdeps/pthread/pthread.h: Define various PTHREAD_* symbols also
+ as macros as demanded in POSIX.1, Annex C.
+
+1998-06-29 12:29 Ulrich Drepper <drepper@cygnus.com>
+
+ * internals.h (struct pthread_request): For free use pthread_t
+ instead of pthread_descr.
+ * join.c (pthread_join): Pass thread_id, not th to manager.
+ (pthread_detach): Likewise.
+ * manager.c (__pthread_manager): Except thread ID in FREE_REQ case.
+ (pthread_exited): Remove detached queue code.
+ (pthread_handle_free): Expect thread ID parameter and use it to
+ validate the thread decsriptor. Don't use detached queue.
+ Patches by Xavier Leroy.
+
+1998-06-27 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * libpthread.map: Export accept, longjmp, sigaction, siglongjmp,
+ _IO_flockfile, _IO_ftrylockfile, _IO_funlockfile,
+ __pthread_atfork, __pthread_key_create, __pthread_once.
+ * internals.h: Doc fix.
+ * pthread.c (__pthread_initialize): Define again.
+
1998-06-26 Ulrich Drepper <drepper@cygnus.com>
* manager.c (pthread_exited): If thread is not detached put it on
diff --git a/linuxthreads/internals.h b/linuxthreads/internals.h
index 0a01b61..9d6f2fa 100644
--- a/linuxthreads/internals.h
+++ b/linuxthreads/internals.h
@@ -86,7 +86,7 @@ struct _pthread_descr_struct {
struct pthread_start_args p_start_args; /* arguments for thread creation */
void ** p_specific[PTHREAD_KEY_1STLEVEL_SIZE]; /* thread-specific data */
void * p_libc_specific[_LIBC_TSD_KEY_N]; /* thread-specific data for libc */
- int p_userstack; /* nonzero if the user provided the thread */
+ int p_userstack; /* nonzero if the user provided the stack */
void *p_guardaddr; /* address of guard area or NULL */
size_t p_guardsize; /* size of guard area */
};
@@ -117,7 +117,7 @@ struct pthread_request {
sigset_t mask; /* signal mask */
} create;
struct { /* For REQ_FREE: */
- pthread_descr thread; /* descriptor of thread to free */
+ pthread_t thread_id; /* identifier of thread to free */
} free;
struct { /* For REQ_PROCESS_EXIT: */
int code; /* exit status */
@@ -171,7 +171,7 @@ extern char *__pthread_initial_thread_bos;
extern int __pthread_nonstandard_stacks;
/* File descriptor for sending requests to the thread manager.
- Initially -1, meaning that pthread_initialize must be called. */
+ Initially -1, meaning that __pthread_initialize_manager must be called. */
extern int __pthread_manager_request;
diff --git a/linuxthreads/join.c b/linuxthreads/join.c
index c59de69..4fadd85 100644
--- a/linuxthreads/join.c
+++ b/linuxthreads/join.c
@@ -99,7 +99,7 @@ int pthread_join(pthread_t thread_id, void ** thread_return)
if (__pthread_manager_request >= 0) {
request.req_thread = self;
request.req_kind = REQ_FREE;
- request.req_args.free.thread = th;
+ request.req_args.free.thread_id = thread_id;
__libc_write(__pthread_manager_request,
(char *) &request, sizeof(request));
}
@@ -137,7 +137,7 @@ int pthread_detach(pthread_t thread_id)
if (terminated && __pthread_manager_request >= 0) {
request.req_thread = thread_self();
request.req_kind = REQ_FREE;
- request.req_args.free.thread = th;
+ request.req_args.free.thread_id = thread_id;
__libc_write(__pthread_manager_request,
(char *) &request, sizeof(request));
}
diff --git a/linuxthreads/libpthread.map b/linuxthreads/libpthread.map
index b7dd167..8174f7d 100644
--- a/linuxthreads/libpthread.map
+++ b/linuxthreads/libpthread.map
@@ -8,11 +8,13 @@ GLIBC_2.0 {
__libc_internal_tsd_get; __libc_internal_tsd_set;
# Overwritten libc functions.
- close; connect; fcntl; fork; fsync; lseek; msync; nanosleep; open;
- pause; raise; read; recv; recvfrom; recvmsg; send; sendmsg; sendto;
- system; tcdrain; wait; waitpid; write;
+ accept; close; connect; fcntl; fork; fsync; longjmp; lseek; msync;
+ nanosleep; open; pause; raise; read; recv; recvfrom; recvmsg; send;
+ sendmsg; sendto; sigaction; siglongjmp; system; tcdrain; wait;
+ waitpid; write;
__close; __connect; __fcntl; __lseek; __open; __read; __send; __wait;
__write;
+ _IO_flockfile; _IO_ftrylockfile; _IO_funlockfile;
# POSIX.1c extensions to libc.
flockfile; funlockfile; ftrylockfile;
@@ -43,11 +45,11 @@ GLIBC_2.0 {
sigwait;
# Protected names for functions used in other shared objects.
- __pthread_getspecific; __pthread_initialize; __pthread_mutex_destroy;
- __pthread_mutex_init; __pthread_mutex_lock; __pthread_mutex_trylock;
- __pthread_mutex_unlock; __pthread_mutexattr_destroy;
- __pthread_mutexattr_init; __pthread_mutexattr_setkind_np;
- __pthread_setspecific;
+ __pthread_atfork; __pthread_initialize; __pthread_getspecific;
+ __pthread_key_create; __pthread_mutex_destroy; __pthread_mutex_init;
+ __pthread_mutex_lock; __pthread_mutex_trylock; __pthread_mutex_unlock;
+ __pthread_mutexattr_destroy; __pthread_mutexattr_init;
+ __pthread_mutexattr_setkind_np; __pthread_once; __pthread_setspecific;
# The error functions.
__errno_location; __h_errno_location;
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index 39c103c..e69abac 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -37,12 +37,6 @@
struct pthread_handle_struct __pthread_handles[PTHREAD_THREADS_MAX] =
{ { LOCK_INITIALIZER, &__pthread_initial_thread, 0}, /* All NULLs */ };
-/* This is a list of terminated, but not detached threads. This can happen
- when pthread_join() is called and the pthread_reap_children() function
- removes the thread from the live list before processing the FREE_REQ
- request. */
-static pthread_descr non_detached;
-
/* Indicate whether at least one thread has a user-defined stack (if 1),
or if all threads have stacks supplied by LinuxThreads (if 0). */
int __pthread_nonstandard_stacks = 0;
@@ -83,7 +77,7 @@ static pthread_t pthread_threads_counter = 0;
static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
void * (*start_routine)(void *), void *arg,
sigset_t *mask, int father_pid);
-static void pthread_handle_free(pthread_descr th);
+static void pthread_handle_free(pthread_t th_id);
static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode);
static void pthread_reap_children(void);
static void pthread_kill_all_threads(int sig, int main_thread_also);
@@ -149,7 +143,7 @@ int __pthread_manager(void *arg)
restart(request.req_thread);
break;
case REQ_FREE:
- pthread_handle_free(request.req_args.free.thread);
+ pthread_handle_free(request.req_args.free.thread_id);
break;
case REQ_PROCESS_EXIT:
pthread_handle_exit(request.req_thread,
@@ -406,14 +400,6 @@ static void pthread_exited(pid_t pid)
__pthread_unlock(th->p_lock);
if (detached)
pthread_free(th);
- else {
- /* Enqueue in the detached list. */
- th->p_nextlive = non_detached;
- if (non_detached != NULL)
- non_detached->p_prevlive = th;
- th->p_prevlive = NULL;
- non_detached = th;
- }
break;
}
}
@@ -445,49 +431,28 @@ static void pthread_reap_children(void)
/* Try to free the resources of a thread when requested by pthread_join
or pthread_detach on a terminated thread. */
-static void pthread_handle_free(pthread_descr th)
+static void pthread_handle_free(pthread_t th_id)
{
- pthread_descr t;
- /* Check that the thread th is still there -- pthread_reap_children
- might have deallocated it already */
- t = __pthread_main_thread;
- do {
- if (t == th) break;
- t = t->p_nextlive;
- } while (t != __pthread_main_thread);
- if (t != th) {
- /* Hum, it might be that the thread already was dequeued but
- wasn't detached. In the case the thread is already detached
- and we cannot find it this is a user bug but we must be
- gracious. */
- t = non_detached;
- while (t != NULL) {
- if (t == th) break;
- t = t->p_nextlive;
- }
- if (t == th) {
- if (th->p_prevlive == NULL)
- non_detached = th->p_nextlive;
- else
- th->p_prevlive->p_nextlive = th->p_nextlive;
- if (th->p_nextlive != NULL)
- th->p_nextlive->p_prevlive = th->p_prevlive;
+ pthread_handle handle = thread_handle(th_id);
+ pthread_descr th;
- /* Finally free it. */
- pthread_free (th);
- }
+ __pthread_lock(&handle->h_lock);
+ if (invalid_handle(handle, th_id)) {
+ /* pthread_reap_children has deallocated the thread already,
+ nothing needs to be done */
+ __pthread_unlock(&handle->h_lock);
return;
}
- __pthread_lock(th->p_lock);
+ th = handle->h_descr;
if (th->p_exited) {
- __pthread_unlock(th->p_lock);
+ __pthread_unlock(&handle->h_lock);
pthread_free(th);
} else {
/* The Unix process of the thread is still running.
Mark the thread as detached so that the thread manager will
deallocate its resources when the Unix process exits. */
th->p_detached = 1;
- __pthread_unlock(th->p_lock);
+ __pthread_unlock(&handle->h_lock);
}
}
diff --git a/linuxthreads/pthread.c b/linuxthreads/pthread.c
index e95b352..4e8a9f1 100644
--- a/linuxthreads/pthread.c
+++ b/linuxthreads/pthread.c
@@ -215,6 +215,11 @@ static void pthread_initialize(void)
__on_exit(pthread_exit_process, NULL);
}
+void __pthread_initialize(void)
+{
+ pthread_initialize();
+}
+
int __pthread_initialize_manager(void)
{
int manager_pipe[2];
diff --git a/linuxthreads/sysdeps/pthread/pthread.h b/linuxthreads/sysdeps/pthread/pthread.h
index b76c4a8..7e98123 100644
--- a/linuxthreads/sysdeps/pthread/pthread.h
+++ b/linuxthreads/sysdeps/pthread/pthread.h
@@ -100,19 +100,25 @@ typedef struct
enum
{
PTHREAD_CREATE_JOINABLE,
+#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
PTHREAD_CREATE_DETACHED
+#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
};
enum
{
PTHREAD_INHERIT_SCHED,
+#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
PTHREAD_EXPLICIT_SCHED
+#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
};
enum
{
PTHREAD_SCOPE_SYSTEM,
+#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
PTHREAD_SCOPE_PROCESS
+#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
};
typedef struct
@@ -156,7 +162,9 @@ typedef struct
enum
{
PTHREAD_PROCESS_PRIVATE,
+# define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
PTHREAD_PROCESS_SHARED
+# define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
};
enum
@@ -187,7 +195,7 @@ typedef int pthread_once_t;
struct _pthread_cleanup_buffer
{
- void (*routine) __P ((void *)); /* Function to call. */
+ void (*routine) __PMT ((void *)); /* Function to call. */
void *arg; /* Its argument. */
int canceltype; /* Saved cancellation type. */
struct _pthread_cleanup_buffer *prev; /* Chaining of cleanup functions. */
@@ -195,8 +203,20 @@ struct _pthread_cleanup_buffer
/* Cancellation */
-enum { PTHREAD_CANCEL_ENABLE, PTHREAD_CANCEL_DISABLE };
-enum { PTHREAD_CANCEL_DEFERRED, PTHREAD_CANCEL_ASYNCHRONOUS };
+enum
+{
+ PTHREAD_CANCEL_ENABLE,
+#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
+ PTHREAD_CANCEL_DISABLE
+#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
+};
+enum
+{
+ PTHREAD_CANCEL_DEFERRED,
+#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
+ PTHREAD_CANCEL_ASYNCHRONOUS
+#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
+};
#define PTHREAD_CANCELED ((void *) -1)