diff options
author | deischen <deischen@FreeBSD.org> | 2001-01-24 13:03:38 +0000 |
---|---|---|
committer | deischen <deischen@FreeBSD.org> | 2001-01-24 13:03:38 +0000 |
commit | ee1de6a067c70fbd8cb73facd64c3b0b275f9f83 (patch) | |
tree | 71d2853de2f283028592fa4119320bab82c18d68 /lib/libpthread/thread/thr_sigmask.c | |
parent | 274959d59337555267567d4bde9a5a841c47d84f (diff) | |
download | FreeBSD-src-ee1de6a067c70fbd8cb73facd64c3b0b275f9f83.zip FreeBSD-src-ee1de6a067c70fbd8cb73facd64c3b0b275f9f83.tar.gz |
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
Diffstat (limited to 'lib/libpthread/thread/thr_sigmask.c')
-rw-r--r-- | lib/libpthread/thread/thr_sigmask.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/libpthread/thread/thr_sigmask.c b/lib/libpthread/thread/thr_sigmask.c index 53d0774..c16d66b 100644 --- a/lib/libpthread/thread/thr_sigmask.c +++ b/lib/libpthread/thread/thr_sigmask.c @@ -36,20 +36,22 @@ #include <sys/signalvar.h> #include <errno.h> #include <signal.h> -#ifdef _THREAD_SAFE #include <pthread.h> #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 |