2013-03-20 02:40:29 +09:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
|
// license that can be found in the LICENSE file.
|
2011-08-08 09:56:38 -04:00
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-12-16 15:33:58 -05:00
|
|
|
#include "defs_GOOS_GOARCH.h"
|
|
|
|
|
#include "os_GOOS.h"
|
2013-03-14 11:35:13 -07:00
|
|
|
#include "signal_unix.h"
|
2011-08-08 09:56:38 -04:00
|
|
|
#include "stack.h"
|
2013-08-12 13:47:18 -07:00
|
|
|
#include "../../cmd/ld/textflag.h"
|
2011-08-08 09:56:38 -04:00
|
|
|
|
2011-08-29 09:35:13 -04:00
|
|
|
enum
|
|
|
|
|
{
|
2011-10-09 00:56:13 +11:00
|
|
|
ESRCH = 3,
|
2011-08-29 09:35:13 -04:00
|
|
|
ENOTSUP = 91,
|
2011-11-07 11:57:34 -05:00
|
|
|
|
|
|
|
|
// From OpenBSD's sys/time.h
|
|
|
|
|
CLOCK_REALTIME = 0,
|
|
|
|
|
CLOCK_VIRTUAL = 1,
|
|
|
|
|
CLOCK_PROF = 2,
|
|
|
|
|
CLOCK_MONOTONIC = 3
|
2011-08-29 09:35:13 -04:00
|
|
|
};
|
2011-08-08 09:56:38 -04:00
|
|
|
|
2011-10-09 00:56:13 +11:00
|
|
|
extern SigTab runtime·sigtab[];
|
|
|
|
|
|
2013-02-15 12:18:33 -05:00
|
|
|
static Sigset sigset_none;
|
2012-04-10 21:57:05 +10:00
|
|
|
static Sigset sigset_all = ~(Sigset)0;
|
|
|
|
|
|
2014-08-29 23:13:17 -07:00
|
|
|
extern int32 runtime·tfork(TforkT *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
|
2012-04-11 22:02:08 +10:00
|
|
|
extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
|
2011-11-07 11:57:34 -05:00
|
|
|
extern int32 runtime·thrwakeup(void *ident, int32 n);
|
2011-10-09 00:56:13 +11:00
|
|
|
|
2011-10-05 13:16:43 -04:00
|
|
|
// From OpenBSD's <sys/sysctl.h>
|
|
|
|
|
#define CTL_HW 6
|
|
|
|
|
#define HW_NCPU 3
|
|
|
|
|
|
|
|
|
|
static int32
|
|
|
|
|
getncpu(void)
|
|
|
|
|
{
|
|
|
|
|
uint32 mib[2];
|
|
|
|
|
uint32 out;
|
|
|
|
|
int32 ret;
|
|
|
|
|
uintptr nout;
|
|
|
|
|
|
|
|
|
|
// Fetch hw.ncpu via sysctl.
|
|
|
|
|
mib[0] = CTL_HW;
|
|
|
|
|
mib[1] = HW_NCPU;
|
|
|
|
|
nout = sizeof out;
|
|
|
|
|
out = 0;
|
|
|
|
|
ret = runtime·sysctl(mib, 2, (byte*)&out, &nout, nil, 0);
|
|
|
|
|
if(ret >= 0)
|
|
|
|
|
return out;
|
|
|
|
|
else
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-02 16:42:01 +03:00
|
|
|
uintptr
|
|
|
|
|
runtime·semacreate(void)
|
2011-08-08 09:56:38 -04:00
|
|
|
{
|
2011-11-02 16:42:01 +03:00
|
|
|
return 1;
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
2013-08-12 13:47:18 -07:00
|
|
|
#pragma textflag NOSPLIT
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
int32
|
|
|
|
|
runtime·semasleep(int64 ns)
|
2011-08-08 09:56:38 -04:00
|
|
|
{
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
Timespec ts;
|
|
|
|
|
|
2011-11-02 16:42:01 +03:00
|
|
|
// spin-mutex lock
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
while(runtime·xchg(&g->m->waitsemalock, 1))
|
2011-10-09 00:56:13 +11:00
|
|
|
runtime·osyield();
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
|
|
|
|
|
for(;;) {
|
|
|
|
|
// lock held
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
if(g->m->waitsemacount == 0) {
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
// sleep until semaphore != 0 or timeout.
|
|
|
|
|
// thrsleep unlocks m->waitsemalock.
|
|
|
|
|
if(ns < 0)
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
runtime·thrsleep(&g->m->waitsemacount, 0, nil, &g->m->waitsemalock, nil);
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
else {
|
2011-11-10 11:42:01 -08:00
|
|
|
ns += runtime·nanotime();
|
2013-07-29 16:31:42 -04:00
|
|
|
// NOTE: tv_nsec is int64 on amd64, so this assumes a little-endian system.
|
2013-07-29 22:22:34 +04:00
|
|
|
ts.tv_nsec = 0;
|
2013-07-29 16:31:42 -04:00
|
|
|
ts.tv_sec = runtime·timediv(ns, 1000000000, (int32*)&ts.tv_nsec);
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
runtime·thrsleep(&g->m->waitsemacount, CLOCK_MONOTONIC, &ts, &g->m->waitsemalock, nil);
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
}
|
|
|
|
|
// reacquire lock
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
while(runtime·xchg(&g->m->waitsemalock, 1))
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
runtime·osyield();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// lock held (again)
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
if(g->m->waitsemacount != 0) {
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
// semaphore is available.
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
g->m->waitsemacount--;
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
// spin-mutex unlock
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
runtime·atomicstore(&g->m->waitsemalock, 0);
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
return 0; // semaphore acquired
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// semaphore not available.
|
|
|
|
|
// if there is a timeout, stop now.
|
|
|
|
|
// otherwise keep trying.
|
|
|
|
|
if(ns >= 0)
|
|
|
|
|
break;
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
|
|
|
|
|
// lock held but giving up
|
2011-11-02 16:42:01 +03:00
|
|
|
// spin-mutex unlock
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
runtime·atomicstore(&g->m->waitsemalock, 0);
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 15:17:05 -05:00
|
|
|
return -1;
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2011-11-02 16:42:01 +03:00
|
|
|
runtime·semawakeup(M *mp)
|
2011-08-08 09:56:38 -04:00
|
|
|
{
|
2011-11-02 16:42:01 +03:00
|
|
|
uint32 ret;
|
2011-08-08 09:56:38 -04:00
|
|
|
|
2011-11-02 16:42:01 +03:00
|
|
|
// spin-mutex lock
|
|
|
|
|
while(runtime·xchg(&mp->waitsemalock, 1))
|
|
|
|
|
runtime·osyield();
|
|
|
|
|
mp->waitsemacount++;
|
|
|
|
|
ret = runtime·thrwakeup(&mp->waitsemacount, 1);
|
|
|
|
|
if(ret != 0 && ret != ESRCH)
|
|
|
|
|
runtime·printf("thrwakeup addr=%p sem=%d ret=%d\n", &mp->waitsemacount, mp->waitsemacount, ret);
|
|
|
|
|
// spin-mutex unlock
|
|
|
|
|
runtime·atomicstore(&mp->waitsemalock, 0);
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
2013-03-01 11:44:43 -05:00
|
|
|
runtime·newosproc(M *mp, void *stk)
|
2011-08-08 09:56:38 -04:00
|
|
|
{
|
2014-08-29 23:13:17 -07:00
|
|
|
TforkT param;
|
2012-04-10 21:57:05 +10:00
|
|
|
Sigset oset;
|
2011-08-08 09:56:38 -04:00
|
|
|
int32 ret;
|
|
|
|
|
|
2012-04-26 00:08:02 +10:00
|
|
|
if(0) {
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·printf(
|
2013-03-01 11:57:50 -05:00
|
|
|
"newosproc stk=%p m=%p g=%p id=%d/%d ostk=%p\n",
|
|
|
|
|
stk, mp, mp->g0, mp->id, (int32)mp->tls[0], &mp);
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
2012-12-19 00:30:29 +08:00
|
|
|
mp->tls[0] = mp->id; // so 386 asm can find it
|
2011-08-08 09:56:38 -04:00
|
|
|
|
2012-12-19 00:30:29 +08:00
|
|
|
param.tf_tcb = (byte*)&mp->tls[0];
|
|
|
|
|
param.tf_tid = (int32*)&mp->procid;
|
2012-11-22 01:25:53 +11:00
|
|
|
param.tf_stack = stk;
|
2012-04-26 00:08:02 +10:00
|
|
|
|
2012-04-10 21:57:05 +10:00
|
|
|
oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
|
2014-08-29 23:13:17 -07:00
|
|
|
ret = runtime·tfork(¶m, sizeof(param), mp, mp->g0, runtime·mstart);
|
2012-04-10 21:57:05 +10:00
|
|
|
runtime·sigprocmask(SIG_SETMASK, oset);
|
|
|
|
|
|
|
|
|
|
if(ret < 0) {
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
|
2011-08-29 09:35:13 -04:00
|
|
|
if (ret == -ENOTSUP)
|
|
|
|
|
runtime·printf("runtime: is kern.rthreads disabled?\n");
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·throw("runtime.newosproc");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
runtime·osinit(void)
|
|
|
|
|
{
|
2011-10-05 13:16:43 -04:00
|
|
|
runtime·ncpu = getncpu();
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
2014-09-04 15:53:45 -04:00
|
|
|
#pragma textflag NOSPLIT
|
2013-03-12 10:47:44 -07:00
|
|
|
void
|
|
|
|
|
runtime·get_random_data(byte **rnd, int32 *rnd_len)
|
|
|
|
|
{
|
2014-05-31 19:21:17 -04:00
|
|
|
#pragma dataflag NOPTR
|
2013-03-12 10:47:44 -07:00
|
|
|
static byte urandom_data[HashRandomBytes];
|
|
|
|
|
int32 fd;
|
|
|
|
|
fd = runtime·open("/dev/urandom", 0 /* O_RDONLY */, 0);
|
|
|
|
|
if(runtime·read(fd, urandom_data, HashRandomBytes) == HashRandomBytes) {
|
|
|
|
|
*rnd = urandom_data;
|
|
|
|
|
*rnd_len = HashRandomBytes;
|
|
|
|
|
} else {
|
|
|
|
|
*rnd = nil;
|
|
|
|
|
*rnd_len = 0;
|
|
|
|
|
}
|
|
|
|
|
runtime·close(fd);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-08 09:56:38 -04:00
|
|
|
void
|
|
|
|
|
runtime·goenvs(void)
|
|
|
|
|
{
|
|
|
|
|
runtime·goenvs_unix();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called to initialize a new m (including the bootstrap m).
|
2013-02-21 16:24:38 +04:00
|
|
|
// 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);
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
mp->gsignal->m = mp;
|
2013-02-21 16:24:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Called to initialize a new m (including the bootstrap m).
|
|
|
|
|
// Called on the new thread, can not allocate memory.
|
2011-08-08 09:56:38 -04:00
|
|
|
void
|
|
|
|
|
runtime·minit(void)
|
|
|
|
|
{
|
|
|
|
|
// Initialize signal handling
|
all: remove 'extern register M *m' from runtime
The runtime has historically held two dedicated values g (current goroutine)
and m (current thread) in 'extern register' slots (TLS on x86, real registers
backed by TLS on ARM).
This CL removes the extern register m; code now uses g->m.
On ARM, this frees up the register that formerly held m (R9).
This is important for NaCl, because NaCl ARM code cannot use R9 at all.
The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected:
BenchmarkBinaryTree17 5491374955 5471024381 -0.37%
BenchmarkFannkuch11 4357101311 4275174828 -1.88%
BenchmarkGobDecode 11029957 11364184 +3.03%
BenchmarkGobEncode 6852205 6784822 -0.98%
BenchmarkGzip 650795967 650152275 -0.10%
BenchmarkGunzip 140962363 141041670 +0.06%
BenchmarkHTTPClientServer 71581 73081 +2.10%
BenchmarkJSONEncode 31928079 31913356 -0.05%
BenchmarkJSONDecode 117470065 113689916 -3.22%
BenchmarkMandelbrot200 6008923 5998712 -0.17%
BenchmarkGoParse 6310917 6327487 +0.26%
BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17%
BenchmarkRegexpMatchHard_1K 168977 169244 +0.16%
BenchmarkRevcomp 935294971 914060918 -2.27%
BenchmarkTemplate 145917123 148186096 +1.55%
Minux previous reported larger variations, but these were caused by
run-to-run noise, not repeatable slowdowns.
Actual code changes by Minux.
I only did the docs and the benchmarking.
LGTM=dvyukov, iant, minux
R=minux, josharian, iant, dave, bradfitz, dvyukov
CC=golang-codereviews
https://golang.org/cl/109050043
2014-06-26 11:54:39 -04:00
|
|
|
runtime·signalstack((byte*)g->m->gsignal->stackguard - StackGuard, 32*1024);
|
2013-02-17 02:06:59 +11:00
|
|
|
runtime·sigprocmask(SIG_SETMASK, sigset_none);
|
2011-08-08 09:56:38 -04:00
|
|
|
}
|
|
|
|
|
|
2013-02-20 17:48:23 -05:00
|
|
|
// Called from dropm to undo the effect of an minit.
|
|
|
|
|
void
|
|
|
|
|
runtime·unminit(void)
|
|
|
|
|
{
|
|
|
|
|
runtime·signalstack(nil, 0);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-08 09:56:38 -04:00
|
|
|
void
|
|
|
|
|
runtime·sigpanic(void)
|
|
|
|
|
{
|
2014-04-03 19:05:59 -04:00
|
|
|
if(!runtime·canpanic(g))
|
|
|
|
|
runtime·throw("unexpected signal during runtime execution");
|
|
|
|
|
|
2011-08-08 09:56:38 -04:00
|
|
|
switch(g->sig) {
|
|
|
|
|
case SIGBUS:
|
2014-02-20 16:18:05 -05:00
|
|
|
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
2012-01-10 11:46:57 -08:00
|
|
|
if(g->sigpc == 0)
|
|
|
|
|
runtime·panicstring("call of nil func value");
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·panicstring("invalid memory address or nil pointer dereference");
|
2012-01-10 11:46:57 -08:00
|
|
|
}
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·printf("unexpected fault address %p\n", g->sigcode1);
|
|
|
|
|
runtime·throw("fault");
|
|
|
|
|
case SIGSEGV:
|
2014-02-20 16:18:05 -05:00
|
|
|
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000 || g->paniconfault) {
|
2012-01-10 11:46:57 -08:00
|
|
|
if(g->sigpc == 0)
|
|
|
|
|
runtime·panicstring("call of nil func value");
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·panicstring("invalid memory address or nil pointer dereference");
|
2012-01-10 11:46:57 -08:00
|
|
|
}
|
2011-08-08 09:56:38 -04:00
|
|
|
runtime·printf("unexpected fault address %p\n", g->sigcode1);
|
|
|
|
|
runtime·throw("fault");
|
|
|
|
|
case SIGFPE:
|
|
|
|
|
switch(g->sigcode0) {
|
|
|
|
|
case FPE_INTDIV:
|
|
|
|
|
runtime·panicstring("integer divide by zero");
|
|
|
|
|
case FPE_INTOVF:
|
|
|
|
|
runtime·panicstring("integer overflow");
|
|
|
|
|
}
|
|
|
|
|
runtime·panicstring("floating point error");
|
|
|
|
|
}
|
|
|
|
|
runtime·panicstring(runtime·sigtab[g->sig].name);
|
|
|
|
|
}
|
2012-02-24 15:28:51 -05:00
|
|
|
|
|
|
|
|
uintptr
|
|
|
|
|
runtime·memlimit(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2012-02-28 16:18:24 -05:00
|
|
|
|
2013-03-14 11:35:13 -07:00
|
|
|
extern void runtime·sigtramp(void);
|
|
|
|
|
|
|
|
|
|
typedef struct sigaction {
|
|
|
|
|
union {
|
|
|
|
|
void (*__sa_handler)(int32);
|
|
|
|
|
void (*__sa_sigaction)(int32, Siginfo*, void *);
|
|
|
|
|
} __sigaction_u; /* signal handler */
|
|
|
|
|
uint32 sa_mask; /* signal mask to apply */
|
|
|
|
|
int32 sa_flags; /* see signal options below */
|
2014-08-29 16:00:31 -04:00
|
|
|
} SigactionT;
|
2013-03-14 11:35:13 -07:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
runtime·setsig(int32 i, GoSighandler *fn, bool restart)
|
|
|
|
|
{
|
2014-08-29 16:00:31 -04:00
|
|
|
SigactionT sa;
|
2013-03-14 11:35:13 -07:00
|
|
|
|
|
|
|
|
runtime·memclr((byte*)&sa, sizeof sa);
|
|
|
|
|
sa.sa_flags = SA_SIGINFO|SA_ONSTACK;
|
|
|
|
|
if(restart)
|
|
|
|
|
sa.sa_flags |= SA_RESTART;
|
|
|
|
|
sa.sa_mask = ~0U;
|
|
|
|
|
if(fn == runtime·sighandler)
|
|
|
|
|
fn = (void*)runtime·sigtramp;
|
|
|
|
|
sa.__sigaction_u.__sa_sigaction = (void*)fn;
|
|
|
|
|
runtime·sigaction(i, &sa, nil);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GoSighandler*
|
|
|
|
|
runtime·getsig(int32 i)
|
|
|
|
|
{
|
2014-08-29 16:00:31 -04:00
|
|
|
SigactionT sa;
|
2013-03-14 11:35:13 -07:00
|
|
|
|
|
|
|
|
runtime·memclr((byte*)&sa, sizeof sa);
|
|
|
|
|
runtime·sigaction(i, nil, &sa);
|
|
|
|
|
if((void*)sa.__sigaction_u.__sa_sigaction == runtime·sigtramp)
|
|
|
|
|
return runtime·sighandler;
|
|
|
|
|
return (void*)sa.__sigaction_u.__sa_sigaction;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
runtime·signalstack(byte *p, int32 n)
|
|
|
|
|
{
|
|
|
|
|
StackT st;
|
|
|
|
|
|
|
|
|
|
st.ss_sp = (void*)p;
|
|
|
|
|
st.ss_size = n;
|
|
|
|
|
st.ss_flags = 0;
|
|
|
|
|
if(p == nil)
|
|
|
|
|
st.ss_flags = SS_DISABLE;
|
|
|
|
|
runtime·sigaltstack(&st, nil);
|
|
|
|
|
}
|
2013-12-19 20:45:05 -05:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
runtime·unblocksignals(void)
|
|
|
|
|
{
|
2013-12-19 21:12:18 -05:00
|
|
|
runtime·sigprocmask(SIG_SETMASK, sigset_none);
|
2013-12-19 20:45:05 -05:00
|
|
|
}
|