diff options
author | Marcus Brinkmann <marcus@gnu.org> | 2004-03-18 02:44:20 +0000 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gnu.org> | 2009-04-06 22:16:47 +0200 |
commit | ef01119ea9239c3e91c33dc3b51bb059eb621677 (patch) | |
tree | e2d13d56fbd0b59e959efc8b0f6bda8fca63b2ed /pthread/pt-create.c | |
parent | cb62fb204d22daea8ec0367c7590f32116276aa7 (diff) |
2004-03-17 Marcus Brinkmann <marcus@gnu.org>
* libpthread: New directory, populated with Neal H. Walfields
pthread implementation.
Diffstat (limited to 'pthread/pt-create.c')
-rw-r--r-- | pthread/pt-create.c | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c index 0295a0a..727fbac 100644 --- a/pthread/pt-create.c +++ b/pthread/pt-create.c @@ -57,7 +57,7 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr, int err; struct __pthread *pthread; - err = __pthread_create_internal (&pthread, attr, start_routine, arg); + err = __pthread_create_internal (&pthread, attr, 0, start_routine, arg); if (! err) *thread = pthread->thread; @@ -69,6 +69,7 @@ pthread_create (pthread_t *thread, const pthread_attr_t *attr, int __pthread_create_internal (struct __pthread **thread, const pthread_attr_t *attr, + void *provided_thread, void *(*start_routine)(void *), void *arg) { int err; @@ -122,10 +123,20 @@ __pthread_create_internal (struct __pthread **thread, pthread->stack = 1; } - /* Allocate the kernel thread and other required resources. */ - err = __pthread_thread_alloc (pthread); - if (err) - goto failed_thread_alloc; + /* Allocate the kernel thread and other required resources + if they were not provided with this call. */ + if (!provided_thread) + { + err = __pthread_thread_alloc (pthread); + if (err) + goto failed_thread_alloc; + } + else + { + err = __pthread_init_provided_thread (pthread, provided_thread); + if (err) + goto failed_thread_alloc; + } /* And initialize the rest of the machine context. This may include additional machine- and system-specific initializations that @@ -146,7 +157,8 @@ __pthread_create_internal (struct __pthread **thread, shall be empty." If the currnet thread is not a pthread then we just inherit the process' sigmask. */ if (__pthread_num_threads == 1) - err = sigprocmask (0, 0, &sigset); + /* FIXME no sigprocmask yet */ + err = 0; /* sigprocmask (0, 0, &sigset); */ else err = __pthread_sigstate (_pthread_self (), 0, 0, &sigset, 0); assert_perror (err); |