2010-10-18 10:32:55 -06:00
|
|
|
// Copyright 2010 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 "os_GOOS.h"
|
|
|
|
#include "arch_GOARCH.h"
|
2010-10-18 10:32:55 -06:00
|
|
|
|
|
|
|
int8 *goos = "plan9";
|
2012-05-04 04:48:34 -06:00
|
|
|
int8 *runtime·exitstatus;
|
|
|
|
|
|
|
|
int32 runtime·postnote(int32, int8*);
|
2010-10-18 10:32:55 -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·minit(void)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-10-05 10:07:44 -06:00
|
|
|
static int32
|
|
|
|
getproccount(void)
|
|
|
|
{
|
|
|
|
int32 fd, i, n, ncpu;
|
|
|
|
byte buf[2048];
|
|
|
|
|
|
|
|
fd = runtime·open((byte*)"/dev/sysstat", OREAD);
|
|
|
|
if(fd < 0)
|
|
|
|
return 1;
|
|
|
|
ncpu = 0;
|
|
|
|
for(;;) {
|
|
|
|
n = runtime·read(fd, buf, sizeof buf);
|
|
|
|
if(n <= 0)
|
|
|
|
break;
|
|
|
|
for(i = 0; i < n; i++) {
|
|
|
|
if(buf[i] == '\n')
|
|
|
|
ncpu++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
runtime·close(fd);
|
|
|
|
return ncpu > 0 ? ncpu : 1;
|
|
|
|
}
|
|
|
|
|
2012-05-04 04:48:34 -06:00
|
|
|
static int32
|
|
|
|
getpid(void)
|
|
|
|
{
|
|
|
|
byte b[20], *c;
|
|
|
|
int32 fd, n;
|
|
|
|
|
|
|
|
runtime·memclr(b, sizeof(b));
|
|
|
|
fd = runtime·open((byte*)"#c/pid", 0);
|
|
|
|
if(fd >= 0) {
|
|
|
|
runtime·read(fd, b, sizeof(b));
|
|
|
|
runtime·close(fd);
|
|
|
|
}
|
|
|
|
c = b;
|
|
|
|
while(*c == ' ' || *c == '\t')
|
|
|
|
c++;
|
|
|
|
return runtime·atoi(c);
|
|
|
|
}
|
|
|
|
|
2010-10-18 10:32:55 -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)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
2011-10-05 10:07:44 -06:00
|
|
|
runtime·ncpu = getproccount();
|
2012-05-04 04:48:34 -06:00
|
|
|
m->procid = getpid();
|
|
|
|
runtime·notify(runtime·gonote);
|
2010-10-18 10:32:55 -06:00
|
|
|
}
|
|
|
|
|
2011-01-11 17:48:15 -07:00
|
|
|
void
|
|
|
|
runtime·goenvs(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-10-18 10:32:55 -06:00
|
|
|
void
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
runtime·initsig(void)
|
2011-10-05 10:07:44 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime·osyield(void)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
2011-10-05 10:07:44 -06:00
|
|
|
runtime·sleep(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime·usleep(uint32 µs)
|
|
|
|
{
|
|
|
|
uint32 ms;
|
|
|
|
|
|
|
|
ms = µs/1000;
|
|
|
|
if(ms == 0)
|
|
|
|
ms = 1;
|
|
|
|
runtime·sleep(ms);
|
2010-10-18 10:32:55 -06:00
|
|
|
}
|
|
|
|
|
2011-11-17 20:09:28 -07:00
|
|
|
int64
|
|
|
|
runtime·nanotime(void)
|
|
|
|
{
|
|
|
|
static int32 fd = -1;
|
|
|
|
byte b[8];
|
|
|
|
uint32 hi, lo;
|
|
|
|
|
|
|
|
// As long as all goroutines share the same file
|
|
|
|
// descriptor table we can get away with using
|
|
|
|
// just a static fd. Without a lock the file can
|
|
|
|
// be opened twice but that's okay.
|
|
|
|
//
|
|
|
|
// Using /dev/bintime gives us a latency on the
|
|
|
|
// order of ten microseconds between two calls.
|
|
|
|
//
|
|
|
|
// The naïve implementation (without the cached
|
|
|
|
// file descriptor) is roughly four times slower
|
|
|
|
// in 9vx on a 2.16 GHz Intel Core 2 Duo.
|
2012-02-28 14:18:24 -07:00
|
|
|
|
2011-11-17 20:09:28 -07:00
|
|
|
if(fd < 0 && (fd = runtime·open((byte*)"/dev/bintime", OREAD|OCEXEC)) < 0)
|
|
|
|
return 0;
|
|
|
|
if(runtime·pread(fd, b, sizeof b, 0) != sizeof b)
|
|
|
|
return 0;
|
|
|
|
hi = b[0]<<24 | b[1]<<16 | b[2]<<8 | b[3];
|
|
|
|
lo = b[4]<<24 | b[5]<<16 | b[6]<<8 | b[7];
|
|
|
|
return (int64)hi<<32 | (int64)lo;
|
|
|
|
}
|
|
|
|
|
2011-12-12 14:12:22 -07:00
|
|
|
void
|
|
|
|
time·now(int64 sec, int32 nsec)
|
|
|
|
{
|
|
|
|
int64 ns;
|
|
|
|
|
|
|
|
ns = runtime·nanotime();
|
|
|
|
sec = ns / 1000000000LL;
|
|
|
|
nsec = ns - sec * 1000000000LL;
|
|
|
|
FLUSH(&sec);
|
|
|
|
FLUSH(&nsec);
|
|
|
|
}
|
|
|
|
|
2010-10-18 10:32:55 -06:00
|
|
|
void
|
2012-05-04 04:48:34 -06:00
|
|
|
runtime·itoa(int32 n, byte *p, uint32 len)
|
|
|
|
{
|
|
|
|
byte *q, c;
|
|
|
|
uint32 i;
|
|
|
|
|
|
|
|
if(len <= 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
runtime·memclr(p, len);
|
|
|
|
q = p;
|
|
|
|
|
|
|
|
if(n==0) {
|
|
|
|
*q++ = '0';
|
|
|
|
USED(q);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(n < 0) {
|
|
|
|
*q++ = '-';
|
|
|
|
p++;
|
|
|
|
n = -n;
|
|
|
|
}
|
|
|
|
for(i=0; n > 0 && i < len; i++) {
|
|
|
|
*q++ = '0' + (n%10);
|
|
|
|
n = n/10;
|
|
|
|
}
|
|
|
|
for(q--; q >= p; ) {
|
|
|
|
c = *p;
|
|
|
|
*p++ = *q;
|
|
|
|
*q-- = c;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
goexitsall(void)
|
|
|
|
{
|
|
|
|
M *m;
|
|
|
|
int32 pid;
|
|
|
|
|
|
|
|
pid = getpid();
|
|
|
|
for(m=runtime·atomicloadp(&runtime·allm); m; m=m->alllink)
|
|
|
|
if(m->procid != pid)
|
|
|
|
runtime·postnote(m->procid, "gointr");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime·gonote(void*, byte *s)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
2012-05-04 04:48:34 -06:00
|
|
|
uint8 buf[128];
|
|
|
|
int32 l;
|
|
|
|
|
|
|
|
l = runtime·findnull(s);
|
|
|
|
if(l > 4 && runtime·mcmp(s, (byte*)"sys:", 4) == 0) {
|
|
|
|
runtime·memclr(buf, sizeof buf);
|
|
|
|
runtime·memmove((void*)buf, (void*)s, runtime·findnull(s));
|
|
|
|
runtime·exitstatus = (int8*)buf;
|
|
|
|
goexitsall();
|
|
|
|
runtime·noted(NDFLT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(runtime·exitstatus)
|
|
|
|
runtime·exits(runtime·exitstatus);
|
|
|
|
|
|
|
|
if(runtime·strcmp(s, (byte*)"gointr") == 0)
|
|
|
|
runtime·noted(NCONT);
|
|
|
|
|
|
|
|
runtime·noted(NDFLT);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32
|
|
|
|
runtime·postnote(int32 pid, int8* msg)
|
|
|
|
{
|
|
|
|
int32 fd, len;
|
2011-06-10 01:23:54 -06:00
|
|
|
uint8 buf[128];
|
|
|
|
uint8 tmp[16];
|
|
|
|
uint8 *p, *q;
|
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
|
|
|
|
2011-06-10 01:23:54 -06:00
|
|
|
runtime·memclr(buf, sizeof buf);
|
|
|
|
|
2012-05-04 04:48:34 -06:00
|
|
|
/* build path string /proc/pid/note */
|
|
|
|
q = tmp;
|
2011-06-10 01:23:54 -06:00
|
|
|
p = buf;
|
2012-05-04 04:48:34 -06:00
|
|
|
runtime·itoa(pid, tmp, sizeof tmp);
|
2011-07-12 18:30:40 -06:00
|
|
|
runtime·memmove((void*)p, (void*)"/proc/", 6);
|
2012-05-04 04:48:34 -06:00
|
|
|
for(p += 6; *p++ = *q++; );
|
|
|
|
p--;
|
|
|
|
runtime·memmove((void*)p, (void*)"/note", 5);
|
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
|
|
|
|
2011-06-10 01:23:54 -06:00
|
|
|
fd = runtime·open(buf, OWRITE);
|
2012-05-04 04:48:34 -06:00
|
|
|
if(fd < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
len = runtime·findnull((byte*)msg);
|
|
|
|
if(runtime·write(fd, msg, len) != len) {
|
|
|
|
runtime·close(fd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
runtime·close(fd);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
runtime·exit(int32 e)
|
|
|
|
{
|
|
|
|
byte tmp[16];
|
|
|
|
|
|
|
|
if(e == 0)
|
|
|
|
runtime·exitstatus = "";
|
|
|
|
else {
|
|
|
|
/* build error string */
|
|
|
|
runtime·itoa(e, tmp, sizeof tmp);
|
|
|
|
runtime·exitstatus = (int8*)tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
goexitsall();
|
|
|
|
runtime·exits(runtime·exitstatus);
|
2010-10-18 10:32:55 -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))
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
|
|
|
m->tls[0] = m->id; // so 386 asm can find it
|
|
|
|
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 rfork=%p id=%d/%d ostk=%p\n",
|
2010-12-06 14:38:28 -07:00
|
|
|
stk, m, g, fn, runtime·rfork, m->id, m->tls[0], &m);
|
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
|
|
|
}
|
|
|
|
|
2011-10-05 10:07:44 -06:00
|
|
|
if(runtime·rfork(RFPROC|RFMEM|RFNOWAIT, stk, m, g, fn) < 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·throw("newosproc: rfork failed");
|
2010-10-18 10:32:55 -06:00
|
|
|
}
|
|
|
|
|
2011-11-02 07:42:01 -06:00
|
|
|
uintptr
|
|
|
|
runtime·semacreate(void)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
2011-11-02 07:42:01 -06:00
|
|
|
return 1;
|
2010-10-18 10:32:55 -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·semasleep(int64 ns)
|
2010-10-18 10:32:55 -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 ret;
|
|
|
|
int32 ms;
|
|
|
|
|
|
|
|
if(ns >= 0) {
|
|
|
|
// TODO: Plan 9 needs a new system call, tsemacquire.
|
|
|
|
// The kernel implementation is the same as semacquire
|
|
|
|
// except with a tsleep and check for timeout.
|
|
|
|
// It would be great if the implementation returned the
|
|
|
|
// value that was added to the semaphore, so that on
|
|
|
|
// timeout the return value would be 0, on success 1.
|
|
|
|
// Then the error string does not have to be parsed
|
|
|
|
// to detect timeout.
|
|
|
|
//
|
|
|
|
// If a negative time indicates no timeout, then
|
|
|
|
// semacquire can be implemented (in the kernel)
|
|
|
|
// as tsemacquire(p, v, -1).
|
|
|
|
runtime·throw("semasleep: timed sleep not implemented on Plan 9");
|
|
|
|
|
|
|
|
/*
|
|
|
|
if(ns < 0)
|
|
|
|
ms = -1;
|
|
|
|
else if(ns/1000 > 0x7fffffffll)
|
|
|
|
ms = 0x7fffffff;
|
|
|
|
else
|
|
|
|
ms = ns/1000;
|
|
|
|
ret = runtime·plan9_tsemacquire(&m->waitsemacount, 1, ms);
|
|
|
|
if(ret == 1)
|
|
|
|
return 0; // success
|
|
|
|
return -1; // timeout or interrupted
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
2011-11-02 07:42:01 -06:00
|
|
|
while(runtime·plan9_semacquire(&m->waitsemacount, 1) < 0) {
|
|
|
|
/* interrupted; try again */
|
|
|
|
}
|
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; // success
|
2010-10-18 10:32:55 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-11-02 07:42:01 -06:00
|
|
|
runtime·semawakeup(M *mp)
|
2010-10-18 10:32:55 -06:00
|
|
|
{
|
2011-11-02 07:42:01 -06:00
|
|
|
runtime·plan9_semrelease(&mp->waitsemacount, 1);
|
2010-10-18 10:32:55 -06:00
|
|
|
}
|
|
|
|
|
2011-04-25 14:58:00 -06:00
|
|
|
void
|
|
|
|
os·sigpipe(void)
|
|
|
|
{
|
|
|
|
runtime·throw("too many writes on closed pipe");
|
|
|
|
}
|
2011-07-25 22:52:46 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* placeholder - once notes are implemented,
|
|
|
|
* a signal generating a panic must appear as
|
|
|
|
* a call to this function for correct handling by
|
|
|
|
* traceback.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
runtime·sigpanic(void)
|
|
|
|
{
|
|
|
|
}
|
2011-11-17 20:09:28 -07:00
|
|
|
|
|
|
|
int32
|
|
|
|
runtime·read(int32 fd, void *buf, int32 nbytes)
|
|
|
|
{
|
|
|
|
return runtime·pread(fd, buf, nbytes, -1LL);
|
|
|
|
}
|
|
|
|
|
|
|
|
int32
|
|
|
|
runtime·write(int32 fd, void *buf, int32 nbytes)
|
|
|
|
{
|
|
|
|
return runtime·pwrite(fd, buf, nbytes, -1LL);
|
|
|
|
}
|
2012-02-24 13:28:51 -07:00
|
|
|
|
|
|
|
uintptr
|
|
|
|
runtime·memlimit(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-02-28 14:18:24 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
runtime·setprof(bool on)
|
|
|
|
{
|
|
|
|
USED(on);
|
|
|
|
}
|
2012-03-08 10:12:40 -07:00
|
|
|
|
|
|
|
static int8 badcallback[] = "runtime: cgo callback on thread not created by Go.\n";
|
|
|
|
|
|
|
|
// This runs on a foreign stack, without an m or a g. No stack split.
|
|
|
|
#pragma textflag 7
|
|
|
|
void
|
|
|
|
runtime·badcallback(void)
|
|
|
|
{
|
|
|
|
runtime·pwrite(2, badcallback, sizeof badcallback - 1, -1LL);
|
|
|
|
}
|
2012-03-12 13:55:18 -06:00
|
|
|
|
|
|
|
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
|
|
|
|
|
|
|
// This runs on a foreign stack, without an m or a g. No stack split.
|
|
|
|
#pragma textflag 7
|
|
|
|
void
|
|
|
|
runtime·badsignal(void)
|
|
|
|
{
|
|
|
|
runtime·pwrite(2, badsignal, sizeof badsignal - 1, -1LL);
|
|
|
|
}
|