From e5106342c6de9cbe26c4827e4e29bae309cd8cfb Mon Sep 17 00:00:00 2001 From: Daniel Eischen Date: Wed, 24 Jan 2001 13:03:38 +0000 Subject: Add weak definitions for wrapped system calls. In general: _foo - wrapped system call foo - weak definition to _foo and for cancellation points: _foo - wrapped system call __foo - enter cancellation point, call _foo(), leave cancellation point foo - weak definition to __foo Change use of global _thread_run to call a function to get the currently running thread. Make all pthread_foo functions weak definitions to _pthread_foo, where _pthread_foo is the implementation. This allows an application to provide its own pthread functions. Provide slightly different versions of pthread_mutex_lock and pthread_mutex_init so that we can tell the difference between a libc mutex and an application mutex. Threads holding mutexes internal to libc should never be allowed to exit, call signal handlers, or cancel. Approved by: -arch --- lib/libpthread/thread/thr_sigmask.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib/libpthread/thread/thr_sigmask.c') diff --git a/lib/libpthread/thread/thr_sigmask.c b/lib/libpthread/thread/thr_sigmask.c index 53d0774f3b684..c16d66bd54151 100644 --- a/lib/libpthread/thread/thr_sigmask.c +++ b/lib/libpthread/thread/thr_sigmask.c @@ -36,20 +36,22 @@ #include #include #include -#ifdef _THREAD_SAFE #include #include "pthread_private.h" +#pragma weak pthread_sigmask=_pthread_sigmask + int -pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) +_pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) { + struct pthread *curthread = _get_curthread(); sigset_t sigset; int ret = 0; /* Check if the existing signal process mask is to be returned: */ if (oset != NULL) { /* Return the current mask: */ - *oset = _thread_run->sigmask; + *oset = curthread->sigmask; } /* Check if a new signal set was provided by the caller: */ if (set != NULL) { @@ -58,19 +60,19 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) /* Block signals: */ case SIG_BLOCK: /* Add signals to the existing mask: */ - SIGSETOR(_thread_run->sigmask, *set); + SIGSETOR(curthread->sigmask, *set); break; /* Unblock signals: */ case SIG_UNBLOCK: /* Clear signals from the existing mask: */ - SIGSETNAND(_thread_run->sigmask, *set); + SIGSETNAND(curthread->sigmask, *set); break; /* Set the signal process mask: */ case SIG_SETMASK: /* Set the new mask: */ - _thread_run->sigmask = *set; + curthread->sigmask = *set; break; /* Trap invalid actions: */ @@ -82,15 +84,15 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) } /* Increment the sequence number: */ - _thread_run->sigmask_seqno++; + curthread->sigmask_seqno++; /* * Check if there are pending signals for the running * thread or process that aren't blocked: */ - sigset = _thread_run->sigpend; + sigset = curthread->sigpend; SIGSETOR(sigset, _process_sigpending); - SIGSETNAND(sigset, _thread_run->sigmask); + SIGSETNAND(sigset, curthread->sigmask); if (SIGNOTEMPTY(sigset)) /* * Call the kernel scheduler which will safely @@ -102,4 +104,3 @@ pthread_sigmask(int how, const sigset_t *set, sigset_t *oset) /* Return the completion status: */ return (ret); } -#endif -- cgit v1.3