Commit e088e162 authored by Aram Hăvărneanu's avatar Aram Hăvărneanu

[dev.cc] runtime: convert Solaris port to Go

Memory management was consolitated with the BSD ports, since
it was almost identical.

Assembly thunks are gone, being replaced by the new //go:linkname
feature.

This change supersedes CL 138390043 (runtime: convert solaris
netpoll to Go), which was previously reviewed and tested.

This change is only the first step, the port now builds,
but doesn't run. Binaries fail to exec:

    ld.so.1: 6.out: fatal: 6.out: TLS requirement failure : TLS support is unavailable
    Killed

This seems to happen because binaries don't link with libc.so
anymore. We will have to solve that in a different CL.

Also this change is just a rough translation of the original
C code, cleanup will come in a different CL.

[This CL is part of the removal of C code from package runtime.
See golang.org/s/dev.cc for an overview.]

LGTM=rsc
R=rsc, dave
CC=golang-codereviews, iant, khr, minux, r, rlh
https://golang.org/cl/174960043
parent a0862a17
......@@ -1543,9 +1543,8 @@ static vlong vaddr(Link*, Addr*, Reloc*);
static int
isextern(LSym *s)
{
// All the Solaris dynamic imports from libc.so begin with "libc·", which
// the compiler rewrites to "libc." by the time liblink gets it.
return strncmp(s->name, "libc.", 5) == 0;
// All the Solaris dynamic imports from libc.so begin with "libc_".
return strncmp(s->name, "libc_", 5) == 0;
}
// single-instruction no-ops of various lengths.
......
......@@ -172,6 +172,10 @@ type timeval struct {
tv_usec int64
}
func (tv *timeval) set_usec(x int32) {
tv.tv_usec = int64(x)
}
type itimerval struct {
it_interval timeval
it_value timeval
......@@ -185,6 +189,7 @@ type portevent struct {
portev_user *byte
}
type pthread uint32
type pthreadattr struct {
__pthread_attrp *byte
}
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build dragonfly freebsd netbsd openbsd
// +build dragonfly freebsd netbsd openbsd solaris
package runtime
......
// 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"
#include "arch_GOARCH.h"
#include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h"
#include "malloc.h"
#include "textflag.h"
enum
{
ENOMEM = 12,
};
#pragma textflag NOSPLIT
void*
runtime·sysAlloc(uintptr n, uint64 *stat)
{
void *v;
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096)
return nil;
runtime·xadd64(stat, n);
return v;
}
void
runtime·SysUnused(void *v, uintptr n)
{
USED(v);
USED(n);
}
void
runtime·SysUsed(void *v, uintptr n)
{
USED(v);
USED(n);
}
void
runtime·SysFree(void *v, uintptr n, uint64 *stat)
{
runtime·xadd64(stat, -(uint64)n);
runtime·munmap(v, n);
}
void
runtime·SysFault(void *v, uintptr n)
{
runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, 0);
}
void*
runtime·SysReserve(void *v, uintptr n, bool *reserved)
{
void *p;
// On 64-bit, people with ulimit -v set complain if we reserve too
// much address space. Instead, assume that the reservation is okay
// and check the assumption in SysMap.
if(sizeof(void*) == 8 && n > 1LL<<32) {
*reserved = false;
return v;
}
p = runtime·mmap(v, n, PROT_NONE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p < (void*)4096)
return nil;
*reserved = true;
return p;
}
void
runtime·SysMap(void *v, uintptr n, bool reserved, uint64 *stat)
{
void *p;
runtime·xadd64(stat, n);
// On 64-bit, we don't actually have v reserved, so tread carefully.
if(!reserved) {
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM)
runtime·throw("runtime: out of memory");
if(p != v) {
runtime·printf("runtime: address space conflict: map(%p) = %p\n", v, p);
runtime·throw("runtime: address space conflict");
}
return;
}
p = runtime·mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0);
if(p == (void*)ENOMEM)
runtime·throw("runtime: out of memory");
if(p != v)
runtime·throw("runtime: cannot map pages in arena address space");
}
......@@ -49,14 +49,14 @@ type pollDesc struct {
lock mutex // protectes the following fields
fd uintptr
closing bool
seq uintptr // protects from stale timers and ready notifications
rg uintptr // pdReady, pdWait, G waiting for read or nil
rt timer // read deadline timer (set if rt.f != nil)
rd int64 // read deadline
wg uintptr // pdReady, pdWait, G waiting for write or nil
wt timer // write deadline timer
wd int64 // write deadline
user unsafe.Pointer // user settable cookie
seq uintptr // protects from stale timers and ready notifications
rg uintptr // pdReady, pdWait, G waiting for read or nil
rt timer // read deadline timer (set if rt.f != nil)
rd int64 // read deadline
wg uintptr // pdReady, pdWait, G waiting for write or nil
wt timer // write deadline timer
wd int64 // write deadline
user uint32 // user settable cookie
}
type pollCache struct {
......@@ -72,7 +72,7 @@ type pollCache struct {
var pollcache pollCache
func netpollServerInit() {
systemstack(netpollinit)
netpollinit()
}
func netpollOpen(fd uintptr) (*pollDesc, int) {
......@@ -94,9 +94,7 @@ func netpollOpen(fd uintptr) (*pollDesc, int) {
unlock(&pd.lock)
var errno int32
systemstack(func() {
errno = netpollopen(fd, pd)
})
errno = netpollopen(fd, pd)
return pd, int(errno)
}
......@@ -110,9 +108,7 @@ func netpollClose(pd *pollDesc) {
if pd.rg != 0 && pd.rg != pdReady {
gothrow("netpollClose: blocked read on closing descriptor")
}
systemstack(func() {
netpollclose(uintptr(pd.fd))
})
netpollclose(uintptr(pd.fd))
pollcache.free(pd)
}
......@@ -143,9 +139,7 @@ func netpollWait(pd *pollDesc, mode int) int {
}
// As for now only Solaris uses level-triggered IO.
if GOOS == "solaris" {
systemstack(func() {
netpollarm(pd, mode)
})
netpollarm(pd, mode)
}
for !netpollblock(pd, int32(mode), false) {
err = netpollcheckerr(pd, int32(mode))
......@@ -263,26 +257,6 @@ func netpollUnblock(pd *pollDesc) {
}
}
func netpollfd(pd *pollDesc) uintptr {
return pd.fd
}
func netpolluser(pd *pollDesc) *unsafe.Pointer {
return &pd.user
}
func netpollclosing(pd *pollDesc) bool {
return pd.closing
}
func netpolllock(pd *pollDesc) {
lock(&pd.lock)
}
func netpollunlock(pd *pollDesc) {
unlock(&pd.lock)
}
// make pd ready, newly runnable goroutines (if any) are returned in rg/wg
func netpollready(gpp **g, pd *pollDesc, mode int32) {
var rg, wg *g
......
// Copyright 2014 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.
package runtime
const (
_SS_DISABLE = 2
_SIG_SETMASK = 3
_NSIG = 73 /* number of signals in sigtable array */
_SI_USER = 0
_RLIMIT_AS = 10
)
This diff is collapsed.
This diff is collapsed.
......@@ -6,53 +6,35 @@ package runtime
import "unsafe"
func setitimer(mode int32, new, old unsafe.Pointer)
func sigaction(sig int32, new, old unsafe.Pointer)
func sigaltstack(new, old unsafe.Pointer)
func sigprocmask(mode int32, new, old unsafe.Pointer)
func sysctl(mib *uint32, miblen uint32, out *byte, size *uintptr, dst *byte, ndst uintptr) int32
func getrlimit(kind int32, limit unsafe.Pointer)
func miniterrno(fn unsafe.Pointer)
func raise(sig int32)
func getcontext(ctxt unsafe.Pointer)
func tstart_sysvicall(mm unsafe.Pointer) uint32
func nanotime1() int64
func usleep1(usec uint32)
func osyield1()
func netpollinit()
func netpollopen(fd uintptr, pd *pollDesc) int32
func netpollclose(fd uintptr) int32
func netpollarm(pd *pollDesc, mode int)
type libcFunc byte
type libcFunc uintptr
var asmsysvicall6 libcFunc
//go:nosplit
func sysvicall0(fn *libcFunc) uintptr {
func sysvicall0(fn libcFunc) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 0
// TODO(rsc): Why is noescape necessary here and below?
libcall.args = uintptr(noescape(unsafe.Pointer(&fn))) // it's unused but must be non-nil, otherwise crashes
libcall.args = uintptr(fn) // it's unused but must be non-nil, otherwise crashes
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
//go:nosplit
func sysvicall1(fn *libcFunc, a1 uintptr) uintptr {
func sysvicall1(fn libcFunc, a1 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 1
// TODO(rsc): Why is noescape necessary here and below?
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
return libcall.r1
}
//go:nosplit
func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
func sysvicall2(fn libcFunc, a1, a2 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 2
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
......@@ -60,9 +42,9 @@ func sysvicall2(fn *libcFunc, a1, a2 uintptr) uintptr {
}
//go:nosplit
func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
func sysvicall3(fn libcFunc, a1, a2, a3 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 3
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
......@@ -70,9 +52,9 @@ func sysvicall3(fn *libcFunc, a1, a2, a3 uintptr) uintptr {
}
//go:nosplit
func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
func sysvicall4(fn libcFunc, a1, a2, a3, a4 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 4
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
......@@ -80,9 +62,9 @@ func sysvicall4(fn *libcFunc, a1, a2, a3, a4 uintptr) uintptr {
}
//go:nosplit
func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
func sysvicall5(fn libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 5
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
......@@ -90,9 +72,9 @@ func sysvicall5(fn *libcFunc, a1, a2, a3, a4, a5 uintptr) uintptr {
}
//go:nosplit
func sysvicall6(fn *libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
func sysvicall6(fn libcFunc, a1, a2, a3, a4, a5, a6 uintptr) uintptr {
libcall := &getg().m.libcall
libcall.fn = uintptr(unsafe.Pointer(fn))
libcall.fn = uintptr(fn)
libcall.n = 6
libcall.args = uintptr(noescape(unsafe.Pointer(&a1)))
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(libcall))
......
// Copyright 2014 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.
typedef uintptr kevent_udata;
struct sigaction;
void runtime·sigpanic(void);
void runtime·setitimer(int32, Itimerval*, Itimerval*);
void runtime·sigaction(int32, struct SigactionT*, struct SigactionT*);
void runtime·sigaltstack(SigaltstackT*, SigaltstackT*);
void runtime·sigprocmask(int32, Sigset*, Sigset*);
void runtime·unblocksignals(void);
int32 runtime·sysctl(uint32*, uint32, byte*, uintptr*, byte*, uintptr);
void runtime·raisesigpipe(void);
void runtime·setsig(int32, void(*)(int32, Siginfo*, void*, G*), bool);
void runtime·sighandler(int32 sig, Siginfo *info, void *context, G *gp);
void runtime·sigpanic(void);
enum {
SS_DISABLE = 2,
SIG_BLOCK = 1,
SIG_UNBLOCK = 2,
SIG_SETMASK = 3,
NSIG = 73, /* number of signals in runtime·SigTab array */
SI_USER = 0,
_UC_SIGMASK = 0x01,
_UC_CPU = 0x04,
RLIMIT_AS = 10,
};
typedef struct Rlimit Rlimit;
struct Rlimit {
int64 rlim_cur;
int64 rlim_max;
};
int32 runtime·getrlimit(int32, Rlimit*);
// Call an external library function described by {fn, a0, ..., an}, with
// SysV conventions, switching to os stack during the call, if necessary.
uintptr runtime·sysvicall0(uintptr fn);
uintptr runtime·sysvicall1(uintptr fn, uintptr a1);
uintptr runtime·sysvicall2(uintptr fn, uintptr a1, uintptr a2);
uintptr runtime·sysvicall3(uintptr fn, uintptr a1, uintptr a2, uintptr a3);
uintptr runtime·sysvicall4(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4);
uintptr runtime·sysvicall5(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5);
uintptr runtime·sysvicall6(uintptr fn, uintptr a1, uintptr a2, uintptr a3, uintptr a4, uintptr a5, uintptr a6);
void runtime·asmsysvicall6(void *c);
void runtime·miniterrno(void *fn);
// Copyright 2014 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.
package runtime
type sigTabT struct {
flags int32
name string
}
var sigtable = [...]sigTabT{
/* 0 */ {0, "SIGNONE: no trap"},
/* 1 */ {_SigNotify + _SigKill, "SIGHUP: hangup"},
/* 2 */ {_SigNotify + _SigKill, "SIGINT: interrupt (rubout)"},
/* 3 */ {_SigNotify + _SigThrow, "SIGQUIT: quit (ASCII FS)"},
/* 4 */ {_SigThrow, "SIGILL: illegal instruction (not reset when caught)"},
/* 5 */ {_SigThrow, "SIGTRAP: trace trap (not reset when caught)"},
/* 6 */ {_SigNotify + _SigThrow, "SIGABRT: used by abort, replace SIGIOT in the future"},
/* 7 */ {_SigThrow, "SIGEMT: EMT instruction"},
/* 8 */ {_SigPanic, "SIGFPE: floating point exception"},
/* 9 */ {0, "SIGKILL: kill (cannot be caught or ignored)"},
/* 10 */ {_SigPanic, "SIGBUS: bus error"},
/* 11 */ {_SigPanic, "SIGSEGV: segmentation violation"},
/* 12 */ {_SigThrow, "SIGSYS: bad argument to system call"},
/* 13 */ {_SigNotify, "SIGPIPE: write on a pipe with no one to read it"},
/* 14 */ {_SigNotify, "SIGALRM: alarm clock"},
/* 15 */ {_SigNotify + _SigKill, "SIGTERM: software termination signal from kill"},
/* 16 */ {_SigNotify, "SIGUSR1: user defined signal 1"},
/* 17 */ {_SigNotify, "SIGUSR2: user defined signal 2"},
/* 18 */ {_SigNotify, "SIGCHLD: child status change alias (POSIX)"},
/* 19 */ {_SigNotify, "SIGPWR: power-fail restart"},
/* 20 */ {_SigNotify, "SIGWINCH: window size change"},
/* 21 */ {_SigNotify, "SIGURG: urgent socket condition"},
/* 22 */ {_SigNotify, "SIGPOLL: pollable event occured"},
/* 23 */ {_SigNotify + _SigDefault, "SIGSTOP: stop (cannot be caught or ignored)"},
/* 24 */ {0, "SIGTSTP: user stop requested from tty"},
/* 25 */ {0, "SIGCONT: stopped process has been continued"},
/* 26 */ {_SigNotify + _SigDefault, "SIGTTIN: background tty read attempted"},
/* 27 */ {_SigNotify + _SigDefault, "SIGTTOU: background tty write attempted"},
/* 28 */ {_SigNotify, "SIGVTALRM: virtual timer expired"},
/* 29 */ {_SigNotify, "SIGPROF: profiling timer expired"},
/* 30 */ {_SigNotify, "SIGXCPU: exceeded cpu limit"},
/* 31 */ {_SigNotify, "SIGXFSZ: exceeded file size limit"},
/* 32 */ {_SigNotify, "SIGWAITING: reserved signal no longer used by"},
/* 33 */ {_SigNotify, "SIGLWP: reserved signal no longer used by"},
/* 34 */ {_SigNotify, "SIGFREEZE: special signal used by CPR"},
/* 35 */ {_SigNotify, "SIGTHAW: special signal used by CPR"},
/* 36 */ {0, "SIGCANCEL: reserved signal for thread cancellation"},
/* 37 */ {_SigNotify, "SIGLOST: resource lost (eg, record-lock lost)"},
/* 38 */ {_SigNotify, "SIGXRES: resource control exceeded"},
/* 39 */ {_SigNotify, "SIGJVM1: reserved signal for Java Virtual Machine"},
/* 40 */ {_SigNotify, "SIGJVM2: reserved signal for Java Virtual Machine"},
/* TODO(aram): what should be do about these signals? _SigDefault or _SigNotify? is this set static? */
/* 41 */ {_SigNotify, "real time signal"},
/* 42 */ {_SigNotify, "real time signal"},
/* 43 */ {_SigNotify, "real time signal"},
/* 44 */ {_SigNotify, "real time signal"},
/* 45 */ {_SigNotify, "real time signal"},
/* 46 */ {_SigNotify, "real time signal"},
/* 47 */ {_SigNotify, "real time signal"},
/* 48 */ {_SigNotify, "real time signal"},
/* 49 */ {_SigNotify, "real time signal"},
/* 50 */ {_SigNotify, "real time signal"},
/* 51 */ {_SigNotify, "real time signal"},
/* 52 */ {_SigNotify, "real time signal"},
/* 53 */ {_SigNotify, "real time signal"},
/* 54 */ {_SigNotify, "real time signal"},
/* 55 */ {_SigNotify, "real time signal"},
/* 56 */ {_SigNotify, "real time signal"},
/* 57 */ {_SigNotify, "real time signal"},
/* 58 */ {_SigNotify, "real time signal"},
/* 59 */ {_SigNotify, "real time signal"},
/* 60 */ {_SigNotify, "real time signal"},
/* 61 */ {_SigNotify, "real time signal"},
/* 62 */ {_SigNotify, "real time signal"},
/* 63 */ {_SigNotify, "real time signal"},
/* 64 */ {_SigNotify, "real time signal"},
/* 65 */ {_SigNotify, "real time signal"},
/* 66 */ {_SigNotify, "real time signal"},
/* 67 */ {_SigNotify, "real time signal"},
/* 68 */ {_SigNotify, "real time signal"},
/* 69 */ {_SigNotify, "real time signal"},
/* 70 */ {_SigNotify, "real time signal"},
/* 71 */ {_SigNotify, "real time signal"},
/* 72 */ {_SigNotify, "real time signal"},
}
// Copyright 2014 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.
package runtime
import "unsafe"
type sigctxt struct {
info *siginfo
ctxt unsafe.Pointer
}
func (c *sigctxt) regs() *mcontext {
return (*mcontext)(unsafe.Pointer(&(*ucontext)(c.ctxt).uc_mcontext))
}
func (c *sigctxt) rax() uint64 { return uint64(c.regs().gregs[_REG_RAX]) }
func (c *sigctxt) rbx() uint64 { return uint64(c.regs().gregs[_REG_RBX]) }
func (c *sigctxt) rcx() uint64 { return uint64(c.regs().gregs[_REG_RCX]) }
func (c *sigctxt) rdx() uint64 { return uint64(c.regs().gregs[_REG_RDX]) }
func (c *sigctxt) rdi() uint64 { return uint64(c.regs().gregs[_REG_RDI]) }
func (c *sigctxt) rsi() uint64 { return uint64(c.regs().gregs[_REG_RSI]) }
func (c *sigctxt) rbp() uint64 { return uint64(c.regs().gregs[_REG_RBP]) }
func (c *sigctxt) rsp() uint64 { return uint64(c.regs().gregs[_REG_RSP]) }
func (c *sigctxt) r8() uint64 { return uint64(c.regs().gregs[_REG_R8]) }
func (c *sigctxt) r9() uint64 { return uint64(c.regs().gregs[_REG_R9]) }
func (c *sigctxt) r10() uint64 { return uint64(c.regs().gregs[_REG_R10]) }
func (c *sigctxt) r11() uint64 { return uint64(c.regs().gregs[_REG_R11]) }
func (c *sigctxt) r12() uint64 { return uint64(c.regs().gregs[_REG_R12]) }
func (c *sigctxt) r13() uint64 { return uint64(c.regs().gregs[_REG_R13]) }
func (c *sigctxt) r14() uint64 { return uint64(c.regs().gregs[_REG_R14]) }
func (c *sigctxt) r15() uint64 { return uint64(c.regs().gregs[_REG_R15]) }
func (c *sigctxt) rip() uint64 { return uint64(c.regs().gregs[_REG_RIP]) }
func (c *sigctxt) rflags() uint64 { return uint64(c.regs().gregs[_REG_RFLAGS]) }
func (c *sigctxt) cs() uint64 { return uint64(c.regs().gregs[_REG_CS]) }
func (c *sigctxt) fs() uint64 { return uint64(c.regs().gregs[_REG_FS]) }
func (c *sigctxt) gs() uint64 { return uint64(c.regs().gregs[_REG_GS]) }
func (c *sigctxt) sigcode() uint64 { return uint64(c.info.si_code) }
func (c *sigctxt) sigaddr() uint64 { return uint64(uintptr(unsafe.Pointer(&c.info.__data[0]))) }
func (c *sigctxt) set_rip(x uint64) { c.regs().gregs[_REG_RIP] = int64(x) }
func (c *sigctxt) set_rsp(x uint64) { c.regs().gregs[_REG_RSP] = int64(x) }
func (c *sigctxt) set_sigcode(x uint64) { c.info.si_code = int32(x) }
func (c *sigctxt) set_sigaddr(x uint64) {
*(*uintptr)(unsafe.Pointer(&c.info.__data[0])) = uintptr(x)
}
// Copyright 2014 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.
#define SIG_REGS(ctxt) (((Ucontext*)(ctxt))->uc_mcontext)
#define SIG_RAX(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RAX])
#define SIG_RBX(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RBX])
#define SIG_RCX(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RCX])
#define SIG_RDX(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RDX])
#define SIG_RDI(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RDI])
#define SIG_RSI(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RSI])
#define SIG_RBP(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RBP])
#define SIG_RSP(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RSP])
#define SIG_R8(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R8])
#define SIG_R9(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R9])
#define SIG_R10(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R10])
#define SIG_R11(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R11])
#define SIG_R12(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R12])
#define SIG_R13(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R13])
#define SIG_R14(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R14])
#define SIG_R15(info, ctxt) (SIG_REGS(ctxt).gregs[REG_R15])
#define SIG_RIP(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RIP])
#define SIG_RFLAGS(info, ctxt) (SIG_REGS(ctxt).gregs[REG_RFLAGS])
#define SIG_CS(info, ctxt) (SIG_REGS(ctxt).gregs[REG_CS])
#define SIG_FS(info, ctxt) (SIG_REGS(ctxt).gregs[REG_FS])
#define SIG_GS(info, ctxt) (SIG_REGS(ctxt).gregs[REG_GS])
#define SIG_CODE0(info, ctxt) ((info)->si_code)
#define SIG_CODE1(info, ctxt) (*(uintptr*)&(info)->__data[0])
// Copyright 2014 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 "textflag.h"
#define N SigNotify
#define K SigKill
#define T SigThrow
#define P SigPanic
#define D SigDefault
#pragma dataflag NOPTR
SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap",
/* 1 */ N+K, "SIGHUP: hangup",
/* 2 */ N+K, "SIGINT: interrupt (rubout)",
/* 3 */ N+T, "SIGQUIT: quit (ASCII FS)",
/* 4 */ T, "SIGILL: illegal instruction (not reset when caught)",
/* 5 */ T, "SIGTRAP: trace trap (not reset when caught)",
/* 6 */ N+T, "SIGABRT: used by abort, replace SIGIOT in the future",
/* 7 */ T, "SIGEMT: EMT instruction",
/* 8 */ P, "SIGFPE: floating point exception",
/* 9 */ 0, "SIGKILL: kill (cannot be caught or ignored)",
/* 10 */ P, "SIGBUS: bus error",
/* 11 */ P, "SIGSEGV: segmentation violation",
/* 12 */ T, "SIGSYS: bad argument to system call",
/* 13 */ N, "SIGPIPE: write on a pipe with no one to read it",
/* 14 */ N, "SIGALRM: alarm clock",
/* 15 */ N+K, "SIGTERM: software termination signal from kill",
/* 16 */ N, "SIGUSR1: user defined signal 1",
/* 17 */ N, "SIGUSR2: user defined signal 2",
/* 18 */ N, "SIGCLD: child status change",
/* 18 */ N, "SIGCHLD: child status change alias (POSIX)",
/* 19 */ N, "SIGPWR: power-fail restart",
/* 20 */ N, "SIGWINCH: window size change",
/* 21 */ N, "SIGURG: urgent socket condition",
/* 22 */ N, "SIGPOLL: pollable event occured",
/* 23 */ N+D, "SIGSTOP: stop (cannot be caught or ignored)",
/* 24 */ 0, "SIGTSTP: user stop requested from tty",
/* 25 */ 0, "SIGCONT: stopped process has been continued",
/* 26 */ N+D, "SIGTTIN: background tty read attempted",
/* 27 */ N+D, "SIGTTOU: background tty write attempted",
/* 28 */ N, "SIGVTALRM: virtual timer expired",
/* 29 */ N, "SIGPROF: profiling timer expired",
/* 30 */ N, "SIGXCPU: exceeded cpu limit",
/* 31 */ N, "SIGXFSZ: exceeded file size limit",
/* 32 */ N, "SIGWAITING: reserved signal no longer used by",
/* 33 */ N, "SIGLWP: reserved signal no longer used by",
/* 34 */ N, "SIGFREEZE: special signal used by CPR",
/* 35 */ N, "SIGTHAW: special signal used by CPR",
/* 36 */ 0, "SIGCANCEL: reserved signal for thread cancellation",
/* 37 */ N, "SIGLOST: resource lost (eg, record-lock lost)",
/* 38 */ N, "SIGXRES: resource control exceeded",
/* 39 */ N, "SIGJVM1: reserved signal for Java Virtual Machine",
/* 40 */ N, "SIGJVM2: reserved signal for Java Virtual Machine",
/* TODO(aram): what should be do about these signals? D or N? is this set static? */
/* 41 */ N, "real time signal",
/* 42 */ N, "real time signal",
/* 43 */ N, "real time signal",
/* 44 */ N, "real time signal",
/* 45 */ N, "real time signal",
/* 46 */ N, "real time signal",
/* 47 */ N, "real time signal",
/* 48 */ N, "real time signal",
/* 49 */ N, "real time signal",
/* 50 */ N, "real time signal",
/* 51 */ N, "real time signal",
/* 52 */ N, "real time signal",
/* 53 */ N, "real time signal",
/* 54 */ N, "real time signal",
/* 55 */ N, "real time signal",
/* 56 */ N, "real time signal",
/* 57 */ N, "real time signal",
/* 58 */ N, "real time signal",
/* 59 */ N, "real time signal",
/* 60 */ N, "real time signal",
/* 61 */ N, "real time signal",
/* 62 */ N, "real time signal",
/* 63 */ N, "real time signal",
/* 64 */ N, "real time signal",
/* 65 */ N, "real time signal",
/* 66 */ N, "real time signal",
/* 67 */ N, "real time signal",
/* 68 */ N, "real time signal",
/* 69 */ N, "real time signal",
/* 70 */ N, "real time signal",
/* 71 */ N, "real time signal",
/* 72 */ N, "real time signal",
};
#undef N
#undef K
#undef T
#undef P
#undef D
......@@ -96,8 +96,6 @@ func noescape(p unsafe.Pointer) unsafe.Pointer {
func cgocallback(fn, frame unsafe.Pointer, framesize uintptr)
func gogo(buf *gobuf)
func gosave(buf *gobuf)
func read(fd int32, p unsafe.Pointer, n int32) int32
func close(fd int32) int32
func mincore(addr unsafe.Pointer, n uintptr, dst *byte) int32
//go:noescape
......@@ -105,22 +103,13 @@ func jmpdefer(fv *funcval, argp uintptr)
func exit1(code int32)
func asminit()
func setg(gg *g)
func exit(code int32)
func breakpoint()
func nanotime() int64
func usleep(usec uint32)
func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer
func munmap(addr unsafe.Pointer, n uintptr)
func madvise(addr unsafe.Pointer, n uintptr, flags int32)
func reflectcall(fn, arg unsafe.Pointer, n uint32, retoffset uint32)
func procyield(cycles uint32)
func cgocallback_gofunc(fv *funcval, frame unsafe.Pointer, framesize uintptr)
func goexit()
//go:noescape
func write(fd uintptr, p unsafe.Pointer, n int32) int32
//go:noescape
func cas(ptr *uint32, old, new uint32) bool
......@@ -195,9 +184,6 @@ func asmcgocall(fn, arg unsafe.Pointer)
//go:noescape
func asmcgocall_errno(fn, arg unsafe.Pointer) int32
//go:noescape
func open(name *byte, mode, perm int32) int32
// argp used in Defer structs when there is no argp.
const _NoArgs = ^uintptr(0)
......
// Copyright 2014 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.
// +build !solaris
package runtime
import "unsafe"
func read(fd int32, p unsafe.Pointer, n int32) int32
func close(fd int32) int32
func exit(code int32)
func nanotime() int64
func usleep(usec uint32)
func mmap(addr unsafe.Pointer, n uintptr, prot, flags, fd int32, off uint32) unsafe.Pointer
func munmap(addr unsafe.Pointer, n uintptr)
//go:noescape
func write(fd uintptr, p unsafe.Pointer, n int32) int32
//go:noescape
func open(name *byte, mode, perm int32) int32
func madvise(addr unsafe.Pointer, n uintptr, flags int32)
......@@ -14,7 +14,7 @@
TEXT runtime·settls(SB),NOSPLIT,$8
RET
// void libc·miniterrno(void *(*___errno)(void));
// void libc_miniterrno(void *(*___errno)(void));
//
// Set the TLS errno pointer in M.
//
......@@ -41,7 +41,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0
SUBQ $64, SP // 16 bytes will do, but who knows in the future?
MOVQ $3, DI // CLOCK_REALTIME from <sys/time_impl.h>
MOVQ SP, SI
MOVQ libc·clock_gettime(SB), AX
MOVQ libc_clock_gettime(SB), AX
CALL AX
MOVQ (SP), AX // tv_sec from struct timespec
IMULQ $1000000000, AX // multiply into nanoseconds
......@@ -54,7 +54,7 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$0
TEXT runtime·pipe1(SB),NOSPLIT,$0
SUBQ $16, SP // 8 bytes will do, but stack has to be 16-byte alligned
MOVQ SP, DI
MOVQ libc·pipe(SB), AX
MOVQ libc_pipe(SB), AX
CALL AX
MOVL 0(SP), AX
MOVL 4(SP), DX
......@@ -133,7 +133,7 @@ TEXT runtime·tstart_sysvicall(SB),NOSPLIT,$0
MOVQ AX, (g_stack+stack_hi)(DX)
SUBQ $(0x100000), AX // stack size
MOVQ AX, (g_stack+stack_lo)(DX)
ADDQ $const_StackGuard, AX
ADDQ $const__StackGuard, AX
MOVQ AX, g_stackguard0(DX)
MOVQ AX, g_stackguard1(DX)
......@@ -321,13 +321,13 @@ usleep1_noswitch:
// Runs on OS stack. duration (in µs units) is in DI.
TEXT runtime·usleep2(SB),NOSPLIT,$0
MOVQ libc·usleep(SB), AX
MOVQ libc_usleep(SB), AX
CALL AX
RET
// Runs on OS stack, called from runtime·osyield.
TEXT runtime·osyield1(SB),NOSPLIT,$0
MOVQ libc·sched_yield(SB), AX
MOVQ libc_sched_yield(SB), AX
CALL AX
RET
......
// Copyright 2014 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.
package runtime
import _ "unsafe"
//go:cgo_import_dynamic libc_chdir chdir "libc.so"
//go:cgo_import_dynamic libc_chroot chroot "libc.so"
//go:cgo_import_dynamic libc_close close "libc.so"
//go:cgo_import_dynamic libc_dlclose dlclose "libc.so"
//go:cgo_import_dynamic libc_dlopen dlopen "libc.so"
//go:cgo_import_dynamic libc_dlsym dlsym "libc.so"
//go:cgo_import_dynamic libc_execve execve "libc.so"
//go:cgo_import_dynamic libc_fcntl fcntl "libc.so"
//go:cgo_import_dynamic libc_gethostname gethostname "libc.so"
//go:cgo_import_dynamic libc_ioctl ioctl "libc.so"
//go:cgo_import_dynamic libc_pipe pipe "libc.so"
//go:cgo_import_dynamic libc_setgid setgid "libc.so"
//go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
//go:cgo_import_dynamic libc_setsid setsid "libc.so"
//go:cgo_import_dynamic libc_setuid setuid "libc.so"
//go:cgo_import_dynamic libc_setpgid setsid "libc.so"
//go:cgo_import_dynamic libc_syscall syscall "libc.so"
//go:cgo_import_dynamic libc_forkx forkx "libc.so"
//go:cgo_import_dynamic libc_wait4 wait4 "libc.so"
//go:linkname libc_chdir libc_chdir
//go:linkname libc_chroot libc_chroot
//go:linkname libc_close libc_close
//go:linkname libc_dlclose libc_dlclose
//go:linkname libc_dlopen libc_dlopen
//go:linkname libc_dlsym libc_dlsym
//go:linkname libc_execve libc_execve
//go:linkname libc_fcntl libc_fcntl
//go:linkname libc_gethostname libc_gethostname
//go:linkname libc_ioctl libc_ioctl
//go:linkname libc_pipe libc_pipe
//go:linkname libc_setgid libc_setgid
//go:linkname libc_setgroups libc_setgroups
//go:linkname libc_setsid libc_setsid
//go:linkname libc_setuid libc_setuid
//go:linkname libc_setpgid libc_setpgid
//go:linkname libc_syscall libc_syscall
//go:linkname libc_forkx libc_forkx
//go:linkname libc_wait4 libc_wait4
// Copyright 2014 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.
#pragma dynimport libc·chdir chdir "libc.so"
#pragma dynimport libc·chroot chroot "libc.so"
#pragma dynimport libc·close close "libc.so"
#pragma dynimport libc·dlclose dlclose "libc.so"
#pragma dynimport libc·dlopen dlopen "libc.so"
#pragma dynimport libc·dlsym dlsym "libc.so"
#pragma dynimport libc·execve execve "libc.so"
#pragma dynimport libc·fcntl fcntl "libc.so"
#pragma dynimport libc·gethostname gethostname "libc.so"
#pragma dynimport libc·ioctl ioctl "libc.so"
#pragma dynimport libc·pipe pipe "libc.so"
#pragma dynimport libc·setgid setgid "libc.so"
#pragma dynimport libc·setgroups setgroups "libc.so"
#pragma dynimport libc·setsid setsid "libc.so"
#pragma dynimport libc·setuid setuid "libc.so"
#pragma dynimport libc·setpgid setsid "libc.so"
#pragma dynimport libc·syscall syscall "libc.so"
#pragma dynimport libc·forkx forkx "libc.so"
#pragma dynimport libc·wait4 wait4 "libc.so"
......@@ -9,12 +9,10 @@ import "unsafe"
var (
libc_chdir,
libc_chroot,
libc_close,
libc_dlopen,
libc_dlclose,
libc_dlsym,
libc_execve,
libc_exit,
libc_fcntl,
libc_forkx,
libc_gethostname,
......@@ -27,7 +25,6 @@ var (
libc_setpgid,
libc_syscall,
libc_wait4,
libc_write,
pipe1 libcFunc
)
......@@ -38,9 +35,9 @@ func syscall_sysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err
n: nargs,
args: uintptr(unsafe.Pointer(&a1)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
return call.r1, call.r2, call.err
}
......@@ -62,7 +59,7 @@ func syscall_rawsysvicall6(fn, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, e
//go:nosplit
func syscall_chdir(path uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_chdir)),
fn: uintptr(unsafe.Pointer(libc_chdir)),
n: 1,
args: uintptr(unsafe.Pointer(&path)),
}
......@@ -73,7 +70,7 @@ func syscall_chdir(path uintptr) (err uintptr) {
//go:nosplit
func syscall_chroot(path uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_chroot)),
fn: uintptr(unsafe.Pointer(libc_chroot)),
n: 1,
args: uintptr(unsafe.Pointer(&path)),
}
......@@ -84,18 +81,18 @@ func syscall_chroot(path uintptr) (err uintptr) {
// like close, but must not split stack, for forkx.
//go:nosplit
func syscall_close(fd int32) int32 {
return int32(sysvicall1(&libc_close, uintptr(fd)))
return int32(sysvicall1(libc_close, uintptr(fd)))
}
func syscall_dlopen(name *byte, mode uintptr) (handle uintptr, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_dlopen)),
fn: uintptr(unsafe.Pointer(libc_dlopen)),
n: 2,
args: uintptr(unsafe.Pointer(&name)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
if call.r1 == 0 {
return call.r1, call.err
}
......@@ -104,25 +101,25 @@ func syscall_dlopen(name *byte, mode uintptr) (handle uintptr, err uintptr) {
func syscall_dlclose(handle uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_dlclose)),
fn: uintptr(unsafe.Pointer(libc_dlclose)),
n: 1,
args: uintptr(unsafe.Pointer(&handle)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
return call.r1
}
func syscall_dlsym(handle uintptr, name *byte) (proc uintptr, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_dlsym)),
fn: uintptr(unsafe.Pointer(libc_dlsym)),
n: 2,
args: uintptr(unsafe.Pointer(&handle)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
if call.r1 == 0 {
return call.r1, call.err
}
......@@ -132,7 +129,7 @@ func syscall_dlsym(handle uintptr, name *byte) (proc uintptr, err uintptr) {
//go:nosplit
func syscall_execve(path, argv, envp uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_execve)),
fn: uintptr(unsafe.Pointer(libc_execve)),
n: 3,
args: uintptr(unsafe.Pointer(&path)),
}
......@@ -143,13 +140,13 @@ func syscall_execve(path, argv, envp uintptr) (err uintptr) {
// like exit, but must not split stack, for forkx.
//go:nosplit
func syscall_exit(code uintptr) {
sysvicall1(&libc_exit, code)
sysvicall1(libc_exit, code)
}
//go:nosplit
func syscall_fcntl(fd, cmd, arg uintptr) (val, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_fcntl)),
fn: uintptr(unsafe.Pointer(libc_fcntl)),
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
......@@ -160,7 +157,7 @@ func syscall_fcntl(fd, cmd, arg uintptr) (val, err uintptr) {
//go:nosplit
func syscall_forkx(flags uintptr) (pid uintptr, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_forkx)),
fn: uintptr(unsafe.Pointer(libc_forkx)),
n: 1,
args: uintptr(unsafe.Pointer(&flags)),
}
......@@ -172,13 +169,13 @@ func syscall_gethostname() (name string, err uintptr) {
cname := new([_MAXHOSTNAMELEN]byte)
var args = [2]uintptr{uintptr(unsafe.Pointer(&cname[0])), _MAXHOSTNAMELEN}
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_gethostname)),
fn: uintptr(unsafe.Pointer(libc_gethostname)),
n: 2,
args: uintptr(unsafe.Pointer(&args[0])),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
if call.r1 != 0 {
return "", call.err
}
......@@ -189,7 +186,7 @@ func syscall_gethostname() (name string, err uintptr) {
//go:nosplit
func syscall_ioctl(fd, req, arg uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_ioctl)),
fn: uintptr(unsafe.Pointer(libc_ioctl)),
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
......@@ -203,9 +200,9 @@ func syscall_pipe() (r, w, err uintptr) {
n: 0,
args: uintptr(unsafe.Pointer(&pipe1)), // it's unused but must be non-nil, otherwise crashes
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
return call.r1, call.r2, call.err
}
......@@ -217,7 +214,7 @@ func syscall_pipe() (r, w, err uintptr) {
// TODO(aram): make this panic once we stop calling fcntl(2) in net using it.
func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_syscall)),
fn: uintptr(unsafe.Pointer(libc_syscall)),
n: 4,
args: uintptr(unsafe.Pointer(&trap)),
}
......@@ -228,7 +225,7 @@ func syscall_rawsyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
//go:nosplit
func syscall_setgid(gid uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_setgid)),
fn: uintptr(unsafe.Pointer(libc_setgid)),
n: 1,
args: uintptr(unsafe.Pointer(&gid)),
}
......@@ -239,7 +236,7 @@ func syscall_setgid(gid uintptr) (err uintptr) {
//go:nosplit
func syscall_setgroups(ngid, gid uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_setgroups)),
fn: uintptr(unsafe.Pointer(libc_setgroups)),
n: 2,
args: uintptr(unsafe.Pointer(&ngid)),
}
......@@ -250,9 +247,9 @@ func syscall_setgroups(ngid, gid uintptr) (err uintptr) {
//go:nosplit
func syscall_setsid() (pid, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_setsid)),
fn: uintptr(unsafe.Pointer(libc_setsid)),
n: 0,
args: uintptr(unsafe.Pointer(&libc_setsid)), // it's unused but must be non-nil, otherwise crashes
args: uintptr(unsafe.Pointer(libc_setsid)), // it's unused but must be non-nil, otherwise crashes
}
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
return call.r1, call.err
......@@ -261,7 +258,7 @@ func syscall_setsid() (pid, err uintptr) {
//go:nosplit
func syscall_setuid(uid uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_setuid)),
fn: uintptr(unsafe.Pointer(libc_setuid)),
n: 1,
args: uintptr(unsafe.Pointer(&uid)),
}
......@@ -272,7 +269,7 @@ func syscall_setuid(uid uintptr) (err uintptr) {
//go:nosplit
func syscall_setpgid(pid, pgid uintptr) (err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_setpgid)),
fn: uintptr(unsafe.Pointer(libc_setpgid)),
n: 2,
args: uintptr(unsafe.Pointer(&pid)),
}
......@@ -288,32 +285,32 @@ func syscall_setpgid(pid, pgid uintptr) (err uintptr) {
// TODO(aram): make this panic once we stop calling fcntl(2) in net using it.
func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_syscall)),
fn: uintptr(unsafe.Pointer(libc_syscall)),
n: 4,
args: uintptr(unsafe.Pointer(&trap)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
return call.r1, call.r2, call.err
}
func syscall_wait4(pid uintptr, wstatus *uint32, options uintptr, rusage unsafe.Pointer) (wpid int, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_wait4)),
fn: uintptr(unsafe.Pointer(libc_wait4)),
n: 4,
args: uintptr(unsafe.Pointer(&pid)),
}
entersyscallblock()
entersyscallblock(0)
asmcgocall(unsafe.Pointer(&asmsysvicall6), unsafe.Pointer(&call))
exitsyscall()
exitsyscall(0)
return int(call.r1), call.err
}
//go:nosplit
func syscall_write(fd, buf, nbyte uintptr) (n, err uintptr) {
call := libcall{
fn: uintptr(unsafe.Pointer(&libc_write)),
fn: uintptr(unsafe.Pointer(libc_write)),
n: 3,
args: uintptr(unsafe.Pointer(&fd)),
}
......
// Copyright 2014 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.
// This file exposes various external library functions to Go code in the runtime.
#include "go_asm.h"
#include "go_tls.h"
#include "textflag.h"
TEXT runtime·libc_chdir(SB),NOSPLIT,$0
MOVQ libc·chdir(SB), AX
JMP AX
TEXT runtime·libc_chroot(SB),NOSPLIT,$0
MOVQ libc·chroot(SB), AX
JMP AX
TEXT runtime·libc_close(SB),NOSPLIT,$0
MOVQ libc·close(SB), AX
JMP AX
TEXT runtime·libc_dlopen(SB),NOSPLIT,$0
MOVQ libc·dlopen(SB), AX
JMP AX
TEXT runtime·libc_dlclose(SB),NOSPLIT,$0
MOVQ libc·dlclose(SB), AX
JMP AX
TEXT runtime·libc_dlsym(SB),NOSPLIT,$0
MOVQ libc·dlsym(SB), AX
JMP AX
TEXT runtime·libc_execve(SB),NOSPLIT,$0
MOVQ libc·execve(SB), AX
JMP AX
TEXT runtime·libc_exit(SB),NOSPLIT,$0
MOVQ libc·exit(SB), AX
JMP AX
TEXT runtime·libc_fcntl(SB),NOSPLIT,$0
MOVQ libc·fcntl(SB), AX
JMP AX
TEXT runtime·libc_forkx(SB),NOSPLIT,$0
MOVQ libc·forkx(SB), AX
JMP AX
TEXT runtime·libc_gethostname(SB),NOSPLIT,$0
MOVQ libc·gethostname(SB), AX
JMP AX
TEXT runtime·libc_ioctl(SB),NOSPLIT,$0
MOVQ libc·ioctl(SB), AX
JMP AX
TEXT runtime·libc_setgid(SB),NOSPLIT,$0
MOVQ libc·setgid(SB), AX
JMP AX
TEXT runtime·libc_setgroups(SB),NOSPLIT,$0
MOVQ libc·setgroups(SB), AX
JMP AX
TEXT runtime·libc_setsid(SB),NOSPLIT,$0
MOVQ libc·setsid(SB), AX
JMP AX
TEXT runtime·libc_setuid(SB),NOSPLIT,$0
MOVQ libc·setuid(SB), AX
JMP AX
TEXT runtime·libc_setpgid(SB),NOSPLIT,$0
MOVQ libc·setpgid(SB), AX
JMP AX
TEXT runtime·libc_syscall(SB),NOSPLIT,$0
MOVQ libc·syscall(SB), AX
JMP AX
TEXT runtime·libc_wait4(SB),NOSPLIT,$0
MOVQ libc·wait4(SB), AX
JMP AX
TEXT runtime·libc_write(SB),NOSPLIT,$0
MOVQ libc·write(SB), AX
JMP AX
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment