aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-12-18 01:38:17 +0000
committerUlrich Drepper <drepper@redhat.com>2002-12-18 01:38:17 +0000
commit82f81a9086320d12eb2fc45766203954b90461a2 (patch)
treeb2c668e5ee6bc1e9c4176cee394ac7f37b382617 /linuxthreads
parentf077a4a9f027b938bd091583e3ec34725cba428c (diff)
downloadglibc-82f81a9086320d12eb2fc45766203954b90461a2.tar.xz
glibc-82f81a9086320d12eb2fc45766203954b90461a2.zip
Update.
* sysdeps/unix/sysv/linux/alpha/syscalls.list (msgrcv, msgsnd): Make cancelable. * sysdeps/unix/sysv/linux/hppa/syscalls.list (msgrcv, msgsnd): Likewise. * sysdeps/unix/sysv/linux/ia64/syscalls.list (msgrcv, msgsnd): Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list (msgrcv, msgsnd): Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list (msgrcv, msgsnd): Likewise. * sysdeps/unix/sysv/linux/ia64/sigsuspend.c (__sigsuspend): Likewise.
Diffstat (limited to 'linuxthreads')
-rw-r--r--linuxthreads/ChangeLog119
-rw-r--r--linuxthreads/Makefile26
-rw-r--r--linuxthreads/Versions3
-rw-r--r--linuxthreads/attr.c37
-rw-r--r--linuxthreads/cancel.c43
-rw-r--r--linuxthreads/condvar.c23
-rw-r--r--linuxthreads/descr.h1
-rw-r--r--linuxthreads/forward.c146
-rw-r--r--linuxthreads/internals.h126
-rw-r--r--linuxthreads/join.c3
-rw-r--r--linuxthreads/libc-cancellation.c75
-rw-r--r--linuxthreads/libc_pthread_init.c53
-rw-r--r--linuxthreads/lockfile.c30
-rw-r--r--linuxthreads/manager.c1
-rw-r--r--linuxthreads/mutex.c5
-rw-r--r--linuxthreads/pt-allocrtsig.c50
-rw-r--r--linuxthreads/pt-system.c32
-rw-r--r--linuxthreads/pthread.c188
-rw-r--r--linuxthreads/sysdeps/pthread/bits/libc-lock.h33
-rw-r--r--linuxthreads/sysdeps/pthread/flockfile.c33
-rw-r--r--linuxthreads/sysdeps/pthread/ftrylockfile.c33
-rw-r--r--linuxthreads/sysdeps/pthread/funlockfile.c33
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/allocrtsig.c85
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/i386/sysdep-cancel.h124
-rw-r--r--linuxthreads/sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h118
-rw-r--r--linuxthreads/sysdeps/x86_64/pt-machine.h31
-rw-r--r--linuxthreads/tst-cancel-wrappers.sh96
-rw-r--r--linuxthreads/weaks.c97
-rw-r--r--linuxthreads/wrapsyscall.c233
29 files changed, 1348 insertions, 529 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index 179e247f2e..a84d4bd383 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,122 @@
+2002-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ * internals.h (__pthread_thread_self): New prototype.
+ (struct pthread_functions): Add ptr_pthread_thread_self field.
+ * pthread.c (pthread_functions): Initialize ptr_pthread_thread_self.
+ (__pthread_thread_self): New function.
+ * libc-cancellation.c (__pthread_thread_self): Add weak_extern.
+ (__libc_enable_asynccancel, __libc_disable_asynccancel): Don't
+ use thread_self() directly if not FLOATING_STACKS.
+
+2002-12-18 Jakub Jelinek <jakub@redhat.com>
+
+ * sysdeps/x86_64/pt-machine.h: Guard most of the header
+ with #ifndef __ASSEMBLER__.
+ * pthread.c (pthread_functions): Use SHLIB_COMPAT around
+ pthread_attr_init_2_0 use.
+
+2002-12-17 Jakub Jelinek <jakub@redhat.com>
+
+ * wrapsyscall.c: Removed.
+ * weaks.c: Removed.
+ * Makefile (distribute): Add tst-cancel-wrappers.sh.
+ (routines): Remove weaks. Add forward,
+ libc_pthread_init, libc-cancellation.
+ (shared-only-routines): Remove weaks. Add forward.
+ (libpthread-routines): Remove wrapsyscall.
+ Add ptw-write, ptw-read, ptw-close, ptw-fcntl, ptw-accept,
+ ptw-connect, ptw-recv, ptw-recvfrom, ptw-recvmsg, ptw-send,
+ ptw-sendmsg, ptw-sendto, ptw-fsync, ptw-lseek, ptw-lseek64,
+ ptw-llseek, ptw-msync, ptw-nanosleep, ptw-open, ptw-open64,
+ ptw-pause, ptw-pread, ptw-pread64, ptw-pwrite, ptw-pwrite64,
+ ptw-tcdrain, ptw-wait, ptw-waitpid, pt-system, pt-allocrtsig.
+ (libpthread-shared-only-routines): Add pt-allocrtsig.
+ (tests): Depend on $(objpfx)tst-cancel-wrappers.out.
+ ($(objpfx)tst-cancel-wrappers.out): New rule.
+ * sysdeps/pthread/bits/libc-lock.h: Include linuxthreads/internals.h
+ if in libc.
+ (__libc_maybe_call): In libpthread.* don't check for existance
+ of the function.
+ (__libc_maybe_call2): Define.
+ (__libc_lock_init, __libc_lock_fini, __libc_lock_lock,
+ __libc_lock_trylock, __libc_lock_unlock): Use it.
+ * sysdeps/pthread/flockfile.c: New file.
+ * sysdeps/pthread/ftrylockfile.c: New file.
+ * sysdeps/pthread/funlockfile.c: New file.
+ * sysdeps/unix/sysv/linux/i386/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/x86_64/sysdep-cancel.h: New file.
+ * sysdeps/unix/sysv/linux/allocrtsig.c: New file.
+ * libc-cancellation.c: New file.
+ * forward.c: New file.
+ * libc_pthread_init.c: New file.
+ * pt-system.c: New file.
+ * pthread.c: Remove locale.h.
+ (__pthread_manager_thread): Initialize multiple_threads.
+ (__pthread_multiple_threads): Declare.
+ (pthread_functions): New variable.
+ (__pthread_initialize_minimal): Remove __uselocale call.
+ Call __libc_pthread_init.
+ (__pthread_initialize_manager): Initialize __pthread_multiple_threads,
+ initial thread's multiple_threads and __libc_multiple_threads.
+ Check MULTIPLE_THREADS_OFFSET value. Initialize manager thread's
+ multiple_threads.
+ (pthread_setschedparam, pthread_getschedparam): Rename to __
+ prefixed variants. Add strong_alias.
+ (current_rtmin, current_rtmax, __libc_current_sigrtmin,
+ __libc_current_sigrtmax, __libc_allocate_rtsig): Remove.
+ (init_rtsigs): Use __libc_current_sigrtmin_private.
+ (pthread_initialize): Only call init_rtsigs if
+ !__ASSUME_REALTIME_SIGNALS.
+ (__pthread_require_wrappers, __pthread_require_lockfile): Remove.
+ * internals.h (__pthread_attr_destroy, __pthread_attr_setdetachstate,
+ __pthread_attr_getdetachstate, __pthread_attr_setschedparam,
+ __pthread_attr_getschedparam, __pthread_attr_setschedpolicy,
+ __pthread_attr_getschedpolicy, __pthread_attr_setinheritsched,
+ __pthread_attr_getinheritsched, __pthread_attr_setscope,
+ __pthread_attr_getscope, __pthread_cond_init,
+ __pthread_cond_destroy, __pthread_cond_wait,
+ __pthread_cond_signal, __pthread_cond_broadcast,
+ __pthread_condattr_init, __pthread_condattr_destroy,
+ __pthread_equal, __pthread_getschedparam,
+ __pthread_setschedparam, __pthread_setcancelstate,
+ __pthread_setcanceltype, __pthread_enable_asynccancel,
+ __libc_enable_asynccancel, __libc_pthread_init): New prototype.
+ (__pthread_mutex_init, __pthread_mutex_destroy,
+ __pthread_mutex_lock, __pthread_mutex_unlock,
+ __pthread_mutex_trylock): Likewise.
+ Add hidden_proto.
+ (struct pthread_functions): New type.
+ (__libc_pthread_functions): New variable.
+ (LIBC_CANCEL_ASYNC, LIBC_CANCEL_RESET): Define.
+ * descr.h (struct _pthread_descr_struct): Add
+ p_header.data.multiple_threads field.
+ * manager.c (pthread_handle_create): Initialize multiple_threads.
+ * cancel.c (__pthread_enable_asynccancel,
+ __pthread_disable_asynccancel): New functions.
+ (__pthread_provide_wrappers): Remove.
+ (pthread_setcancelstate, pthread_setcanceltype): Rename to __
+ prefixed variants. Add strong_alias.
+ * condvar.c (pthread_cond_init, pthread_cond_destroy,
+ pthread_cond_wait, pthread_cond_signal, pthread_cond_broadcast,
+ pthread_condattr_init, pthread_condattr_destroy): Likewise.
+ * join.c (pthread_exit): Likewise.
+ * attr.c (pthread_attr_destroy, pthread_attr_setdetachstate,
+ pthread_attr_getdetachstate, pthread_attr_setschedparam,
+ pthread_attr_getschedparam, pthread_attr_setschedpolicy,
+ pthread_attr_getschedpolicy, pthread_attr_setinheritsched,
+ pthread_attr_getinheritsched, pthread_attr_setscope,
+ pthread_attr_getscope): Likewise.
+ * mutex.c (__pthread_mutex_init, __pthread_mutex_destroy,
+ __pthread_mutex_lock, __pthread_mutex_unlock,
+ __pthread_mutex_trylock): Add hidden_def.
+ * Versions (libc): Add __libc_pthread_init,
+ __libc_current_sigrtmin_private, __libc_current_sigrtmax_private,
+ __libc_allocate_rtsig_private @@GLIBC_PRIVATE.
+ * lockfile.c: Remove some USE_IN_LIBIO guards.
+ (__pthread_provide_lockfile): Remove.
+ * pt-allocrtsig.c: New file.
+ * tst-cancel-wrappers.sh: New test.
+
2002-12-15 Ulrich Drepper <drepper@redhat.com>
* Versions [libpthread: GLIBC_2.3.2]: Remove creat, poll, pselect,
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index fca0137571..7c993ac0fd 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -26,20 +26,29 @@ linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
headers := pthread.h semaphore.h
distribute := internals.h queue.h restart.h spinlock.h smp.h tst-signal.sh \
- libc-tsd.c
+ tst-cancel-wrappers.sh libc-tsd.c
-routines := weaks no-tsd
-shared-only-routines = weaks
+routines := forward no-tsd libc-cancellation libc_pthread_init
+shared-only-routines = forward
extra-libs := libpthread
extra-libs-others := $(extra-libs)
libpthread-routines := attr cancel condvar join manager mutex ptfork \
ptlongjmp pthread signals specific errno lockfile \
- semaphore spinlock wrapsyscall rwlock pt-machine \
+ semaphore spinlock rwlock pt-machine \
oldsemaphore events getcpuclockid pspinlock barrier \
ptclock_gettime ptclock_settime sighandler \
- pthandles libc-tls-loc
+ pthandles libc-tls-loc pt-allocrtsig \
+ ptw-write ptw-read ptw-close ptw-fcntl ptw-accept \
+ ptw-connect ptw-recv ptw-recvfrom ptw-recvmsg \
+ ptw-send ptw-sendmsg ptw-sendto ptw-fsync ptw-lseek \
+ ptw-lseek64 ptw-llseek ptw-msync ptw-nanosleep \
+ ptw-open ptw-open64 ptw-pause ptw-pread ptw-pread64 \
+ ptw-pwrite ptw-pwrite64 ptw-tcdrain ptw-wait \
+ ptw-waitpid pt-system
+
+libpthread-shared-only-routines = pt-allocrtsig
nodelete-yes = -Wl,--enable-new-dtags,-z,nodelete
initfirst-yes = -Wl,--enable-new-dtags,-z,initfirst
@@ -194,8 +203,13 @@ endif
ifeq (no,$(cross-compiling))
ifeq (yes,$(build-shared))
-tests: $(objpfx)tst-signal.out
+tests: $(objpfx)tst-signal.out $(objpfx)tst-cancel-wrappers.out
$(objpfx)tst-signal.out: tst-signal.sh $(objpfx)tst-signal
$(SHELL) -e $< $(common-objpfx) > $@
+$(objpfx)tst-cancel-wrappers.out: tst-cancel-wrappers.sh
+ $(SHELL) $< $(common-objpfx)/libc_pic.a \
+ $(common-objpfx)/libc.a \
+ $(objpfx)/libpthread_pic.a \
+ $(objpfx)/libpthread.a > $@
endif
endif
diff --git a/linuxthreads/Versions b/linuxthreads/Versions
index 78b1a937cf..fea2e368d8 100644
--- a/linuxthreads/Versions
+++ b/linuxthreads/Versions
@@ -22,6 +22,9 @@ libc {
__libc_internal_tsd_address; __libc_alloca_cutoff;
__libc_dl_error_tsd;
+ __libc_pthread_init; __libc_current_sigrtmin_private;
+ __libc_current_sigrtmax_private; __libc_allocate_rtsig_private;
+
__libc_creat; __libc_poll; __libc_pselect; __libc_select;
__libc_sigpause; __libc_sigsuspend; __libc_sigwait; __libc_sigwaitinfo;
__libc_waitid; __libc___xpg_sigpause;
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index 8b7e8ce81c..58a7b69f94 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -56,12 +56,13 @@ compat_symbol (libpthread, __pthread_attr_init_2_0, pthread_attr_init,
GLIBC_2_0);
#endif
-int pthread_attr_destroy(pthread_attr_t *attr)
+int __pthread_attr_destroy(pthread_attr_t *attr)
{
return 0;
}
+strong_alias (__pthread_attr_destroy, pthread_attr_destroy);
-int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
+int __pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
{
if (detachstate < PTHREAD_CREATE_JOINABLE ||
detachstate > PTHREAD_CREATE_DETACHED)
@@ -69,15 +70,17 @@ int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
attr->__detachstate = detachstate;
return 0;
}
+strong_alias (__pthread_attr_setdetachstate, pthread_attr_setdetachstate);
-int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
+int __pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)
{
*detachstate = attr->__detachstate;
return 0;
}
+strong_alias (__pthread_attr_getdetachstate, pthread_attr_getdetachstate);
-int pthread_attr_setschedparam(pthread_attr_t *attr,
- const struct sched_param *param)
+int __pthread_attr_setschedparam(pthread_attr_t *attr,
+ const struct sched_param *param)
{
int max_prio = __sched_get_priority_max(attr->__schedpolicy);
int min_prio = __sched_get_priority_min(attr->__schedpolicy);
@@ -87,43 +90,49 @@ int pthread_attr_setschedparam(pthread_attr_t *attr,
memcpy (&attr->__schedparam, param, sizeof (struct sched_param));
return 0;
}
+strong_alias (__pthread_attr_setschedparam, pthread_attr_setschedparam);
-int pthread_attr_getschedparam(const pthread_attr_t *attr,
- struct sched_param *param)
+int __pthread_attr_getschedparam(const pthread_attr_t *attr,
+ struct sched_param *param)
{
memcpy (param, &attr->__schedparam, sizeof (struct sched_param));
return 0;
}
+strong_alias (__pthread_attr_getschedparam, pthread_attr_getschedparam);
-int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
+int __pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
{
if (policy != SCHED_OTHER && policy != SCHED_FIFO && policy != SCHED_RR)
return EINVAL;
attr->__schedpolicy = policy;
return 0;
}
+strong_alias (__pthread_attr_setschedpolicy, pthread_attr_setschedpolicy);
-int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
+int __pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy)
{
*policy = attr->__schedpolicy;
return 0;
}
+strong_alias (__pthread_attr_getschedpolicy, pthread_attr_getschedpolicy);
-int pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
+int __pthread_attr_setinheritsched(pthread_attr_t *attr, int inherit)
{
if (inherit != PTHREAD_INHERIT_SCHED && inherit != PTHREAD_EXPLICIT_SCHED)
return EINVAL;
attr->__inheritsched = inherit;
return 0;
}
+strong_alias (__pthread_attr_setinheritsched, pthread_attr_setinheritsched);
-int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
+int __pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inherit)
{
*inherit = attr->__inheritsched;
return 0;
}
+strong_alias (__pthread_attr_getinheritsched, pthread_attr_getinheritsched);
-int pthread_attr_setscope(pthread_attr_t *attr, int scope)
+int __pthread_attr_setscope(pthread_attr_t *attr, int scope)
{
switch (scope) {
case PTHREAD_SCOPE_SYSTEM:
@@ -135,12 +144,14 @@ int pthread_attr_setscope(pthread_attr_t *attr, int scope)
return EINVAL;
}
}
+strong_alias (__pthread_attr_setscope, pthread_attr_setscope);
-int pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
+int __pthread_attr_getscope(const pthread_attr_t *attr, int *scope)
{
*scope = attr->__scope;
return 0;
}
+strong_alias (__pthread_attr_getscope, pthread_attr_getscope);
int __pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
{
diff --git a/linuxthreads/cancel.c b/linuxthreads/cancel.c
index 47c0bfee04..838f55d8b2 100644
--- a/linuxthreads/cancel.c
+++ b/linuxthreads/cancel.c
@@ -30,7 +30,7 @@
#endif
-int pthread_setcancelstate(int state, int * oldstate)
+int __pthread_setcancelstate(int state, int * oldstate)
{
pthread_descr self = thread_self();
if (state < PTHREAD_CANCEL_ENABLE || state > PTHREAD_CANCEL_DISABLE)
@@ -43,8 +43,9 @@ int pthread_setcancelstate(int state, int * oldstate)
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
return 0;
}
+strong_alias (__pthread_setcancelstate, pthread_setcancelstate);
-int pthread_setcanceltype(int type, int * oldtype)
+int __pthread_setcanceltype(int type, int * oldtype)
{
pthread_descr self = thread_self();
if (type < PTHREAD_CANCEL_DEFERRED || type > PTHREAD_CANCEL_ASYNCHRONOUS)
@@ -57,6 +58,33 @@ int pthread_setcanceltype(int type, int * oldtype)
__pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
return 0;
}
+strong_alias (__pthread_setcanceltype, pthread_setcanceltype);
+
+
+/* The next two functions are similar to pthread_setcanceltype() but
+ more specialized for the use in the cancelable functions like write().
+ They do not need to check parameters etc. */
+int
+attribute_hidden
+__pthread_enable_asynccancel (void)
+{
+ pthread_descr self = thread_self();
+ int oldtype = THREAD_GETMEM(self, p_canceltype);
+ THREAD_SETMEM(self, p_canceltype, PTHREAD_CANCEL_ASYNCHRONOUS);
+ if (__builtin_expect (THREAD_GETMEM(self, p_canceled), 0) &&
+ THREAD_GETMEM(self, p_cancelstate) == PTHREAD_CANCEL_ENABLE)
+ __pthread_do_exit(PTHREAD_CANCELED, CURRENT_STACK_FRAME);
+ return oldtype;
+}
+
+void
+internal_function attribute_hidden
+__pthread_disable_asynccancel (int oldtype)
+{
+ pthread_descr self = thread_self();
+ THREAD_SETMEM(self, p_canceltype, oldtype);
+}
+
int pthread_cancel(pthread_t thread)
{
@@ -210,14 +238,3 @@ void __pthread_perform_cleanup(char *currentframe)
__rpc_thread_destroy ();
#endif
}
-
-#ifndef SHARED
-/* We need a hook to force the cancelation wrappers and file locking
- to be linked in when static libpthread is used. */
-extern const int __pthread_provide_wrappers;
-static const int *const __pthread_require_wrappers =
- &__pthread_provide_wrappers;
-extern const int __pthread_provide_lockfile;
-static const int *const __pthread_require_lockfile =
- &__pthread_provide_lockfile;
-#endif
diff --git a/linuxthreads/condvar.c b/linuxthreads/condvar.c
index fd0db50fa2..a40ae49fab 100644
--- a/linuxthreads/condvar.c
+++ b/linuxthreads/condvar.c
@@ -25,19 +25,21 @@
#include "queue.h"
#include "restart.h"
-int pthread_cond_init(pthread_cond_t *cond,
- const pthread_condattr_t *cond_attr)
+int __pthread_cond_init(pthread_cond_t *cond,
+ const pthread_condattr_t *cond_attr)
{
__pthread_init_lock(&cond->__c_lock);
cond->__c_waiting = NULL;
return 0;
}
+strong_alias (__pthread_cond_init, pthread_cond_init)
-int pthread_cond_destroy(pthread_cond_t *cond)
+int __pthread_cond_destroy(pthread_cond_t *cond)
{
if (cond->__c_waiting != NULL) return EBUSY;
return 0;
}
+strong_alias (__pthread_cond_destroy, pthread_cond_destroy)
/* Function called by pthread_cancel to remove the thread from
waiting on a condition variable queue. */
@@ -55,7 +57,7 @@ static int cond_extricate_func(void *obj, pthread_descr th)
return did_remove;
}
-int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+int __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
{
volatile pthread_descr self = thread_self();
pthread_extricate_if extr;