aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/pthread.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libthread/pthread.c')
-rw-r--r--src/libthread/pthread.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libthread/pthread.c b/src/libthread/pthread.c
index 46bb396a..5e022f0b 100644
--- a/src/libthread/pthread.c
+++ b/src/libthread/pthread.c
@@ -99,6 +99,23 @@ startprocfn(void *v)
pthread_exit(0);
}
+static void
+startpthreadfn(void *v)
+{
+ void **a;
+ Proc *p;
+ _Thread *t;
+
+ a = (void**)v;
+ p = a[0];
+ t = a[1];
+ free(a);
+ t->osprocid = pthread_self();
+ pthread_detach(t->osprocid);
+ _threadpthreadmain(p, t);
+ pthread_exit(0);
+}
+
void
_procstart(Proc *p, void (*fn)(Proc*))
{
@@ -116,6 +133,22 @@ _procstart(Proc *p, void (*fn)(Proc*))
}
}
+void
+_threadpthreadstart(Proc *p, _Thread *t)
+{
+ void **a;
+
+ a = malloc(3*sizeof a[0]);
+ if(a == nil)
+ sysfatal("_pthreadstart malloc: %r");
+ a[0] = p;
+ a[1] = t;
+ if(pthread_create(&t->osprocid, nil, (void*(*)(void*))startpthreadfn, (void*)a) < 0){
+ fprint(2, "pthread_create: %r\n");
+ abort();
+ }
+}
+
static pthread_key_t prockey;
Proc*