summaryrefslogtreecommitdiff
path: root/pthread
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2004-03-18 02:44:20 +0000
committerThomas Schwinge <tschwinge@gnu.org>2009-04-06 22:16:47 +0200
commit87bbfdf3b5718544942498f0d980e13a0f4110da (patch)
treee9693b1d7ee1054b965068fed171be6f1aa0822e /pthread
parent01d0d4c7d07b28326d2de95dd9000f876f661707 (diff)
2004-03-17 Marcus Brinkmann <marcus@gnu.org>
* libpthread: New directory, populated with Neal H. Walfields pthread implementation.
Diffstat (limited to 'pthread')
-rw-r--r--pthread/pt-create.c24
-rw-r--r--pthread/pt-internal.h7
2 files changed, 24 insertions, 7 deletions
diff --git a/pthread/pt-create.c b/pthread/pt-create.c
index 0295a0af..727fbac1 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);
diff --git a/pthread/pt-internal.h b/pthread/pt-internal.h
index a32345c4..79ce19c7 100644
--- a/pthread/pt-internal.h
+++ b/pthread/pt-internal.h
@@ -21,11 +21,12 @@
#define _PT_INTERNAL_H 1
#include <pthread.h>
+#if 0
#include <stddef.h>
#include <sched.h>
#include <signal.h>
#include <assert.h>
-
+#endif
#include <bits/atomic.h>
#include <pt-key.h>
@@ -164,6 +165,7 @@ extern void __pthread_initialize (void);
tid, we return the whole __pthread structure in *PTHREAD. */
extern int __pthread_create_internal (struct __pthread **pthread,
const pthread_attr_t *attr,
+ void *provided_thread,
void *(*start_routine)(void *),
void *arg);
@@ -203,6 +205,9 @@ extern int __pthread_thread_start (struct __pthread *thread);
with THREAD. */
extern void __pthread_thread_halt (struct __pthread *thread);
+/* Initialize provided kernel thread. */
+extern int __pthread_init_provided_thread (struct __pthread *thread,
+ void *p);
/* Block THREAD. */
extern void __pthread_block (struct __pthread *thread);