Commit 86d509b4 authored by Russ Cox's avatar Russ Cox

runtime: preparation for non-Go threads running Go code

* Handle p==nil in signalstack by setting SS_DISABLE flag.
* Make minit only allocate a signal g if there's not one already.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7323072
parent 07e87885
......@@ -5,6 +5,7 @@
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
#define SIGHUP 1
#define SS_DISABLE 4
int32 runtime·bsdthread_create(void*, M*, G*, void(*)(void));
int32 runtime·bsdthread_register(void);
......
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
#define SIGHUP 1
#define SS_DISABLE 4
int32 runtime·thr_new(ThrParam*, int32);
void runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp);
......
......@@ -5,6 +5,7 @@
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
#define SIGHUP 1
#define SS_DISABLE 2
// Linux-specific system calls
int32 runtime·futex(uint32*, int32, uint32, Timespec*, uint32*, uint32);
......
......@@ -5,6 +5,7 @@
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
#define SIGHUP 1
#define SS_DISABLE 4
#define SIG_BLOCK 1
#define SIG_UNBLOCK 2
......
......@@ -5,6 +5,7 @@
#define SIG_DFL ((void*)0)
#define SIG_IGN ((void*)1)
#define SIGHUP 1
#define SS_DISABLE 4
#define SIG_BLOCK 1
#define SIG_UNBLOCK 2
......
......@@ -125,6 +125,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -135,6 +135,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -120,6 +120,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = (int8*)p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -128,6 +128,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = (int8*)p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -143,6 +143,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = (uint8*)p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -116,6 +116,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -126,6 +126,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -132,6 +132,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -120,6 +120,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -127,6 +127,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -149,6 +149,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = (uint8*)p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -116,6 +116,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -125,6 +125,8 @@ runtime·signalstack(byte *p, int32 n)
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
if(p == nil)
st.ss_flags = SS_DISABLE;
runtime·sigaltstack(&st, nil);
}
......
......@@ -113,7 +113,8 @@ void
runtime·minit(void)
{
// Initialize signal handling.
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
if(m->gsignal == nil)
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
......@@ -438,10 +439,11 @@ runtime·sigpanic(void)
runtime·panicstring(runtime·sigtab[g->sig].name);
}
// TODO(rsc): place holder to fix build.
#pragma textflag 7
void
runtime·osyield(void)
{
runtime·usleep(1);
}
uintptr
......
......@@ -175,7 +175,8 @@ void
runtime·minit(void)
{
// Initialize signal handling.
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
if(m->gsignal == nil)
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
runtime·rtsigprocmask(SIG_SETMASK, &sigset_none, nil, sizeof(Sigset));
}
......
......@@ -193,7 +193,8 @@ runtime·minit(void)
m->procid = runtime·lwp_self();
// Initialize signal handling
m->gsignal = runtime·malg(32*1024);
if(m->gsignal == nil)
m->gsignal = runtime·malg(32*1024);
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
}
......
......@@ -170,7 +170,8 @@ void
runtime·minit(void)
{
// Initialize signal handling
m->gsignal = runtime·malg(32*1024);
if(m->gsignal == nil)
m->gsignal = runtime·malg(32*1024);
runtime·signalstack((byte*)m->gsignal->stackguard - StackGuard, 32*1024);
runtime·sigprocmask(SIG_SETMASK, sigset_none);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment