2008-06-21 16:36:23 -06:00
|
|
|
// Copyright 2009 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.
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-12-16 13:33:58 -07:00
|
|
|
#include "defs_GOOS_GOARCH.h"
|
|
|
|
#include "os_GOOS.h"
|
runtime: fix signal stack bug
In CL 4188061 I changed malg to allocate the requested
number of bytes n, not n+StackGuard, so that the
allocations would use rounder numbers.
The allocation of the signal stack asks for 32k and
then used g->stackguard as the base, but g->stackguard
is StackGuard bytes above the base. Previously, asking
for 32k meant getting 32k+StackGuard bytes, so using
g->stackguard as the base was safe. Now, the actual base
must be computed, so that the signal handler does not
run StackGuard bytes past the top of the stack.
Was causing flakiness mainly in programs that use the
network, because they sometimes write to closed network
connections, causing SIGPIPEs. Was also causing problems
in the doc/progs test.
Also fix Makefile so that changes to stack.h trigger rebuild.
R=bradfitzgo, r, r2
CC=golang-dev
https://golang.org/cl/4230044
2011-02-24 14:46:44 -07:00
|
|
|
#include "stack.h"
|
2008-08-04 17:43:49 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
extern SigTab runtime·sigtab[];
|
2010-04-08 19:15:30 -06:00
|
|
|
|
2012-02-23 12:44:06 -07:00
|
|
|
static Sigset sigset_all = ~(Sigset)0;
|
|
|
|
static Sigset sigset_none;
|
2012-02-28 14:18:24 -07:00
|
|
|
static Sigset sigset_prof = 1<<(SIGPROF-1);
|
2012-02-23 12:44:06 -07:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
static void
|
|
|
|
unimplemented(int8 *name)
|
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints(name);
|
|
|
|
runtime·prints(" not implemented\n");
|
2008-08-04 17:43:49 -06:00
|
|
|
*(int32*)1231 = 1231;
|
|
|
|
}
|
|
|
|
|
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 13:17:05 -07:00
|
|
|
int32
|
|
|
|
runtime·semasleep(int64 ns)
|
2008-09-24 11:25:28 -06:00
|
|
|
{
|
2012-02-28 14:18:24 -07:00
|
|
|
int32 v;
|
|
|
|
|
|
|
|
if(m->profilehz > 0)
|
|
|
|
runtime·setprof(false);
|
|
|
|
v = runtime·mach_semacquire(m->waitsema, ns);
|
|
|
|
if(m->profilehz > 0)
|
|
|
|
runtime·setprof(true);
|
|
|
|
return v;
|
2008-09-24 11:25:28 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-02 07:42:01 -06:00
|
|
|
runtime·semawakeup(M *mp)
|
2008-09-24 11:25:28 -06:00
|
|
|
{
|
2011-11-02 07:42:01 -06:00
|
|
|
runtime·mach_semrelease(mp->waitsema);
|
2008-09-24 11:25:28 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 07:42:01 -06:00
|
|
|
uintptr
|
|
|
|
runtime·semacreate(void)
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
2011-11-02 07:42:01 -06:00
|
|
|
return runtime·mach_semcreate();
|
2008-08-04 17:43:49 -06:00
|
|
|
}
|
|
|
|
|
2008-09-09 12:50:14 -06:00
|
|
|
// BSD interface for threading.
|
2008-08-04 17:43:49 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·osinit(void)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2012-01-22 11:34:17 -07:00
|
|
|
// Register our thread-creation callback (see sys_darwin_{amd64,386}.s)
|
2009-10-03 11:37:12 -06:00
|
|
|
// but only if we're not using cgo. If we are using cgo we need
|
|
|
|
// to let the C pthread libary install its own thread-creation callback.
|
2010-12-08 11:53:30 -07:00
|
|
|
if(!runtime·iscgo)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·bsdthread_register();
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
|
|
|
|
// Use sysctl to fetch hw.ncpu.
|
|
|
|
uint32 mib[2];
|
|
|
|
uint32 out;
|
|
|
|
int32 ret;
|
|
|
|
uintptr nout;
|
|
|
|
|
|
|
|
mib[0] = 6;
|
|
|
|
mib[1] = 3;
|
|
|
|
nout = sizeof out;
|
|
|
|
out = 0;
|
|
|
|
ret = runtime·sysctl(mib, 2, (byte*)&out, &nout, nil, 0);
|
|
|
|
if(ret >= 0)
|
|
|
|
runtime·ncpu = out;
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
2011-01-11 17:48:15 -07:00
|
|
|
void
|
|
|
|
runtime·goenvs(void)
|
|
|
|
{
|
|
|
|
runtime·goenvs_unix();
|
|
|
|
}
|
|
|
|
|
2008-09-09 12:50:14 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2011-01-28 13:03:26 -07:00
|
|
|
int32 errno;
|
2012-02-23 12:44:06 -07:00
|
|
|
Sigset oset;
|
2011-01-28 13:03:26 -07:00
|
|
|
|
2009-06-04 12:16:03 -06:00
|
|
|
m->tls[0] = m->id; // so 386 asm can find it
|
2009-06-17 16:15:55 -06:00
|
|
|
if(0){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
|
2009-06-17 16:15:55 -06:00
|
|
|
stk, m, g, fn, m->id, m->tls[0], &m);
|
|
|
|
}
|
2012-02-23 12:44:06 -07:00
|
|
|
|
|
|
|
runtime·sigprocmask(SIG_SETMASK, &sigset_all, &oset);
|
|
|
|
errno = runtime·bsdthread_create(stk, m, g, fn);
|
|
|
|
runtime·sigprocmask(SIG_SETMASK, &oset, nil);
|
2012-02-28 14:18:24 -07:00
|
|
|
|
2012-02-23 12:44:06 -07:00
|
|
|
if(errno < 0) {
|
2011-01-28 13:03:26 -07:00
|
|
|
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount(), -errno);
|
|
|
|
runtime·throw("runtime.newosproc");
|
|
|
|
}
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
2008-09-18 16:56:46 -06:00
|
|
|
// Called to initialize a new m (including the bootstrap m).
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·minit(void)
|
2008-09-18 16:56:46 -06:00
|
|
|
{
|
|
|
|
// Initialize signal handling.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
m->gsignal = runtime·malg(32*1024); // OS X wants >=8K, Linux >=2K
|
runtime: fix signal stack bug
In CL 4188061 I changed malg to allocate the requested
number of bytes n, not n+StackGuard, so that the
allocations would use rounder numbers.
The allocation of the signal stack asks for 32k and
then used g->stackguard as the base, but g->stackguard
is StackGuard bytes above the base. Previously, asking
for 32k meant getting 32k+StackGuard bytes, so using
g->stackguard as the base was safe. Now, the actual base
must be computed, so that the signal handler does not
run StackGuard bytes past the top of the stack.
Was causing flakiness mainly in programs that use the
network, because they sometimes write to closed network
connections, causing SIGPIPEs. Was also causing problems
in the doc/progs test.
Also fix Makefile so that changes to stack.h trigger rebuild.
R=bradfitzgo, r, r2
CC=golang-dev
https://golang.org/cl/4230044
2011-02-24 14:46:44 -07:00
|
|
|
runtime·signalstack(m->gsignal->stackguard - StackGuard, 32*1024);
|
2012-02-28 14:18:24 -07:00
|
|
|
|
|
|
|
if(m->profilehz > 0)
|
|
|
|
runtime·sigprocmask(SIG_SETMASK, &sigset_none, nil);
|
|
|
|
else
|
|
|
|
runtime·sigprocmask(SIG_SETMASK, &sigset_prof, nil);
|
2008-09-18 16:56:46 -06:00
|
|
|
}
|
|
|
|
|
2008-09-09 12:50:14 -06:00
|
|
|
// Mach IPC, to get at semaphores
|
|
|
|
// Definitions are in /usr/include/mach on a Mac.
|
|
|
|
|
|
|
|
static void
|
2009-03-24 14:51:48 -06:00
|
|
|
macherror(int32 r, int8 *fn)
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("mach error %s: %d\n", fn, r);
|
|
|
|
runtime·throw("mach error");
|
2008-08-04 17:43:49 -06:00
|
|
|
}
|
|
|
|
|
2008-09-09 12:50:14 -06:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
DebugMach = 0
|
|
|
|
};
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
static MachNDR zerondr;
|
2008-09-09 12:50:14 -06:00
|
|
|
|
|
|
|
#define MACH_MSGH_BITS(a, b) ((a) | ((b)<<8))
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
static int32
|
|
|
|
mach_msg(MachHeader *h,
|
|
|
|
int32 op,
|
|
|
|
uint32 send_size,
|
|
|
|
uint32 rcv_size,
|
|
|
|
uint32 rcv_name,
|
|
|
|
uint32 timeout,
|
|
|
|
uint32 notify)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
|
|
|
// TODO: Loop on interrupt.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
return runtime·mach_msg_trap(h, op, send_size, rcv_size, rcv_name, timeout, notify);
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Mach RPC (MIG)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
MinMachMsg = 48,
|
|
|
|
Reply = 100,
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack on
|
|
|
|
typedef struct CodeMsg CodeMsg;
|
|
|
|
struct CodeMsg
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
MachHeader h;
|
|
|
|
MachNDR NDR;
|
|
|
|
int32 code;
|
2008-09-09 12:50:14 -06:00
|
|
|
};
|
|
|
|
#pragma pack off
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
static int32
|
|
|
|
machcall(MachHeader *h, int32 maxsize, int32 rxsize)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
|
|
|
uint32 *p;
|
|
|
|
int32 i, ret, id;
|
2009-03-24 14:51:48 -06:00
|
|
|
uint32 port;
|
2008-09-09 12:50:14 -06:00
|
|
|
CodeMsg *c;
|
|
|
|
|
|
|
|
if((port = m->machport) == 0){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
port = runtime·mach_reply_port();
|
2008-09-09 12:50:14 -06:00
|
|
|
m->machport = port;
|
|
|
|
}
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
h->msgh_bits |= MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
|
|
|
|
h->msgh_local_port = port;
|
|
|
|
h->msgh_reserved = 0;
|
|
|
|
id = h->msgh_id;
|
2008-09-09 12:50:14 -06:00
|
|
|
|
|
|
|
if(DebugMach){
|
|
|
|
p = (uint32*)h;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("send:\t");
|
2009-03-24 14:51:48 -06:00
|
|
|
for(i=0; i<h->msgh_size/sizeof(p[0]); i++){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints(" ");
|
|
|
|
runtime·printpointer((void*)p[i]);
|
2008-09-09 12:50:14 -06:00
|
|
|
if(i%8 == 7)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("\n\t");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
if(i%8)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = mach_msg(h, MACH_SEND_MSG|MACH_RCV_MSG,
|
2009-03-24 14:51:48 -06:00
|
|
|
h->msgh_size, maxsize, port, 0, 0);
|
2008-09-09 12:50:14 -06:00
|
|
|
if(ret != 0){
|
|
|
|
if(DebugMach){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("mach_msg error ");
|
|
|
|
runtime·printint(ret);
|
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(DebugMach){
|
|
|
|
p = (uint32*)h;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("recv:\t");
|
2009-03-24 14:51:48 -06:00
|
|
|
for(i=0; i<h->msgh_size/sizeof(p[0]); i++){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints(" ");
|
|
|
|
runtime·printpointer((void*)p[i]);
|
2008-09-09 12:50:14 -06:00
|
|
|
if(i%8 == 7)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("\n\t");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
if(i%8)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
if(h->msgh_id != id+Reply){
|
2008-09-09 12:50:14 -06:00
|
|
|
if(DebugMach){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("mach_msg reply id mismatch ");
|
|
|
|
runtime·printint(h->msgh_id);
|
|
|
|
runtime·prints(" != ");
|
|
|
|
runtime·printint(id+Reply);
|
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
return -303; // MIG_REPLY_MISMATCH
|
|
|
|
}
|
|
|
|
|
|
|
|
// Look for a response giving the return value.
|
|
|
|
// Any call can send this back with an error,
|
|
|
|
// and some calls only have return values so they
|
|
|
|
// send it back on success too. I don't quite see how
|
|
|
|
// you know it's one of these and not the full response
|
|
|
|
// format, so just look if the message is right.
|
|
|
|
c = (CodeMsg*)h;
|
2009-03-24 14:51:48 -06:00
|
|
|
if(h->msgh_size == sizeof(CodeMsg)
|
|
|
|
&& !(h->msgh_bits & MACH_MSGH_BITS_COMPLEX)){
|
2008-09-09 12:50:14 -06:00
|
|
|
if(DebugMach){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("mig result ");
|
|
|
|
runtime·printint(c->code);
|
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
return c->code;
|
|
|
|
}
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
if(h->msgh_size != rxsize){
|
2008-09-09 12:50:14 -06:00
|
|
|
if(DebugMach){
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·prints("mach_msg reply size mismatch ");
|
|
|
|
runtime·printint(h->msgh_size);
|
|
|
|
runtime·prints(" != ");
|
|
|
|
runtime·printint(rxsize);
|
|
|
|
runtime·prints("\n");
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
return -307; // MIG_ARRAY_TOO_LARGE
|
|
|
|
}
|
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
return 0;
|
|
|
|
}
|
2008-09-09 12:50:14 -06:00
|
|
|
|
|
|
|
|
|
|
|
// Semaphores!
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2009-01-22 17:23:44 -07:00
|
|
|
Tmach_semcreate = 3418,
|
|
|
|
Rmach_semcreate = Tmach_semcreate + Reply,
|
2008-09-09 12:50:14 -06:00
|
|
|
|
2009-01-22 17:23:44 -07:00
|
|
|
Tmach_semdestroy = 3419,
|
|
|
|
Rmach_semdestroy = Tmach_semdestroy + Reply,
|
2009-06-08 15:03:21 -06:00
|
|
|
|
2009-06-08 15:09:04 -06:00
|
|
|
// Mach calls that get interrupted by Unix signals
|
|
|
|
// return this error code. We retry them.
|
2009-06-08 15:03:21 -06:00
|
|
|
KERN_ABORTED = 14,
|
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 13:17:05 -07:00
|
|
|
KERN_OPERATION_TIMED_OUT = 49,
|
2008-09-09 12:50:14 -06:00
|
|
|
};
|
|
|
|
|
2009-01-22 17:23:44 -07:00
|
|
|
typedef struct Tmach_semcreateMsg Tmach_semcreateMsg;
|
|
|
|
typedef struct Rmach_semcreateMsg Rmach_semcreateMsg;
|
|
|
|
typedef struct Tmach_semdestroyMsg Tmach_semdestroyMsg;
|
|
|
|
// Rmach_semdestroyMsg = CodeMsg
|
2008-09-09 12:50:14 -06:00
|
|
|
|
|
|
|
#pragma pack on
|
2009-01-22 17:23:44 -07:00
|
|
|
struct Tmach_semcreateMsg
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
MachHeader h;
|
|
|
|
MachNDR ndr;
|
2008-09-09 12:50:14 -06:00
|
|
|
int32 policy;
|
|
|
|
int32 value;
|
|
|
|
};
|
|
|
|
|
2009-01-22 17:23:44 -07:00
|
|
|
struct Rmach_semcreateMsg
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
MachHeader h;
|
|
|
|
MachBody body;
|
|
|
|
MachPort semaphore;
|
2008-09-09 12:50:14 -06:00
|
|
|
};
|
|
|
|
|
2009-01-22 17:23:44 -07:00
|
|
|
struct Tmach_semdestroyMsg
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
MachHeader h;
|
|
|
|
MachBody body;
|
|
|
|
MachPort semaphore;
|
2008-09-09 12:50:14 -06:00
|
|
|
};
|
|
|
|
#pragma pack off
|
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
uint32
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·mach_semcreate(void)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
|
|
|
union {
|
2009-01-22 17:23:44 -07:00
|
|
|
Tmach_semcreateMsg tx;
|
|
|
|
Rmach_semcreateMsg rx;
|
2008-09-09 12:50:14 -06:00
|
|
|
uint8 pad[MinMachMsg];
|
|
|
|
} m;
|
2009-03-24 14:51:48 -06:00
|
|
|
int32 r;
|
2008-09-09 12:50:14 -06:00
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
m.tx.h.msgh_bits = 0;
|
|
|
|
m.tx.h.msgh_size = sizeof(m.tx);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
m.tx.h.msgh_remote_port = runtime·mach_task_self();
|
2009-03-24 14:51:48 -06:00
|
|
|
m.tx.h.msgh_id = Tmach_semcreate;
|
2008-09-09 12:50:14 -06:00
|
|
|
m.tx.ndr = zerondr;
|
|
|
|
|
|
|
|
m.tx.policy = 0; // 0 = SYNC_POLICY_FIFO
|
|
|
|
m.tx.value = 0;
|
|
|
|
|
2009-06-08 15:03:21 -06:00
|
|
|
while((r = machcall(&m.tx.h, sizeof m, sizeof(m.rx))) != 0){
|
|
|
|
if(r == KERN_ABORTED) // interrupted
|
|
|
|
continue;
|
2008-09-09 12:50:14 -06:00
|
|
|
macherror(r, "semaphore_create");
|
2009-06-08 15:03:21 -06:00
|
|
|
}
|
2009-03-24 14:51:48 -06:00
|
|
|
if(m.rx.body.msgh_descriptor_count != 1)
|
2009-01-22 17:23:44 -07:00
|
|
|
unimplemented("mach_semcreate desc count");
|
2008-09-09 12:50:14 -06:00
|
|
|
return m.rx.semaphore.name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·mach_semdestroy(uint32 sem)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
|
|
|
union {
|
2009-01-22 17:23:44 -07:00
|
|
|
Tmach_semdestroyMsg tx;
|
2008-09-09 12:50:14 -06:00
|
|
|
uint8 pad[MinMachMsg];
|
|
|
|
} m;
|
2009-03-24 14:51:48 -06:00
|
|
|
int32 r;
|
2008-09-09 12:50:14 -06:00
|
|
|
|
2009-03-24 14:51:48 -06:00
|
|
|
m.tx.h.msgh_bits = MACH_MSGH_BITS_COMPLEX;
|
|
|
|
m.tx.h.msgh_size = sizeof(m.tx);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
m.tx.h.msgh_remote_port = runtime·mach_task_self();
|
2009-03-24 14:51:48 -06:00
|
|
|
m.tx.h.msgh_id = Tmach_semdestroy;
|
|
|
|
m.tx.body.msgh_descriptor_count = 1;
|
2008-09-09 12:50:14 -06:00
|
|
|
m.tx.semaphore.name = sem;
|
|
|
|
m.tx.semaphore.disposition = MACH_MSG_TYPE_MOVE_SEND;
|
|
|
|
m.tx.semaphore.type = 0;
|
|
|
|
|
2009-06-08 15:03:21 -06:00
|
|
|
while((r = machcall(&m.tx.h, sizeof m, 0)) != 0){
|
2009-07-27 11:59:59 -06:00
|
|
|
if(r == KERN_ABORTED) // interrupted
|
|
|
|
continue;
|
2008-09-09 12:50:14 -06:00
|
|
|
macherror(r, "semaphore_destroy");
|
2009-06-08 15:03:21 -06:00
|
|
|
}
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
2012-01-22 11:34:17 -07:00
|
|
|
// The other calls have simple system call traps in sys_darwin_{amd64,386}.s
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
int32 runtime·mach_semaphore_wait(uint32 sema);
|
|
|
|
int32 runtime·mach_semaphore_timedwait(uint32 sema, uint32 sec, uint32 nsec);
|
|
|
|
int32 runtime·mach_semaphore_signal(uint32 sema);
|
|
|
|
int32 runtime·mach_semaphore_signal_all(uint32 sema);
|
2008-09-09 12:50:14 -06: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 13:17:05 -07:00
|
|
|
int32
|
|
|
|
runtime·mach_semacquire(uint32 sem, int64 ns)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
int32 r;
|
2008-09-09 12:50:14 -06: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 13:17:05 -07:00
|
|
|
if(ns >= 0) {
|
|
|
|
r = runtime·mach_semaphore_timedwait(sem, ns/1000000000LL, ns%1000000000LL);
|
|
|
|
if(r == KERN_ABORTED || r == KERN_OPERATION_TIMED_OUT)
|
|
|
|
return -1;
|
|
|
|
if(r != 0)
|
|
|
|
macherror(r, "semaphore_wait");
|
|
|
|
return 0;
|
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
while((r = runtime·mach_semaphore_wait(sem)) != 0) {
|
2009-06-08 15:03:21 -06:00
|
|
|
if(r == KERN_ABORTED) // interrupted
|
|
|
|
continue;
|
2008-09-09 12:50:14 -06:00
|
|
|
macherror(r, "semaphore_wait");
|
2009-06-08 15:03:21 -06: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 13:17:05 -07:00
|
|
|
return 0;
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·mach_semrelease(uint32 sem)
|
2008-09-09 12:50:14 -06:00
|
|
|
{
|
2009-03-24 14:51:48 -06:00
|
|
|
int32 r;
|
2008-09-09 12:50:14 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
while((r = runtime·mach_semaphore_signal(sem)) != 0) {
|
2009-06-08 15:03:21 -06:00
|
|
|
if(r == KERN_ABORTED) // interrupted
|
|
|
|
continue;
|
2008-09-09 12:50:14 -06:00
|
|
|
macherror(r, "semaphore_signal");
|
2009-06-08 15:03:21 -06:00
|
|
|
}
|
2008-09-09 12:50:14 -06:00
|
|
|
}
|
|
|
|
|
2010-04-08 19:15:30 -06:00
|
|
|
void
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·sigpanic(void)
|
2010-04-08 19:15:30 -06:00
|
|
|
{
|
|
|
|
switch(g->sig) {
|
|
|
|
case SIGBUS:
|
2012-01-10 12:46:57 -07:00
|
|
|
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
|
|
|
|
if(g->sigpc == 0)
|
|
|
|
runtime·panicstring("call of nil func value");
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("invalid memory address or nil pointer dereference");
|
2012-01-10 12:46:57 -07:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("unexpected fault address %p\n", g->sigcode1);
|
|
|
|
runtime·throw("fault");
|
2010-04-08 19:15:30 -06:00
|
|
|
case SIGSEGV:
|
2012-01-10 12:46:57 -07:00
|
|
|
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
|
|
|
|
if(g->sigpc == 0)
|
|
|
|
runtime·panicstring("call of nil func value");
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("invalid memory address or nil pointer dereference");
|
2012-01-10 12:46:57 -07:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·printf("unexpected fault address %p\n", g->sigcode1);
|
|
|
|
runtime·throw("fault");
|
2010-04-08 19:15:30 -06:00
|
|
|
case SIGFPE:
|
|
|
|
switch(g->sigcode0) {
|
|
|
|
case FPE_INTDIV:
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("integer divide by zero");
|
2010-04-08 19:15:30 -06:00
|
|
|
case FPE_INTOVF:
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("integer overflow");
|
2010-04-08 19:15:30 -06:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring("floating point error");
|
2010-04-08 19:15:30 -06:00
|
|
|
}
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
runtime·panicstring(runtime·sigtab[g->sig].name);
|
2010-04-08 19:15:30 -06:00
|
|
|
}
|
2011-09-30 11:52:36 -06:00
|
|
|
|
|
|
|
// TODO(rsc): place holder to fix build.
|
|
|
|
void
|
|
|
|
runtime·osyield(void)
|
|
|
|
{
|
|
|
|
}
|
2012-02-24 13:28:51 -07:00
|
|
|
|
|
|
|
uintptr
|
|
|
|
runtime·memlimit(void)
|
|
|
|
{
|
|
|
|
// NOTE(rsc): Could use getrlimit here,
|
|
|
|
// like on FreeBSD or Linux, but Darwin doesn't enforce
|
|
|
|
// ulimit -v, so it's unclear why we'd try to stay within
|
|
|
|
// the limit.
|
|
|
|
return 0;
|
|
|
|
}
|
2012-02-28 14:18:24 -07:00
|
|
|
|
|
|
|
// NOTE(rsc): On OS X, when the CPU profiling timer expires, the SIGPROF
|
|
|
|
// signal is not guaranteed to be sent to the thread that was executing to
|
|
|
|
// cause it to expire. It can and often does go to a sleeping thread, which is
|
|
|
|
// not interesting for our profile. This is filed Apple Bug Report #9177434,
|
|
|
|
// copied to http://code.google.com/p/go/source/detail?r=35b716c94225.
|
|
|
|
// To work around this bug, we disable receipt of the profiling signal on
|
|
|
|
// a thread while in blocking system calls. This forces the kernel to deliver
|
|
|
|
// the profiling signal to an executing thread.
|
|
|
|
//
|
|
|
|
// The workaround fails on OS X machines using a 64-bit Snow Leopard kernel.
|
|
|
|
// In that configuration, the kernel appears to want to deliver SIGPROF to the
|
|
|
|
// sleeping threads regardless of signal mask and, worse, does not deliver
|
|
|
|
// the signal until the thread wakes up on its own.
|
|
|
|
//
|
|
|
|
// If necessary, we can switch to using ITIMER_REAL for OS X and handle
|
|
|
|
// the kernel-generated SIGALRM by generating our own SIGALRMs to deliver
|
|
|
|
// to all the running threads. SIGALRM does not appear to be affected by
|
|
|
|
// the 64-bit Snow Leopard bug. However, as of this writing Mountain Lion
|
|
|
|
// is in preview, making Snow Leopard two versions old, so it is unclear how
|
|
|
|
// much effort we need to spend on one buggy kernel.
|
|
|
|
|
|
|
|
// Control whether profiling signal can be delivered to this thread.
|
|
|
|
void
|
|
|
|
runtime·setprof(bool on)
|
|
|
|
{
|
|
|
|
if(on)
|
|
|
|
runtime·sigprocmask(SIG_UNBLOCK, &sigset_prof, nil);
|
|
|
|
else
|
|
|
|
runtime·sigprocmask(SIG_BLOCK, &sigset_prof, nil);
|
|
|
|
}
|