summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/thread/thr_create.c
diff options
context:
space:
mode:
authordeischen <deischen@FreeBSD.org>2001-01-24 13:03:38 +0000
committerdeischen <deischen@FreeBSD.org>2001-01-24 13:03:38 +0000
commitee1de6a067c70fbd8cb73facd64c3b0b275f9f83 (patch)
tree71d2853de2f283028592fa4119320bab82c18d68 /lib/libpthread/thread/thr_create.c
parent274959d59337555267567d4bde9a5a841c47d84f (diff)
downloadFreeBSD-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_create.c')
-rw-r--r--lib/libpthread/thread/thr_create.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/libpthread/thread/thr_create.c b/lib/libpthread/thread/thr_create.c
index 430869e..a0a51ec 100644
--- a/lib/libpthread/thread/thr_create.c
+++ b/lib/libpthread/thread/thr_create.c
@@ -40,7 +40,6 @@
#include <sys/time.h>
#include <sys/param.h>
#include <sys/mman.h>
-#ifdef _THREAD_SAFE
#include <machine/reg.h>
#include <pthread.h>
#include "pthread_private.h"
@@ -64,10 +63,13 @@ int _thread_CTX_JB_value = CTX_JB;
int _thread_CTX_SJB_value = CTX_SJB;
int _thread_CTX_UC_value = CTX_UC;
+#pragma weak pthread_create=_pthread_create
+
int
-pthread_create(pthread_t * thread, const pthread_attr_t * attr,
+_pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void *(*start_routine) (void *), void *arg)
{
+ struct pthread *curthread = _get_curthread();
struct itimerval itimer;
int f_gc = 0;
int ret = 0;
@@ -180,7 +182,7 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
new_thread->magic = PTHREAD_MAGIC;
/* Initialise the thread for signals: */
- new_thread->sigmask = _thread_run->sigmask;
+ new_thread->sigmask = curthread->sigmask;
new_thread->sigmask_seqno = 0;
/* Initialize the signal frame: */
@@ -214,13 +216,13 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
if (new_thread->attr.flags & PTHREAD_INHERIT_SCHED) {
/* Copy the scheduling attributes: */
new_thread->base_priority =
- _thread_run->base_priority &
+ curthread->base_priority &
~PTHREAD_SIGNAL_PRIORITY;
new_thread->attr.prio =
- _thread_run->base_priority &
+ curthread->base_priority &
~PTHREAD_SIGNAL_PRIORITY;
new_thread->attr.sched_policy =
- _thread_run->attr.sched_policy;
+ curthread->attr.sched_policy;
} else {
/*
* Use just the thread priority, leaving the
@@ -315,13 +317,14 @@ pthread_create(pthread_t * thread, const pthread_attr_t * attr,
void
_thread_start(void)
{
+ struct pthread *curthread = _get_curthread();
+
/* We just left the scheduler via longjmp: */
_thread_kern_in_sched = 0;
/* Run the current thread's start routine with argument: */
- pthread_exit(_thread_run->start_routine(_thread_run->arg));
+ pthread_exit(curthread->start_routine(curthread->arg));
/* This point should never be reached. */
PANIC("Thread has resumed after exit");
}
-#endif
OpenPOWER on IntegriCloud