runtime: Move new 1.1.1 functions from thread-linux.c to runtime.c.
This way they are compiled on non-GNU/Linux systems. From-SVN: r201209
This commit is contained in:
parent
493f4c9e09
commit
c0f0119244
|
@ -2,6 +2,7 @@
|
||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -232,3 +233,49 @@ runtime_pprof_runtime_cyclesPerSecond(void)
|
||||||
{
|
{
|
||||||
return runtime_tickspersecond();
|
return runtime_tickspersecond();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called to initialize a new m (including the bootstrap m).
|
||||||
|
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
||||||
|
void
|
||||||
|
runtime_mpreinit(M *mp)
|
||||||
|
{
|
||||||
|
mp->gsignal = runtime_malg(32*1024, &mp->gsignalstack, &mp->gsignalstacksize); // OS X wants >=8K, Linux >=2K
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called to initialize a new m (including the bootstrap m).
|
||||||
|
// Called on the new thread, can not allocate memory.
|
||||||
|
void
|
||||||
|
runtime_minit(void)
|
||||||
|
{
|
||||||
|
M* m;
|
||||||
|
sigset_t sigs;
|
||||||
|
|
||||||
|
// Initialize signal handling.
|
||||||
|
m = runtime_m();
|
||||||
|
runtime_signalstack(m->gsignalstack, m->gsignalstacksize);
|
||||||
|
if (sigemptyset(&sigs) != 0)
|
||||||
|
runtime_throw("sigemptyset");
|
||||||
|
sigprocmask(SIG_SETMASK, &sigs, nil);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called from dropm to undo the effect of an minit.
|
||||||
|
void
|
||||||
|
runtime_unminit(void)
|
||||||
|
{
|
||||||
|
runtime_signalstack(nil, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime_signalstack(byte *p, int32 n)
|
||||||
|
{
|
||||||
|
stack_t st;
|
||||||
|
|
||||||
|
st.ss_sp = p;
|
||||||
|
st.ss_size = n;
|
||||||
|
st.ss_flags = 0;
|
||||||
|
if(p == nil)
|
||||||
|
st.ss_flags = SS_DISABLE;
|
||||||
|
if(sigaltstack(&st, nil) < 0)
|
||||||
|
*(int *)0xf1 = 0xf1;
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
// Futexsleep is allowed to wake up spuriously.
|
// Futexsleep is allowed to wake up spuriously.
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -84,48 +83,3 @@ runtime_goenvs(void)
|
||||||
{
|
{
|
||||||
runtime_goenvs_unix();
|
runtime_goenvs_unix();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called to initialize a new m (including the bootstrap m).
|
|
||||||
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
|
|
||||||
void
|
|
||||||
runtime_mpreinit(M *mp)
|
|
||||||
{
|
|
||||||
mp->gsignal = runtime_malg(32*1024, &mp->gsignalstack, &mp->gsignalstacksize); // OS X wants >=8K, Linux >=2K
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called to initialize a new m (including the bootstrap m).
|
|
||||||
// Called on the new thread, can not allocate memory.
|
|
||||||
void
|
|
||||||
runtime_minit(void)
|
|
||||||
{
|
|
||||||
M* m;
|
|
||||||
sigset_t sigs;
|
|
||||||
|
|
||||||
// Initialize signal handling.
|
|
||||||
m = runtime_m();
|
|
||||||
runtime_signalstack(m->gsignalstack, m->gsignalstacksize);
|
|
||||||
if (sigemptyset(&sigs) != 0)
|
|
||||||
runtime_throw("sigemptyset");
|
|
||||||
sigprocmask(SIG_SETMASK, &sigs, nil);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Called from dropm to undo the effect of an minit.
|
|
||||||
void
|
|
||||||
runtime_unminit(void)
|
|
||||||
{
|
|
||||||
runtime_signalstack(nil, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
runtime_signalstack(byte *p, int32 n)
|
|
||||||
{
|
|
||||||
stack_t st;
|
|
||||||
|
|
||||||
st.ss_sp = p;
|
|
||||||
st.ss_size = n;
|
|
||||||
st.ss_flags = 0;
|
|
||||||
if(p == nil)
|
|
||||||
st.ss_flags = SS_DISABLE;
|
|
||||||
if(sigaltstack(&st, nil) < 0)
|
|
||||||
*(int *)0xf1 = 0xf1;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue