aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/runtime/thread_openbsd.c
diff options
context:
space:
mode:
authorJoel Sing <jsing@google.com>2012-04-26 00:08:02 +1000
committerJoel Sing <jsing@google.com>2012-04-26 00:08:02 +1000
commit689d5b91631ccfaee9b85aa25a06df55769e299e (patch)
tree7e4e1208eeef38f244a36befe425b2fae9325b49 /src/pkg/runtime/thread_openbsd.c
parentfdce27f7b8f671e3399d2c116dbd15ec2e612af2 (diff)
downloadgo-689d5b91631ccfaee9b85aa25a06df55769e299e.tar.xz
runtime: use __tfork() syscall on openbsd
Switch from using the rfork() syscall on OpenBSD, to the __tfork() syscall. The __tfork() syscall is the preferred way of creating system threads and the rfork() syscall has recently been removed. Note: this will break compatibility with OpenBSD releases prior to 5.1. R=golang-dev, bradfitz, devon.odell, rsc CC=golang-dev https://golang.org/cl/6037048
Diffstat (limited to 'src/pkg/runtime/thread_openbsd.c')
-rw-r--r--src/pkg/runtime/thread_openbsd.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/pkg/runtime/thread_openbsd.c b/src/pkg/runtime/thread_openbsd.c
index acd32a6f18..56bb1c8ebf 100644
--- a/src/pkg/runtime/thread_openbsd.c
+++ b/src/pkg/runtime/thread_openbsd.c
@@ -23,7 +23,7 @@ extern SigTab runtime·sigtab[];
static Sigset sigset_all = ~(Sigset)0;
static Sigset sigset_none;
-extern int64 runtime·rfork_thread(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+extern int64 runtime·tfork_thread(void *param, void *stack, M *m, G *g, void (*fn)(void));
extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
extern int32 runtime·thrwakeup(void *ident, int32 n);
@@ -122,22 +122,14 @@ runtime·semawakeup(M *mp)
runtime·atomicstore(&mp->waitsemalock, 0);
}
-// From OpenBSD's sys/param.h
-#define RFPROC (1<<4) /* change child (else changes curproc) */
-#define RFMEM (1<<5) /* share `address space' */
-#define RFNOWAIT (1<<6) /* parent need not wait() on child */
-#define RFTHREAD (1<<13) /* create a thread, not a process */
-
void
runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
{
+ Tfork param;
Sigset oset;
- int32 flags;
int32 ret;
- flags = RFPROC | RFTHREAD | RFMEM | RFNOWAIT;
-
- if (0) {
+ if(0) {
runtime·printf(
"newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
stk, m, g, fn, m->id, m->tls[0], &m);
@@ -145,8 +137,12 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
m->tls[0] = m->id; // so 386 asm can find it
+ param.tf_tcb = (byte*)&m->tls[0];
+ param.tf_tid = (int32*)&m->procid;
+ param.tf_flags = (int32)0;
+
oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
- ret = runtime·rfork_thread(flags, stk, m, g, fn);
+ ret = runtime·tfork_thread((byte*)&param, stk, m, g, fn);
runtime·sigprocmask(SIG_SETMASK, oset);
if(ret < 0) {