Commit 68b4255a authored by Russ Cox's avatar Russ Cox

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
parent 3b6ddd9b
......@@ -174,7 +174,7 @@ func (p *Package) writeDefsFunc(fc, fgo2 *os.File, n *Name, soprefix, sopath str
fmt.Fprintf(fc, "void\n")
fmt.Fprintf(fc, "·%s(struct{uint8 x[%d];}p)\n", n.Mangle, argSize)
fmt.Fprintf(fc, "{\n")
fmt.Fprintf(fc, "\tcgocall(_cgo%s, &p);\n", n.Mangle)
fmt.Fprintf(fc, "\truntime·cgocall(_cgo%s, &p);\n", n.Mangle)
if n.AddError {
// gcc leaves errno in first word of interface at end of p.
// check whether it is zero; if so, turn interface into nil.
......@@ -416,7 +416,7 @@ func (p *Package) writeExports(fgo2, fc *os.File) {
fmt.Fprintf(fc, "\nvoid\n")
fmt.Fprintf(fc, "_cgoexp_%s(void *a, int32 n)\n", exp.ExpName)
fmt.Fprintf(fc, "{\n")
fmt.Fprintf(fc, "\tcgocallback(·%s, a, n);\n", goname)
fmt.Fprintf(fc, "\truntime·cgocallback(·%s, a, n);\n", goname)
fmt.Fprintf(fc, "}\n")
// Calling a function with a receiver from C requires
......@@ -603,22 +603,22 @@ void ·_Cerrno(void*, int32);
void
·_Cfunc_GoString(int8 *p, String s)
{
s = gostring((byte*)p);
s = runtime·gostring((byte*)p);
FLUSH(&s);
}
void
·_Cfunc_GoStringN(int8 *p, int32 l, String s)
{
s = gostringn((byte*)p, l);
s = runtime·gostringn((byte*)p, l);
FLUSH(&s);
}
void
·_Cfunc_CString(String s, int8 *p)
{
p = cmalloc(s.len+1);
mcpy((byte*)p, s.str, s.len);
p = runtime·cmalloc(s.len+1);
runtime·mcpy((byte*)p, s.str, s.len);
p[s.len] = 0;
FLUSH(&p);
}
......
char *runtimeimport =
"package runtime\n"
"func \"\".mal (? int32) *any\n"
"func \"\".new (? int32) *any\n"
"func \"\".panicindex ()\n"
"func \"\".panicslice ()\n"
"func \"\".throwreturn ()\n"
......@@ -19,7 +19,7 @@ char *runtimeimport =
"func \"\".printslice (? any)\n"
"func \"\".printnl ()\n"
"func \"\".printsp ()\n"
"func \"\".printf ()\n"
"func \"\".goprintf ()\n"
"func \"\".concatstring ()\n"
"func \"\".append ()\n"
"func \"\".appendslice (typ *uint8, x any, y []any) any\n"
......
......@@ -10,7 +10,7 @@ package PACKAGE
// emitted by compiler, not referred to by go programs
func mal(int32) *any
func new(int32) *any
func panicindex()
func panicslice()
func throwreturn()
......@@ -31,7 +31,7 @@ func printeface(any)
func printslice(any)
func printnl()
func printsp()
func printf()
func goprintf()
// filled in by compiler: int n, string, string, ...
func concatstring()
......
......@@ -1862,7 +1862,7 @@ walkprint(Node *nn, NodeList **init, int defer)
if(defer) {
if(op == OPRINTN)
fmtprint(&fmt, "\n");
on = syslook("printf", 1);
on = syslook("goprintf", 1);
on->type = functype(nil, intypes, nil);
args->n = nod(OLITERAL, N, N);
args->n->val.ctype = CTSTR;
......@@ -1891,7 +1891,7 @@ callnew(Type *t)
Node *fn;
dowidth(t);
fn = syslook("mal", 1);
fn = syslook("new", 1);
argtype(fn, t);
return mkcall1(fn, ptrto(t), nil, nodintconst(t->width));
}
......
......@@ -23,23 +23,23 @@ TEXT _rt0_386(SB),7,$0
JMP ok
// set up %gs
CALL ldt0setup(SB)
CALL runtime·ldt0setup(SB)
// store through it, to make sure it works
CMPL isplan9(SB), $1
CMPL runtime·isplan9(SB), $1
JEQ ok
get_tls(BX)
MOVL $0x123, g(BX)
MOVL tls0(SB), AX
MOVL runtime·tls0(SB), AX
CMPL AX, $0x123
JEQ ok
MOVL AX, 0 // abort
ok:
// set up m and g "registers"
get_tls(BX)
LEAL g0(SB), CX
LEAL runtime·g0(SB), CX
MOVL CX, g(BX)
LEAL m0(SB), AX
LEAL runtime·m0(SB), AX
MOVL AX, m(BX)
// save m->g0 = g0
......@@ -49,46 +49,46 @@ ok:
LEAL (-8192+104)(SP), AX // TODO: 104?
MOVL AX, g_stackguard(CX)
MOVL SP, g_stackbase(CX)
CALL emptyfunc(SB) // fault if stack check is wrong
CALL runtime·emptyfunc(SB) // fault if stack check is wrong
// convention is D is always cleared
CLD
CALL check(SB)
CALL runtime·check(SB)
// saved argc, argv
MOVL 120(SP), AX
MOVL AX, 0(SP)
MOVL 124(SP), AX
MOVL AX, 4(SP)
CALL args(SB)
CALL osinit(SB)
CALL schedinit(SB)
CALL runtime·args(SB)
CALL runtime·osinit(SB)
CALL runtime·schedinit(SB)
// create a new goroutine to start program
PUSHL $mainstart(SB) // entry
PUSHL $runtime·mainstart(SB) // entry
PUSHL $0 // arg size
CALL ·newproc(SB)
CALL runtime·newproc(SB)
POPL AX
POPL AX
// start this M
CALL mstart(SB)
CALL runtime·mstart(SB)
INT $3
RET
TEXT mainstart(SB),7,$0
TEXT runtime·mainstart(SB),7,$0
CALL main·init(SB)
CALL initdone(SB)
CALL runtime·initdone(SB)
CALL main·main(SB)
PUSHL $0
CALL exit(SB)
CALL runtime·exit(SB)
POPL AX
INT $3
RET
TEXT breakpoint(SB),7,$0
TEXT runtime·breakpoint(SB),7,$0
INT $3
RET
......@@ -98,7 +98,7 @@ TEXT breakpoint(SB),7,$0
// uintptr gosave(Gobuf*)
// save state in Gobuf; setjmp
TEXT gosave(SB), 7, $0
TEXT runtime·gosave(SB), 7, $0
MOVL 4(SP), AX // gobuf
LEAL 4(SP), BX // caller's SP
MOVL BX, gobuf_sp(AX)
......@@ -112,7 +112,7 @@ TEXT gosave(SB), 7, $0
// void gogo(Gobuf*, uintptr)
// restore state from Gobuf; longjmp
TEXT gogo(SB), 7, $0
TEXT runtime·gogo(SB), 7, $0
MOVL 8(SP), AX // return 2nd arg
MOVL 4(SP), BX // gobuf
MOVL gobuf_g(BX), DX
......@@ -126,7 +126,7 @@ TEXT gogo(SB), 7, $0
// void gogocall(Gobuf*, void (*fn)(void))
// restore state from Gobuf but then call fn.
// (call fn, returning to state in Gobuf)
TEXT gogocall(SB), 7, $0
TEXT runtime·gogocall(SB), 7, $0
MOVL 8(SP), AX // fn
MOVL 4(SP), BX // gobuf
MOVL gobuf_g(BX), DX
......@@ -144,7 +144,7 @@ TEXT gogocall(SB), 7, $0
*/
// Called during function prolog when more stack is needed.
TEXT ·morestack(SB),7,$0
TEXT runtime·morestack(SB),7,$0
// Cannot grow scheduler stack (m->g0).
get_tls(CX)
MOVL m(CX), BX
......@@ -178,7 +178,7 @@ TEXT ·morestack(SB),7,$0
MOVL m_g0(BX), BP
MOVL BP, g(CX)
MOVL (m_sched+gobuf_sp)(BX), SP
CALL newstack(SB)
CALL runtime·newstack(SB)
MOVL $0, 0x1003 // crash if newstack returns
RET
......@@ -220,13 +220,13 @@ TEXT reflect·call(SB), 7, $0
get_tls(CX)
MOVL BP, g(CX)
MOVL (m_sched+gobuf_sp)(BX), SP
CALL newstack(SB)
CALL runtime·newstack(SB)
MOVL $0, 0x1103 // crash if newstack returns
RET
// Return point when leaving stack.
TEXT ·lessstack(SB), 7, $0
TEXT runtime·lessstack(SB), 7, $0
// Save return value in m->cret
get_tls(CX)
MOVL m(CX), BX
......@@ -236,7 +236,7 @@ TEXT ·lessstack(SB), 7, $0
MOVL m_g0(BX), DX
MOVL DX, g(CX)
MOVL (m_sched+gobuf_sp)(BX), SP
CALL oldstack(SB)
CALL runtime·oldstack(SB)
MOVL $0, 0x1004 // crash if oldstack returns
RET
......@@ -248,7 +248,7 @@ TEXT ·lessstack(SB), 7, $0
// return 1;
// }else
// return 0;
TEXT cas(SB), 7, $0
TEXT runtime·cas(SB), 7, $0
MOVL 4(SP), BX
MOVL 8(SP), AX
MOVL 12(SP), CX
......@@ -267,7 +267,7 @@ TEXT cas(SB), 7, $0
// return 1;
// }else
// return 0;
TEXT casp(SB), 7, $0
TEXT runtime·casp(SB), 7, $0
MOVL 4(SP), BX
MOVL 8(SP), AX
MOVL 12(SP), CX
......@@ -284,14 +284,14 @@ TEXT casp(SB), 7, $0
// 1. pop the caller
// 2. sub 5 bytes from the callers return
// 3. jmp to the argument
TEXT jmpdefer(SB), 7, $0
TEXT runtime·jmpdefer(SB), 7, $0
MOVL 4(SP), AX // fn
MOVL 8(SP), BX // caller sp
LEAL -4(BX), SP // caller sp after CALL
SUBL $5, (SP) // return to CALL again
JMP AX // but first run the deferred function
TEXT ·memclr(SB),7,$0
TEXT runtime·memclr(SB),7,$0
MOVL 4(SP), DI // arg 1 addr
MOVL 8(SP), CX // arg 2 count
ADDL $3, CX
......@@ -302,42 +302,42 @@ TEXT ·memclr(SB),7,$0
STOSL
RET
TEXT ·getcallerpc+0(SB),7,$0
TEXT runtime·getcallerpc(SB),7,$0
MOVL x+0(FP),AX // addr of first arg
MOVL -4(AX),AX // get calling pc
RET
TEXT ·setcallerpc+0(SB),7,$0
TEXT runtime·setcallerpc(SB),7,$0
MOVL x+0(FP),AX // addr of first arg
MOVL x+4(FP), BX
MOVL BX, -4(AX) // set calling pc
RET
TEXT getcallersp(SB), 7, $0
TEXT runtime·getcallersp(SB), 7, $0
MOVL sp+0(FP), AX
RET
TEXT ldt0setup(SB),7,$16
TEXT runtime·ldt0setup(SB),7,$16
// set up ldt 7 to point at tls0
// ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go.
// the entry number is just a hint. setldt will set up GS with what it used.
MOVL $7, 0(SP)
LEAL tls0(SB), AX
LEAL runtime·tls0(SB), AX
MOVL AX, 4(SP)
MOVL $32, 8(SP) // sizeof(tls array)
CALL setldt(SB)
CALL runtime·setldt(SB)
RET
TEXT emptyfunc(SB),0,$0
TEXT runtime·emptyfunc(SB),0,$0
RET
TEXT abort(SB),7,$0
TEXT runtime·abort(SB),7,$0
INT $0x3
// runcgo(void(*fn)(void*), void *arg)
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
TEXT runcgo(SB),7,$16
TEXT runtime·runcgo(SB),7,$16
MOVL fn+0(FP), AX
MOVL arg+4(FP), BX
MOVL SP, CX
......@@ -372,7 +372,7 @@ TEXT runcgo(SB),7,$16
// runcgocallback(G *g1, void* sp, void (*fn)(void))
// Switch to g1 and sp, call fn, switch back. fn's arguments are on
// the new stack.
TEXT runcgocallback(SB),7,$32
TEXT runtime·runcgocallback(SB),7,$32
MOVL g1+0(FP), DX
MOVL sp+4(FP), AX
MOVL fn+8(FP), BX
......@@ -401,7 +401,7 @@ TEXT runcgocallback(SB),7,$32
RET
// check that SP is in range [g->stackbase, g->stackguard)
TEXT stackcheck(SB), 7, $0
TEXT runtime·stackcheck(SB), 7, $0
get_tls(CX)
MOVL g(CX), AX
CMPL g_stackbase(AX), SP
......@@ -412,7 +412,4 @@ TEXT stackcheck(SB), 7, $0
INT $3
RET
GLOBL m0(SB), $1024
GLOBL g0(SB), $1024
GLOBL tls0(SB), $32
GLOBL initcgo(SB), $4
GLOBL runtime·tls0(SB), $32
......@@ -9,23 +9,23 @@
// fn func(arg0, arg1, arg2 *ptr, callerpc uintptr, xxx) yyy,
// arg0, arg1, arg2 *ptr) (func(xxx) yyy)
void
·closure(int32 siz, byte *fn, byte *arg0)
runtime·closure(int32 siz, byte *fn, byte *arg0)
{
byte *p, *q, **ret;
int32 i, n;
int32 pcrel;
if(goos != nil && strcmp((uint8*)goos, (uint8*)"nacl") == 0)
throw("no closures in native client yet");
if(runtime·goos != nil && runtime·strcmp((uint8*)runtime·goos, (uint8*)"nacl") == 0)
runtime·throw("no closures in native client yet");
if(siz < 0 || siz%4 != 0)
throw("bad closure size");
runtime·throw("bad closure size");
ret = (byte**)((byte*)&arg0 + siz);
if(siz > 100) {
// TODO(rsc): implement stack growth preamble?
throw("closure too big");
runtime·throw("closure too big");
}
// compute size of new fn.
......@@ -43,12 +43,12 @@ void
if(n%4)
n += 4 - n%4;
p = mal(n);
p = runtime·mal(n);
*ret = p;
q = p + n - siz;
if(siz > 0) {
mcpy(q, (byte*)&arg0, siz);
runtime·mcpy(q, (byte*)&arg0, siz);
// SUBL $siz, SP
*p++ = 0x81;
......@@ -104,7 +104,5 @@ void
*p++ = 0xc3;
if(p > q)
throw("bad math in sys.closure");
runtime·throw("bad math in sys.closure");
}
......@@ -23,8 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
TEXT memmove(SB), 7, $0
TEXT runtime·memmove(SB), 7, $0
MOVL to+0(FP), DI
MOVL fr+4(FP), SI
MOVL n+8(FP), BX
......
......@@ -59,7 +59,7 @@ struct Vlong
};
};
void abort(void);
void runtime·abort(void);
void
_d2v(Vlong *y, double d)
......@@ -270,7 +270,7 @@ _divvu(Vlong *q, Vlong n, Vlong d)
}
void
·uint64div(Vlong n, Vlong d, Vlong q)
runtime·uint64div(Vlong n, Vlong d, Vlong q)
{
_divvu(&q, n, d);
}
......@@ -288,7 +288,7 @@ _modvu(Vlong *r, Vlong n, Vlong d)
}
void
·uint64mod(Vlong n, Vlong d, Vlong q)
runtime·uint64mod(Vlong n, Vlong d, Vlong q)
{
_modvu(&q, n, d);
}
......@@ -334,7 +334,7 @@ _divv(Vlong *q, Vlong n, Vlong d)
}
void
·int64div(Vlong n, Vlong d, Vlong q)
runtime·int64div(Vlong n, Vlong d, Vlong q)
{
_divv(&q, n, d);
}
......@@ -368,7 +368,7 @@ _modv(Vlong *r, Vlong n, Vlong d)
}
void
·int64mod(Vlong n, Vlong d, Vlong q)
runtime·int64mod(Vlong n, Vlong d, Vlong q)
{
_modv(&q, n, d);
}
......@@ -522,7 +522,7 @@ _vasop(Vlong *ret, void *lv, void fn(Vlong*, Vlong, Vlong), int type, Vlong rv)
u.hi = 0;
switch(type) {
default:
abort();
runtime·abort();
break;
case 1: /* schar */
......
......@@ -21,22 +21,22 @@ TEXT _rt0_amd64(SB),7,$-8
JMP ok
needtls:
LEAQ tls0(SB), DI
CALL settls(SB)
LEAQ runtime·tls0(SB), DI
CALL runtime·settls(SB)
// store through it, to make sure it works
get_tls(BX)
MOVQ $0x123, g(BX)
MOVQ tls0(SB), AX
MOVQ runtime·tls0(SB), AX
CMPQ AX, $0x123
JEQ 2(PC)
MOVL AX, 0 // abort
ok:
// set the per-goroutine and per-mach "registers"
get_tls(BX)
LEAQ g0(SB), CX
LEAQ runtime·g0(SB), CX
MOVQ CX, g(BX)
LEAQ m0(SB), AX
LEAQ runtime·m0(SB), AX
MOVQ AX, m(BX)
// save m->g0 = g0
......@@ -48,40 +48,40 @@ ok:
MOVQ SP, g_stackbase(CX)
CLD // convention is D is always left cleared
CALL check(SB)
CALL runtime·check(SB)
MOVL 16(SP), AX // copy argc
MOVL AX, 0(SP)
MOVQ 24(SP), AX // copy argv
MOVQ AX, 8(SP)
CALL args(SB)
CALL osinit(SB)
CALL schedinit(SB)
CALL runtime·args(SB)
CALL runtime·osinit(SB)
CALL runtime·schedinit(SB)
// create a new goroutine to start program
PUSHQ $mainstart(SB) // entry
PUSHQ $runtime·mainstart(SB) // entry
PUSHQ $0 // arg size
CALL ·newproc(SB)
CALL runtime·newproc(SB)
POPQ AX
POPQ AX
// start this M
CALL mstart(SB)
CALL runtime·mstart(SB)
CALL notok(SB) // never returns
CALL runtime·notok(SB) // never returns
RET
TEXT mainstart(SB),7,$0
TEXT runtime·mainstart(SB),7,$0
CALL main·init(SB)
CALL initdone(SB)
CALL runtime·initdone(SB)
CALL main·main(SB)
PUSHQ $0
CALL exit(SB)
CALL runtime·exit(SB)
POPQ AX
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT breakpoint(SB),7,$0
TEXT runtime·breakpoint(SB),7,$0
BYTE $0xcc
RET
......@@ -91,7 +91,7 @@ TEXT breakpoint(SB),7,$0
// uintptr gosave(Gobuf*)
// save state in Gobuf; setjmp
TEXT gosave(SB), 7, $0
TEXT runtime·gosave(SB), 7, $0
MOVQ 8(SP), AX // gobuf
LEAQ 8(SP), BX // caller's SP
MOVQ BX, gobuf_sp(AX)
......@@ -105,7 +105,7 @@ TEXT gosave(SB), 7, $0
// void gogo(Gobuf*, uintptr)
// restore state from Gobuf; longjmp
TEXT gogo(SB), 7, $0
TEXT runtime·gogo(SB), 7, $0
MOVQ 16(SP), AX // return 2nd arg
MOVQ 8(SP), BX // gobuf
MOVQ gobuf_g(BX), DX
......@@ -119,7 +119,7 @@ TEXT gogo(SB), 7, $0
// void gogocall(Gobuf*, void (*fn)(void))
// restore state from Gobuf but then call fn.
// (call fn, returning to state in Gobuf)
TEXT gogocall(SB), 7, $0
TEXT runtime·gogocall(SB), 7, $0
MOVQ 16(SP), AX // fn
MOVQ 8(SP), BX // gobuf
MOVQ gobuf_g(BX), DX
......@@ -138,7 +138,7 @@ TEXT gogocall(SB), 7, $0
// Called during function prolog when more stack is needed.
// Caller has already done get_tls(CX); MOVQ m(CX), BX.
TEXT morestack(SB),7,$0
TEXT runtime·morestack(SB),7,$0
// Cannot grow scheduler stack (m->g0).
MOVQ m_g0(BX), SI
CMPQ g(CX), SI
......@@ -164,7 +164,7 @@ TEXT morestack(SB),7,$0
MOVQ m_g0(BX), BP
MOVQ BP, g(CX)
MOVQ (m_sched+gobuf_sp)(BX), SP
CALL newstack(SB)
CALL runtime·newstack(SB)
MOVQ $0, 0x1003 // crash if newstack returns
RET
......@@ -206,12 +206,12 @@ TEXT reflect·call(SB), 7, $0
get_tls(CX)
MOVQ BP, g(CX)
MOVQ (m_sched+gobuf_sp)(BX), SP
CALL newstack(SB)
CALL runtime·newstack(SB)
MOVQ $0, 0x1103 // crash if newstack returns
RET
// Return point when leaving stack.
TEXT ·lessstack(SB), 7, $0
TEXT runtime·lessstack(SB), 7, $0
// Save return value in m->cret
get_tls(CX)
MOVQ m(CX), BX
......@@ -221,81 +221,81 @@ TEXT ·lessstack(SB), 7, $0
MOVQ m_g0(BX), DX
MOVQ DX, g(CX)
MOVQ (m_sched+gobuf_sp)(BX), SP
CALL oldstack(SB)
CALL runtime·oldstack(SB)
MOVQ $0, 0x1004 // crash if oldstack returns
RET
// morestack trampolines
TEXT ·morestack00+0(SB),7,$0
TEXT runtime·morestack00(SB),7,$0
get_tls(CX)
MOVQ m(CX), BX
MOVQ $0, AX
MOVQ AX, m_moreframe(BX)
MOVQ $morestack+0(SB), AX
MOVQ $runtime·morestack(SB), AX
JMP AX
TEXT ·morestack01+0(SB),7,$0
TEXT runtime·morestack01(SB),7,$0
get_tls(CX)
MOVQ m(CX), BX
SHLQ $32, AX
MOVQ AX, m_moreframe(BX)
MOVQ $morestack+0(SB), AX
MOVQ $runtime·morestack(SB), AX
JMP AX
TEXT ·morestack10+0(SB),7,$0
TEXT runtime·morestack10(SB),7,$0
get_tls(CX)
MOVQ m(CX), BX
MOVLQZX AX, AX
MOVQ AX, m_moreframe(BX)
MOVQ $morestack+0(SB), AX
MOVQ $runtime·morestack(SB), AX
JMP AX
TEXT ·morestack11+0(SB),7,$0
TEXT runtime·morestack11(SB),7,$0
get_tls(CX)
MOVQ m(CX), BX
MOVQ AX, m_moreframe(BX)
MOVQ $morestack+0(SB), AX
MOVQ $runtime·morestack(SB), AX
JMP AX
// subcases of morestack01
// with const of 8,16,...48
TEXT ·morestack8(SB),7,$0
TEXT runtime·morestack8(SB),7,$0
PUSHQ $1
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestack16(SB),7,$0
TEXT runtime·morestack16(SB),7,$0
PUSHQ $2
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestack24(SB),7,$0
TEXT runtime·morestack24(SB),7,$0
PUSHQ $3
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestack32(SB),7,$0
TEXT runtime·morestack32(SB),7,$0
PUSHQ $4
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestack40(SB),7,$0
TEXT runtime·morestack40(SB),7,$0
PUSHQ $5
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestack48(SB),7,$0
TEXT runtime·morestack48(SB),7,$0
PUSHQ $6
MOVQ $·morestackx(SB), AX
MOVQ $morestack<>(SB), AX
JMP AX
TEXT ·morestackx(SB),7,$0
TEXT morestack<>(SB),7,$0
get_tls(CX)
MOVQ m(CX), BX
POPQ AX
SHLQ $35, AX
MOVQ AX, m_moreframe(BX)
MOVQ $morestack(SB), AX
MOVQ $runtime·morestack(SB), AX
JMP AX
// bool cas(int32 *val, int32 old, int32 new)
......@@ -305,7 +305,7 @@ TEXT ·morestackx(SB),7,$0
// return 1;
// } else
// return 0;
TEXT cas(SB), 7, $0
TEXT runtime·cas(SB), 7, $0
MOVQ 8(SP), BX
MOVL 16(SP), AX
MOVL 20(SP), CX
......@@ -322,7 +322,7 @@ TEXT cas(SB), 7, $0
// 1. pop the caller
// 2. sub 5 bytes from the callers return
// 3. jmp to the argument
TEXT jmpdefer(SB), 7, $0
TEXT runtime·jmpdefer(SB), 7, $0
MOVQ 8(SP), AX // fn
MOVQ 16(SP), BX // caller sp
LEAQ -8(BX), SP // caller sp after CALL
......@@ -332,7 +332,7 @@ TEXT jmpdefer(SB), 7, $0
// runcgo(void(*fn)(void*), void *arg)
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
TEXT runcgo(SB),7,$32
TEXT runtime·runcgo(SB),7,$32
MOVQ fn+0(FP), R12
MOVQ arg+8(FP), R13
MOVQ SP, CX
......@@ -365,7 +365,7 @@ TEXT runcgo(SB),7,$32
// runcgocallback(G *g1, void* sp, void (*fn)(void))
// Switch to g1 and sp, call fn, switch back. fn's arguments are on
// the new stack.
TEXT runcgocallback(SB),7,$48
TEXT runtime·runcgocallback(SB),7,$48
MOVQ g1+0(FP), DX
MOVQ sp+8(FP), AX
MOVQ fp+16(FP), BX
......@@ -394,7 +394,7 @@ TEXT runcgocallback(SB),7,$48
RET
// check that SP is in range [g->stackbase, g->stackguard)
TEXT stackcheck(SB), 7, $0
TEXT runtime·stackcheck(SB), 7, $0
get_tls(CX)
MOVQ g(CX), AX
CMPQ g_stackbase(AX), SP
......@@ -405,7 +405,7 @@ TEXT stackcheck(SB), 7, $0
INT $3
RET
TEXT ·memclr(SB),7,$0
TEXT runtime·memclr(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr
MOVL 16(SP), CX // arg 2 count
ADDL $7, CX
......@@ -416,20 +416,19 @@ TEXT ·memclr(SB),7,$0
STOSQ
RET
TEXT ·getcallerpc+0(SB),7,$0
TEXT runtime·getcallerpc(SB),7,$0
MOVQ x+0(FP),AX // addr of first arg
MOVQ -8(AX),AX // get calling pc
RET
TEXT ·setcallerpc+0(SB),7,$0
TEXT runtime·setcallerpc(SB),7,$0
MOVQ x+0(FP),AX // addr of first arg
MOVQ x+8(FP), BX
MOVQ BX, -8(AX) // set calling pc
RET
TEXT getcallersp(SB),7,$0
TEXT runtime·getcallersp(SB),7,$0
MOVQ sp+0(FP), AX
RET
GLOBL initcgo(SB), $8
GLOBL tls0(SB), $64
GLOBL runtime·tls0(SB), $64
......@@ -9,20 +9,20 @@
// fn func(arg0, arg1, arg2 *ptr, callerpc uintptr, xxx) yyy,
// arg0, arg1, arg2 *ptr) (func(xxx) yyy)
void
·closure(int32 siz, byte *fn, byte *arg0)
runtime·closure(int32 siz, byte *fn, byte *arg0)
{
byte *p, *q, **ret;
int32 i, n;
int64 pcrel;
if(siz < 0 || siz%8 != 0)
throw("bad closure size");
runtime·throw("bad closure size");
ret = (byte**)((byte*)&arg0 + siz);
if(siz > 100) {
// TODO(rsc): implement stack growth preamble?
throw("closure too big");
runtime·throw("closure too big");
}
// compute size of new fn.
......@@ -40,12 +40,12 @@ void
if(n%8)
n += 8 - n%8;
p = mal(n);
p = runtime·mal(n);
*ret = p;
q = p + n - siz;
if(siz > 0) {
mcpy(q, (byte*)&arg0, siz);
runtime·mcpy(q, (byte*)&arg0, siz);
// SUBQ $siz, SP
*p++ = 0x48;
......@@ -117,7 +117,7 @@ void
*p++ = 0xc3;
if(p > q)
throw("bad math in sys.closure");
runtime·throw("bad math in sys.closure");
}
......@@ -23,7 +23,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
TEXT memmove(SB), 7, $0
TEXT runtime·memmove(SB), 7, $0
MOVQ to+0(FP), DI
MOVQ fr+8(FP), SI
......
......@@ -6,8 +6,8 @@
#include "malloc.h"
static uintptr isclosureentry(uintptr);
void ·deferproc(void);
void ·newproc(void);
void runtime·deferproc(void);
void runtime·newproc(void);
// This code is also used for the 386 tracebacks.
// Use uintptr for an appropriate word-sized integer.
......@@ -35,7 +35,7 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
}
nascent = 0;
if(pc0 == g->sched.pc && sp == g->sched.sp && pc0 == (byte*)goexit) {
if(pc0 == g->sched.pc && sp == g->sched.sp && pc0 == (byte*)runtime·goexit) {
// Hasn't started yet. g->sched is set up for goexit
// but goroutine will start at g->entry.
nascent = 1;
......@@ -45,7 +45,7 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
n = 0;
stk = (Stktop*)g->stackbase;
for(iter = 0; iter < 100 && n < m; iter++) { // iter avoids looping forever
if(pc == (uintptr)·lessstack) {
if(pc == (uintptr)runtime·lessstack) {
// Hit top of stack segment. Unwind to next segment.
pc = (uintptr)stk->gobuf.pc;
sp = stk->gobuf.sp;
......@@ -53,14 +53,14 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
continue;
}
if(pc <= 0x1000 || (f = findfunc(pc)) == nil) {
if(pc <= 0x1000 || (f = runtime·findfunc(pc)) == nil) {
// Dangerous, but worthwhile: see if this is a closure:
// ADDQ $wwxxyyzz, SP; RET
// [48] 81 c4 zz yy xx ww c3
// The 0x48 byte is only on amd64.
p = (byte*)pc;
// We check p < p+8 to avoid wrapping and faulting if we lose track.
if(mheap.min < p && p < p+8 && p+8 < mheap.max && // pointer in allocated memory
if(runtime·mheap.min < p && p < p+8 && p+8 < runtime·mheap.max && // pointer in allocated memory
(sizeof(uintptr) != 8 || *p++ == 0x48) && // skip 0x48 byte on amd64
p[0] == 0x81 && p[1] == 0xc4 && p[6] == 0xc3) {
sp += *(uint32*)(p+2);
......@@ -85,14 +85,14 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
// Print during crash.
// main+0xf /home/rsc/go/src/runtime/x.go:23
// main(0x1, 0x2, 0x3)
printf("%S", f->name);
runtime·printf("%S", f->name);
if(pc > f->entry)
printf("+%p", (uintptr)(pc - f->entry));
runtime·printf("+%p", (uintptr)(pc - f->entry));
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry)
tracepc--;
printf(" %S:%d\n", f->src, funcline(f, tracepc));
printf("\t%S(", f->name);
runtime·printf(" %S:%d\n", f->src, runtime·funcline(f, tracepc));
runtime·printf("\t%S(", f->name);
fp = (uintptr*)sp;
if(f->frame < sizeof(uintptr))
fp++;
......@@ -100,14 +100,14 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
fp += f->frame/sizeof(uintptr);
for(i = 0; i < f->args; i++) {
if(i != 0)
prints(", ");
·printhex(fp[i]);
runtime·prints(", ");
runtime·printhex(fp[i]);
if(i >= 4) {
prints(", ...");
runtime·prints(", ...");
break;
}
}
prints(")\n");
runtime·prints(")\n");
n++;
}
......@@ -123,26 +123,26 @@ gentraceback(byte *pc0, byte *sp, G *g, int32 skip, uintptr *pcbuf, int32 m)
else
sp += f->frame;
pc = *((uintptr*)sp - 1);
if(f->entry == (uintptr)·deferproc || f->entry == (uintptr)·newproc)
if(f->entry == (uintptr)runtime·deferproc || f->entry == (uintptr)runtime·newproc)
sp += 2*sizeof(uintptr);
}
return n;
}
void
traceback(byte *pc0, byte *sp, byte*, G *g)
runtime·traceback(byte *pc0, byte *sp, byte*, G *g)
{
gentraceback(pc0, sp, g, 0, nil, 100);
}
int32
callers(int32 skip, uintptr *pcbuf, int32 m)
runtime·callers(int32 skip, uintptr *pcbuf, int32 m)
{
byte *pc, *sp;
// our caller's pc, sp.
sp = (byte*)&skip;
pc = ·getcallerpc(&skip);
pc = runtime·getcallerpc(&skip);
return gentraceback(pc, sp, g, skip, pcbuf, m);
}
......@@ -154,7 +154,7 @@ isclosureentry(uintptr pc)
int32 i, siz;
p = (byte*)pc;
if(p < mheap.min || p+32 > mheap.max)
if(p < runtime·mheap.min || p+32 > runtime·mheap.max)
return 0;
// SUBQ $siz, SP
......
......@@ -19,8 +19,8 @@ TEXT _rt0_arm(SB),7,$-4
// set up m and g registers
// g is R10, m is R9
MOVW $g0(SB), g
MOVW $m0(SB), m
MOVW $runtime·g0(SB), g
MOVW $runtime·m0(SB), m
// save m->g0 = g0
MOVW g, m_g0(m)
......@@ -29,47 +29,47 @@ TEXT _rt0_arm(SB),7,$-4
MOVW $(-8192+104)(R13), R0
MOVW R0, g_stackguard(g) // (w 104b guard)
MOVW R13, g_stackbase(g)
BL emptyfunc(SB) // fault if stack check is wrong
BL runtime·emptyfunc(SB) // fault if stack check is wrong
BL check(SB)
BL runtime·check(SB)
// saved argc, argv
MOVW 120(R13), R0
MOVW R0, 4(R13)
MOVW 124(R13), R1
MOVW R1, 8(R13)
BL args(SB)
BL osinit(SB)
BL schedinit(SB)
BL runtime·args(SB)
BL runtime·osinit(SB)
BL runtime·schedinit(SB)
// create a new goroutine to start program
MOVW $mainstart(SB), R0
MOVW $runtime·mainstart(SB), R0
MOVW.W R0, -4(R13)
MOVW $8, R0
MOVW.W R0, -4(R13)
MOVW $0, R0
MOVW.W R0, -4(R13) // push $0 as guard
BL ·newproc(SB)
BL runtime·newproc(SB)
MOVW $12(R13), R13 // pop args and LR
// start this M
BL mstart(SB)
BL runtime·mstart(SB)
MOVW $1234, R0
MOVW $1000, R1
MOVW R0, (R1) // fail hard
B _dep_dummy(SB) // Never reached
B runtime·_dep_dummy(SB) // Never reached
TEXT mainstart(SB),7,$4
TEXT runtime·mainstart(SB),7,$4
BL main·init(SB)
BL initdone(SB)
BL runtime·initdone(SB)
EOR R0, R0
MOVW R0, 0(R13)
BL main·main(SB)
MOVW $0, R0
MOVW R0, 4(SP)
BL exit(SB)
BL runtime·exit(SB)
MOVW $1234, R0
MOVW $1001, R1
MOVW R0, (R1) // fail hard
......@@ -77,7 +77,7 @@ TEXT mainstart(SB),7,$4
// TODO(kaib): remove these once i actually understand how the linker removes symbols
// pull in dummy dependencies
TEXT _dep_dummy(SB),7,$0
TEXT runtime·_dep_dummy(SB),7,$0
BL _div(SB)
BL _divu(SB)
BL _mod(SB)
......@@ -85,7 +85,7 @@ TEXT _dep_dummy(SB),7,$0
BL _modu(SB)
BL _sfloat(SB)
TEXT breakpoint(SB),7,$0
TEXT runtime·breakpoint(SB),7,$0
// no breakpoint yet; let program exit
RET
......@@ -95,7 +95,7 @@ TEXT breakpoint(SB),7,$0
// uintptr gosave(Gobuf*)
// save state in Gobuf; setjmp
TEXT gosave(SB), 7, $-4
TEXT runtime·gosave(SB), 7, $-4
MOVW 0(FP), R0 // gobuf
MOVW SP, gobuf_sp(R0)
MOVW LR, gobuf_pc(R0)
......@@ -105,7 +105,7 @@ TEXT gosave(SB), 7, $-4
// void gogo(Gobuf*, uintptr)
// restore state from Gobuf; longjmp
TEXT gogo(SB), 7, $-4
TEXT runtime·gogo(SB), 7, $-4
MOVW 0(FP), R1 // gobuf
MOVW 4(FP), R0 // return 2nd arg
MOVW gobuf_g(R1), g
......@@ -117,7 +117,7 @@ TEXT gogo(SB), 7, $-4
// restore state from Gobuf but then call fn.
// (call fn, returning to state in Gobuf)
// using frame size $-4 means do not save LR on stack.
TEXT gogocall(SB), 7, $-4
TEXT runtime·gogocall(SB), 7, $-4
MOVW 0(FP), R0 // gobuf
MOVW 4(FP), R1 // fn
MOVW 8(FP), R2 // fp offset
......@@ -138,11 +138,11 @@ TEXT gogocall(SB), 7, $-4
// NB. we do not save R0 because we've forced 5c to pass all arguments
// on the stack.
// using frame size $-4 means do not save LR on stack.
TEXT ·morestack(SB),7,$-4
TEXT runtime·morestack(SB),7,$-4
// Cannot grow scheduler stack (m->g0).
MOVW m_g0(m), R4
CMP g, R4
BL.EQ abort(SB)
BL.EQ runtime·abort(SB)
// Save in m.
MOVW R1, m_moreframe(m)
......@@ -161,7 +161,7 @@ TEXT ·morestack(SB),7,$-4
// Call newstack on m's scheduling stack.
MOVW m_g0(m), g
MOVW (m_sched+gobuf_sp)(m), SP
B newstack(SB)
B runtime·newstack(SB)
// Called from reflection library. Mimics morestack,
// reuses stack growth code to create a frame
......@@ -197,32 +197,32 @@ TEXT reflect·call(SB), 7, $-4
// Call newstack on m's scheduling stack.
MOVW m_g0(m), g
MOVW (m_sched+gobuf_sp)(m), SP
B newstack(SB)
B runtime·newstack(SB)
// Return point when leaving stack.
// using frame size $-4 means do not save LR on stack.
TEXT ·lessstack(SB), 7, $-4
TEXT runtime·lessstack(SB), 7, $-4
// Save return value in m->cret
MOVW R0, m_cret(m)
// Call oldstack on m's scheduling stack.
MOVW m_g0(m), g
MOVW (m_sched+gobuf_sp)(m), SP
B oldstack(SB)
B runtime·oldstack(SB)
// void jmpdefer(fn, sp);
// called from deferreturn.
// 1. grab stored LR for caller
// 2. sub 4 bytes to get back to BL deferreturn
// 3. B to fn
TEXT jmpdefer(SB), 7, $0
TEXT runtime·jmpdefer(SB), 7, $0
MOVW 0(SP), LR
MOVW $-4(LR), LR // BL deferreturn
MOVW 4(SP), R0 // fn
MOVW 8(SP), SP
B (R0)
TEXT ·memclr(SB),7,$20
TEXT runtime·memclr(SB),7,$20
MOVW 0(FP), R0
MOVW $0, R1 // c = 0
MOVW R1, -16(SP)
......@@ -230,21 +230,21 @@ TEXT ·memclr(SB),7,$20
MOVW R1, -12(SP)
MOVW m, -8(SP) // Save m and g
MOVW g, -4(SP)
BL memset(SB)
BL runtime·memset(SB)
MOVW -8(SP), m // Restore m and g, memset clobbers them
MOVW -4(SP), g
RET
TEXT ·getcallerpc+0(SB),7,$-4
TEXT runtime·getcallerpc(SB),7,$-4
MOVW 0(SP), R0
RET
TEXT ·setcallerpc+0(SB),7,$-4
TEXT runtime·setcallerpc(SB),7,$-4
MOVW x+4(FP), R0
MOVW R0, 0(SP)
RET
TEXT getcallersp(SB),7,$-4
TEXT runtime·getcallersp(SB),7,$-4
MOVW 0(FP), R0
MOVW $-4(R0), R0
RET
......@@ -253,8 +253,8 @@ TEXT getcallersp(SB),7,$-4
// Just call fn(arg), but first align the stack
// appropriately for the gcc ABI.
// TODO(kaib): figure out the arm-gcc ABI
TEXT runcgo(SB),7,$16
BL abort(SB)
TEXT runtime·runcgo(SB),7,$16
BL runtime·abort(SB)
// MOVL fn+0(FP), AX
// MOVL arg+4(FP), BX
// MOVL SP, CX
......@@ -265,13 +265,13 @@ TEXT runcgo(SB),7,$16
// MOVL 4(SP), SP
// RET
TEXT emptyfunc(SB),0,$0
TEXT runtime·emptyfunc(SB),0,$0
RET
TEXT abort(SB),7,$-4
TEXT runtime·abort(SB),7,$-4
MOVW $0, R0
MOVW (R0), R1
TEXT runcgocallback(SB),7,$0
TEXT runtime·runcgocallback(SB),7,$0
MOVW $0, R0
MOVW (R0), R1
......@@ -14,12 +14,12 @@
// }else
// return 0;
TEXT cas(SB),7,$0
TEXT runtime·cas(SB),7,$0
MOVW 0(FP), R0 // *val
MOVW 4(FP), R1 // old
MOVW 8(FP), R2 // new
MOVW $1, R3
MOVW $cas_mutex(SB), R4
MOVW $runtime·cas_mutex(SB), R4
l:
SWPW (R4), R3 // acquire mutex
CMP $0, R3
......@@ -39,5 +39,5 @@ fail0:
MOVW $0, R0
RET
DATA cas_mutex(SB)/4, $0
GLOBL cas_mutex(SB), $4
DATA runtime·cas_mutex(SB)/4, $0
GLOBL runtime·cas_mutex(SB), $4
......@@ -47,20 +47,20 @@ extern void cacheflush(byte* start, byte* end);
#pragma textflag 7
void
·closure(int32 siz, byte *fn, byte *arg0)
runtime·closure(int32 siz, byte *fn, byte *arg0)
{
byte *p, *q, **ret;
uint32 *pc;
int32 n;
if(siz < 0 || siz%4 != 0)
throw("bad closure size");
runtime·throw("bad closure size");
ret = (byte**)((byte*)&arg0 + siz);
if(siz > 100) {
// TODO(kaib): implement stack growth preamble?
throw("closure too big");
runtime·throw("closure too big");
}
// size of new fn.
......@@ -73,7 +73,7 @@ void
// store args aligned after code, so gc can find them.
n += siz;
p = mal(n);
p = runtime·mal(n);
*ret = p;
q = p + n - siz;
......@@ -83,7 +83,7 @@ void
*pc++ = 0xe52de000 | (siz + 4);
if(siz > 0) {
mcpy(q, (byte*)&arg0, siz);
runtime·mcpy(q, (byte*)&arg0, siz);
// MOVW $vars(PC), R0
*pc = 0xe28f0000 | (int32)(q - (byte*)pc - 8);
......@@ -122,8 +122,8 @@ void
p = (byte*)pc;
if(p > q)
throw("bad math in sys.closure");
runtime·throw("bad math in sys.closure");
cacheflush(*ret, q+siz);
runtime·cacheflush(*ret, q+siz);
}
......@@ -31,7 +31,7 @@ TMP = 3 /* N and TMP don't overlap */
TMP1 = 4
// TODO(kaib): This can be done with the existing registers of LR is re-used. Same for memset.
TEXT memmove(SB), 7, $8
TEXT runtime·memmove(SB), 7, $8
// save g and m
MOVW R9, 4(R13)
MOVW R10, 8(R13)
......
......@@ -31,7 +31,7 @@ TMP = 3 /* N and TMP don't overlap */
// TODO(kaib): memset clobbers R9 and R10 (m and g). This makes the
// registers unpredictable if (when) memset SIGSEGV's. Fix it by
// moving the R4-R11 register bank.
TEXT memset(SB), $0
TEXT runtime·memset(SB), $0
MOVW R0, R(TO)
MOVW data+4(FP), R(4)
MOVW n+8(FP), R(N)
......
......@@ -14,8 +14,8 @@ static void
fabort(void)
{
if (1) {
printf("Unsupported floating point instruction\n");
abort();
runtime·printf("Unsupported floating point instruction\n");
runtime·abort();
}
}
......@@ -88,7 +88,7 @@ precision(uint32 i)
case 0x80:
return 1;
default:
fabort();
runtime·fabort();
}
return 0;
}
......@@ -108,7 +108,7 @@ fprint(void)
{
uint32 i;
for (i = 0; i < 8; i++) {
printf("\tf%d:\t%X\n", i, m->freg[i]);
runtime·printf("\tf%d:\t%X\n", i, m->freg[i]);
}
}
......@@ -117,7 +117,7 @@ d2s(uint64 d)
{
uint32 x;
·f64to32c(d, &x);
runtime·f64to32c(d, &x);
return x;
}
......@@ -126,7 +126,7 @@ s2d(uint32 s)
{
uint64 x;
·f32to64c(s, &x);
runtime·f32to64c(s, &x);
return x;
}
......@@ -147,16 +147,16 @@ dataprocess(uint32* pc)
lhs = i>>16 & 7;
rhs = i & 15;
prec = precision(i);
prec = runtime·precision(i);
// if (prec != 1)
// goto undef;
if (unary) {
switch (opcode) {
case 0: // mvf
fd = frhs(rhs);
fd = runtime·frhs(rhs);
if(prec == 0)
fd = s2d(d2s(fd));
fd = runtime·s2d(d2s(fd));
m->freg[dest] = fd;
goto ret;
default:
......@@ -164,21 +164,21 @@ dataprocess(uint32* pc)
}
} else {
l = m->freg[lhs];
r = frhs(rhs);
r = runtime·frhs(rhs);
switch (opcode) {
default:
goto undef;
case 0:
·fadd64c(l, r, &m->freg[dest]);
runtime·fadd64c(l, r, &m->freg[dest]);
break;
case 1:
·fmul64c(l, r, &m->freg[dest]);
runtime·fmul64c(l, r, &m->freg[dest]);
break;
case 2:
·fsub64c(l, r, &m->freg[dest]);
runtime·fsub64c(l, r, &m->freg[dest]);
break;
case 4:
·fdiv64c(l, r, &m->freg[dest]);
runtime·fdiv64c(l, r, &m->freg[dest]);
break;
}
goto ret;
......@@ -190,18 +190,18 @@ undef:
ret:
if (trace || doabort) {
printf(" %p %x\t%s%s\tf%d, ", pc, *pc, opnames[opcode | unary<<4],
runtime·printf(" %p %x\t%s%s\tf%d, ", pc, *pc, opnames[opcode | unary<<4],
fpprec[prec], dest);
if (!unary)
printf("f%d, ", lhs);
runtime·printf("f%d, ", lhs);
if (rhs & 0x8)
printf("#%s\n", fpconst[rhs&0x7]);
runtime·printf("#%s\n", fpconst[rhs&0x7]);
else
printf("f%d\n", rhs&0x7);
fprint();
runtime·printf("f%d\n", rhs&0x7);
runtime·fprint();
}
if (doabort)
fabort();
runtime·fabort();
}
#define CPSR 14
......@@ -225,8 +225,8 @@ compare(uint32 *pc, uint32 *regs)
rhs = i & 0xf;
l = m->freg[lhs];
r = frhs(rhs);
·fcmp64c(l, r, &cmp, &nan);
r = runtime·frhs(rhs);
runtime·fcmp64c(l, r, &cmp, &nan);
if (nan)
flags = FLAGS_C | FLAGS_V;
else if (cmp == 0)
......@@ -237,11 +237,11 @@ compare(uint32 *pc, uint32 *regs)
flags = FLAGS_C;
if (trace) {
printf(" %p %x\tcmf\tf%d, ", pc, *pc, lhs);
runtime·printf(" %p %x\tcmf\tf%d, ", pc, *pc, lhs);
if (rhs & 0x8)
printf("#%s\n", fpconst[rhs&0x7]);
runtime·printf("#%s\n", fpconst[rhs&0x7]);
else
printf("f%d\n", rhs&0x7);
runtime·printf("f%d\n", rhs&0x7);
}
regs[CPSR] = regs[CPSR] & 0x0fffffff | flags;
}
......@@ -278,12 +278,12 @@ loadstore(uint32 *pc, uint32 *regs)
if (tlen)
m->freg[freg] = *((uint64*)addr);
else
m->freg[freg] = s2d(*((uint32*)addr));
m->freg[freg] = runtime·s2d(*((uint32*)addr));
else
if (tlen)
*((uint64*)addr) = m->freg[freg];
else
*((uint32*)addr) = d2s(m->freg[freg]);
*((uint32*)addr) = runtime·d2s(m->freg[freg]);
goto ret;
undef:
......@@ -292,18 +292,18 @@ undef:
ret:
if (trace || doabort) {
if (isload)
printf(" %p %x\tldf", pc, *pc);
runtime·printf(" %p %x\tldf", pc, *pc);
else
printf(" %p %x\tstf", pc, *pc);
printf("%s\t\tf%d, %s%d(r%d)", fpprec[tlen], freg, ud ? "" : "-", offset, reg);
printf("\t\t// %p", regs[reg] + (ud ? offset : -offset));
runtime·printf(" %p %x\tstf", pc, *pc);
runtime·printf("%s\t\tf%d, %s%d(r%d)", fpprec[tlen], freg, ud ? "" : "-", offset, reg);
runtime·printf("\t\t// %p", regs[reg] + (ud ? offset : -offset));
if (coproc != 1 || p != 1 || wb != 0)
printf(" coproc: %d pre: %d wb %d", coproc, p, wb);
printf("\n");
fprint();
runtime·printf(" coproc: %d pre: %d wb %d", coproc, p, wb);
runtime·printf("\n");
runtime·fprint();
}
if (doabort)
fabort();
runtime·fabort();
}
static void
......@@ -318,16 +318,16 @@ fltfix(uint32 *pc, uint32 *regs)
toarm = i>>20 & 0x1;
freg = i>>16 & 0x7;
reg = i>>12 & 0xf;
prec = precision(i);
prec = runtime·precision(i);
if (toarm) { // fix
f0 = m->freg[freg];
·f64tointc(f0, &val, &ok);
runtime·f64tointc(f0, &val, &ok);
if (!ok || (int32)val != val)
val = 0;
regs[reg] = val;
} else { // flt
·fintto64c((int32)regs[reg], &f0);
runtime·fintto64c((int32)regs[reg], &f0);
m->freg[freg] = f0;
}
goto ret;
......@@ -335,13 +335,13 @@ fltfix(uint32 *pc, uint32 *regs)
ret:
if (trace || doabort) {
if (toarm)
printf(" %p %x\tfix%s\t\tr%d, f%d\n", pc, *pc, fpprec[prec], reg, freg);
runtime·printf(" %p %x\tfix%s\t\tr%d, f%d\n", pc, *pc, fpprec[prec], reg, freg);
else
printf(" %p %x\tflt%s\t\tf%d, r%d\n", pc, *pc, fpprec[prec], freg, reg);
fprint();
runtime·printf(" %p %x\tflt%s\t\tf%d, r%d\n", pc, *pc, fpprec[prec], freg, reg);
runtime·fprint();
}
if (doabort)
fabort();
runtime·fabort();
}
// returns number of words that the fp instruction is occupying, 0 if next instruction isn't float.
......@@ -367,7 +367,7 @@ stepflt(uint32 *pc, uint32 *regs)
c = i >> 25 & 7;
switch(c) {
case 6: // 110
loadstore(pc, regs);
runtime·loadstore(pc, regs);
return 1;
case 7: // 111
if (i>>24 & 1)
......@@ -375,15 +375,15 @@ stepflt(uint32 *pc, uint32 *regs)
if (i>>4 & 1) { //data transfer
if ((i&0x00f0ff00) == 0x0090f100) {
compare(pc, regs);
runtime·compare(pc, regs);
} else if ((i&0x00e00f10) == 0x00000110) {
fltfix(pc, regs);
runtime·fltfix(pc, regs);
} else {
printf(" %p %x\t// case 7 fail\n", pc, i);
fabort();
runtime·printf(" %p %x\t// case 7 fail\n", pc, i);
runtime·fabort();
}
} else {
dataprocess(pc);
runtime·dataprocess(pc);
}
return 1;
}
......@@ -410,11 +410,11 @@ stepflt(uint32 *pc, uint32 *regs)
#pragma textflag 7
uint32*
_sfloat2(uint32 *lr, uint32 r0)
runtime·_sfloat2(uint32 *lr, uint32 r0)
{
uint32 skip;
while(skip = stepflt(lr, &r0))
while(skip = runtime·stepflt(lr, &r0))
lr += skip;
return lr;
}
......
......@@ -16,9 +16,9 @@ gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, i
lr = (uintptr)lr0;
// If the PC is goexit, it hasn't started yet.
if(pc == (uintptr)goexit) {
if(pc == (uintptr)runtime·goexit) {
pc = (uintptr)g->entry;
lr = (uintptr)goexit;
lr = (uintptr)runtime·goexit;
}
// If the PC is zero, it's likely a nil function call.
......@@ -31,7 +31,7 @@ gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, i
n = 0;
stk = (Stktop*)g->stackbase;
for(iter = 0; iter < 100 && n < m; iter++) { // iter avoids looping forever
if(pc == (uintptr)·lessstack) {
if(pc == (uintptr)runtime·lessstack) {
// Hit top of stack segment. Unwind to next segment.
pc = (uintptr)stk->gobuf.pc;
sp = stk->gobuf.sp;
......@@ -39,7 +39,7 @@ gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, i
stk = (Stktop*)stk->stackbase;
continue;
}
if(pc <= 0x1000 || (f = findfunc(pc-4)) == nil) {
if(pc <= 0x1000 || (f = runtime·findfunc(pc-4)) == nil) {
// TODO: Check for closure.
break;
}
......@@ -53,24 +53,24 @@ gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, i
// Print during crash.
// main+0xf /home/rsc/go/src/runtime/x.go:23
// main(0x1, 0x2, 0x3)
printf("%S", f->name);
runtime·printf("%S", f->name);
if(pc > f->entry)
printf("+%p", (uintptr)(pc - f->entry));
runtime·printf("+%p", (uintptr)(pc - f->entry));
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry)
tracepc -= sizeof(uintptr);
printf(" %S:%d\n", f->src, funcline(f, tracepc));
printf("\t%S(", f->name);
runtime·printf(" %S:%d\n", f->src, runtime·funcline(f, tracepc));
runtime·printf("\t%S(", f->name);
for(i = 0; i < f->args; i++) {
if(i != 0)
prints(", ");
·printhex(((uintptr*)sp)[1+i]);
runtime·prints(", ");
runtime·printhex(((uintptr*)sp)[1+i]);
if(i >= 4) {
prints(", ...");
runtime·prints(", ...");
break;
}
}
prints(")\n");
runtime·prints(")\n");
n++;
}
......@@ -85,19 +85,19 @@ gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, i
}
void
traceback(byte *pc0, byte *sp, byte *lr, G *g)
runtime·traceback(byte *pc0, byte *sp, byte *lr, G *g)
{
gentraceback(pc0, sp, lr, g, 0, nil, 100);
}
// func caller(n int) (pc uintptr, file string, line int, ok bool)
int32
callers(int32 skip, uintptr *pcbuf, int32 m)
runtime·callers(int32 skip, uintptr *pcbuf, int32 m)
{
byte *pc, *sp;
sp = getcallersp(&skip);
pc = ·getcallerpc(&skip);
sp = runtime·getcallersp(&skip);
pc = runtime·getcallerpc(&skip);
return gentraceback(pc, sp, 0, g, skip, pcbuf, m);
}
......@@ -24,7 +24,7 @@
// THE SOFTWARE.
// declared here to avoid include of runtime.h
void panicstring(char*);
void runtime·panicstring(char*);
typedef unsigned long ulong;
typedef unsigned int uint;
......@@ -35,9 +35,9 @@ typedef signed char schar;
#define SIGN(n) (1UL<<(n-1))
void
panicdivide(void)
runtime·panicdivide(void)
{
panicstring("integer divide by zero");
runtime·panicstring("integer divide by zero");
}
typedef struct Vlong Vlong;
......@@ -60,7 +60,7 @@ struct Vlong
};
};
void abort(void);
void runtime·abort(void);
void
_addv(Vlong *r, Vlong a, Vlong b)
......@@ -152,7 +152,7 @@ _f2v(Vlong *y, float f)
}
void
·float64toint64(double d, Vlong y)
runtime·float64toint64(double d, Vlong y)
{
_d2v(&y, d);
}
......@@ -178,7 +178,7 @@ _v2f(Vlong x)
}
void
·int64tofloat64(Vlong y, double d)
runtime·int64tofloat64(Vlong y, double d)
{
d = _v2d(y);
}
......@@ -199,7 +199,7 @@ dodiv(Vlong num, Vlong den, Vlong *q, Vlong *r)
* get a divide by zero
*/
if(denlo==0 && denhi==0) {
panicdivide();
runtime·panicdivide();
}
/*
......@@ -259,7 +259,7 @@ _divvu(Vlong *q, Vlong n, Vlong d)
}
void
·uint64div(Vlong n, Vlong d, Vlong q)
runtime·uint64div(Vlong n, Vlong d, Vlong q)
{
_divvu(&q, n, d);
}
......@@ -277,7 +277,7 @@ _modvu(Vlong *r, Vlong n, Vlong d)
}
void
·uint64mod(Vlong n, Vlong d, Vlong q)
runtime·uint64mod(Vlong n, Vlong d, Vlong q)
{
_modvu(&q, n, d);
}
......@@ -322,7 +322,7 @@ _divv(Vlong *q, Vlong n, Vlong d)
}
void
·int64div(Vlong n, Vlong d, Vlong q)
runtime·int64div(Vlong n, Vlong d, Vlong q)
{
_divv(&q, n, d);
}
......@@ -349,7 +349,7 @@ _modv(Vlong *r, Vlong n, Vlong d)
}
void
·int64mod(Vlong n, Vlong d, Vlong q)
runtime·int64mod(Vlong n, Vlong d, Vlong q)
{
_modv(&q, n, d);
}
......@@ -502,7 +502,7 @@ _vasop(Vlong *ret, void *lv, void fn(Vlong*, Vlong, Vlong), int type, Vlong rv)
u = *ret;
switch(type) {
default:
abort();
runtime·abort();
break;
case 1: /* schar */
......
......@@ -7,16 +7,16 @@
void *initcgo; /* filled in by dynamic linker when Cgo is available */
int64 ncgocall;
void ·entersyscall(void);
void ·exitsyscall(void);
void runtime·entersyscall(void);
void runtime·exitsyscall(void);
void
cgocall(void (*fn)(void*), void *arg)
runtime·cgocall(void (*fn)(void*), void *arg)
{
G *oldlock;
if(initcgo == nil)
throw("cgocall unavailable");
runtime·throw("cgocall unavailable");
ncgocall++;
......@@ -34,9 +34,9 @@ cgocall(void (*fn)(void*), void *arg)
* M to run goroutines while we are in the
* foreign code.
*/
·entersyscall();
runcgo(fn, arg);
·exitsyscall();
runtime·entersyscall();
runtime·runcgo(fn, arg);
runtime·exitsyscall();
m->lockedg = oldlock;
if(oldlock == nil)
......@@ -51,38 +51,38 @@ cgocall(void (*fn)(void*), void *arg)
// arguments back where they came from, and finally returns to the old
// stack.
void
cgocallback(void (*fn)(void), void *arg, int32 argsize)
runtime·cgocallback(void (*fn)(void), void *arg, int32 argsize)
{
Gobuf oldsched, oldg1sched;
G *g1;
void *sp;
if(g != m->g0)
throw("bad g in cgocallback");
runtime·throw("bad g in cgocallback");
g1 = m->curg;
oldsched = m->sched;
oldg1sched = g1->sched;
startcgocallback(g1);
runtime·startcgocallback(g1);
sp = g1->sched.sp - argsize;
if(sp < g1->stackguard)
throw("g stack overflow in cgocallback");
mcpy(sp, arg, argsize);
runtime·throw("g stack overflow in cgocallback");
runtime·mcpy(sp, arg, argsize);
runcgocallback(g1, sp, fn);
runtime·runcgocallback(g1, sp, fn);
mcpy(arg, sp, argsize);
runtime·mcpy(arg, sp, argsize);
endcgocallback(g1);
runtime·endcgocallback(g1);
m->sched = oldsched;
g1->sched = oldg1sched;
}
void
·Cgocalls(int64 ret)
runtime·Cgocalls(int64 ret)
{
ret = ncgocall;
FLUSH(&ret);
......@@ -92,7 +92,7 @@ void (*_cgo_malloc)(void*);
void (*_cgo_free)(void*);
void*
cmalloc(uintptr n)
runtime·cmalloc(uintptr n)
{
struct a {
uint64 n;
......@@ -101,13 +101,13 @@ cmalloc(uintptr n)
a.n = n;
a.ret = nil;
cgocall(_cgo_malloc, &a);
runtime·cgocall(_cgo_malloc, &a);
return a.ret;
}
void
cfree(void *p)
runtime·cfree(void *p)
{
cgocall(_cgo_free, p);
runtime·cgocall(_cgo_free, p);
}
......@@ -6,7 +6,7 @@
* Cgo interface.
*/
void cgocall(void (*fn)(void*), void*);
void cgocallback(void (*fn)(void), void*, int32);
void *cmalloc(uintptr);
void cfree(void*);
void runtime·cgocall(void (*fn)(void*), void*);
void runtime·cgocallback(void (*fn)(void), void*, int32);
void *runtime·cmalloc(uintptr);
void runtime·cfree(void*);
This diff is collapsed.
......@@ -7,34 +7,34 @@
typedef struct Complex128 Complex128;
void
·complex128div(Complex128 n, Complex128 d, Complex128 q)
runtime·complex128div(Complex128 n, Complex128 d, Complex128 q)
{
int32 ninf, dinf, nnan, dnan;
float64 a, b, ratio, denom;
// Special cases as in C99.
ninf = isInf(n.real, 0) || isInf(n.imag, 0);
dinf = isInf(d.real, 0) || isInf(d.imag, 0);
ninf = runtime·isInf(n.real, 0) || runtime·isInf(n.imag, 0);
dinf = runtime·isInf(d.real, 0) || runtime·isInf(d.imag, 0);
nnan = !ninf && (isNaN(n.real) || isNaN(n.imag));
dnan = !dinf && (isNaN(d.real) || isNaN(d.imag));
nnan = !ninf && (runtime·isNaN(n.real) || runtime·isNaN(n.imag));
dnan = !dinf && (runtime·isNaN(d.real) || runtime·isNaN(d.imag));
if(nnan || dnan) {
q.real = NaN();
q.imag = NaN();
q.real = runtime·NaN();
q.imag = runtime·NaN();
} else if(ninf && !dinf && !dnan) {
q.real = Inf(0);
q.imag = Inf(0);
q.real = runtime·Inf(0);
q.imag = runtime·Inf(0);
} else if(!ninf && !nnan && dinf) {
q.real = 0;
q.imag = 0;
} else if(d.real == 0 && d.imag == 0) {
if(n.real == 0 && n.imag == 0) {
q.real = NaN();
q.imag = NaN();
q.real = runtime·NaN();
q.imag = runtime·NaN();
} else {
q.real = Inf(0);
q.imag = Inf(0);
q.real = runtime·Inf(0);
q.imag = runtime·Inf(0);
}
} else {
// Standard complex arithmetic, factored to avoid unnecessary overflow.
......
......@@ -8,39 +8,38 @@
#include "signals.h"
void
dumpregs(Regs *r)
runtime·dumpregs(Regs *r)
{
printf("eax %x\n", r->eax);
printf("ebx %x\n", r->ebx);
printf("ecx %x\n", r->ecx);
printf("edx %x\n", r->edx);
printf("edi %x\n", r->edi);
printf("esi %x\n", r->esi);
printf("ebp %x\n", r->ebp);
printf("esp %x\n", r->esp);
printf("eip %x\n", r->eip);
printf("eflags %x\n", r->eflags);
printf("cs %x\n", r->cs);
printf("fs %x\n", r->fs);
printf("gs %x\n", r->gs);
runtime·printf("eax %x\n", r->eax);
runtime·printf("ebx %x\n", r->ebx);
runtime·printf("ecx %x\n", r->ecx);
runtime·printf("edx %x\n", r->edx);
runtime·printf("edi %x\n", r->edi);
runtime·printf("esi %x\n", r->esi);
runtime·printf("ebp %x\n", r->ebp);
runtime·printf("esp %x\n", r->esp);
runtime·printf("eip %x\n", r->eip);
runtime·printf("eflags %x\n", r->eflags);
runtime·printf("cs %x\n", r->cs);
runtime·printf("fs %x\n", r->fs);
runtime·printf("gs %x\n", r->gs);
}
String
signame(int32 sig)
runtime·signame(int32 sig)
{
if(sig < 0 || sig >= NSIG)
return emptystring;
return gostringnocopy((byte*)sigtab[sig].name);
return runtime·emptystring;
return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name);
}
void
sighandler(int32 sig, Siginfo *info, void *context)
runtime·sighandler(int32 sig, Siginfo *info, void *context)
{
Ucontext *uc;
Mcontext *mc;
Regs *r;
uintptr *sp;
void (*fn)(void);
G *gp;
byte *pc;
......@@ -48,7 +47,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
mc = uc->uc_mcontext;
r = &mc->ss;
if((gp = m->curg) != nil && (sigtab[sig].flags & SigPanic)) {
if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
// Work around Leopard bug that doesn't set FPE_INTDIV.
// Look at instruction to see if it is a divide.
// Not necessary in Snow Leopard (si_code will be != 0).
......@@ -68,91 +67,91 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->eip != 0.
// Only push runtime·sigpanic if r->eip != 0.
// If r->eip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// make the trace look like a call to runtime·sigpanic instead.
// (Otherwise the trace will end at runtime·sigpanic and we
// won't get to see who faulted.)
if(r->eip != 0) {
sp = (uintptr*)r->esp;
*--sp = r->eip;
r->esp = (uintptr)sp;
}
r->eip = (uintptr)sigpanic;
r->eip = (uintptr)runtime·sigpanic;
return;
}
if(sigtab[sig].flags & SigQueue) {
if(sigsend(sig) || (sigtab[sig].flags & SigIgnore))
if(runtime·sigtab[sig].flags & SigQueue) {
if(runtime·sigsend(sig) || (runtime·sigtab[sig].flags & SigIgnore))
return;
exit(2); // SIGINT, SIGTERM, etc
runtime·exit(2); // SIGINT, SIGTERM, etc
}
if(panicking) // traceback already printed
exit(2);
panicking = 1;
if(runtime·panicking) // traceback already printed
runtime·exit(2);
runtime·panicking = 1;
if(sig < 0 || sig >= NSIG){
printf("Signal %d\n", sig);
runtime·printf("Signal %d\n", sig);
}else{
printf("%s\n", sigtab[sig].name);
runtime·printf("%s\n", runtime·sigtab[sig].name);
}
printf("pc: %x\n", r->eip);
printf("\n");
runtime·printf("pc: %x\n", r->eip);
runtime·printf("\n");
if(gotraceback()){
traceback((void*)r->eip, (void*)r->esp, 0, m->curg);
tracebackothers(m->curg);
dumpregs(r);
if(runtime·gotraceback()){
runtime·traceback((void*)r->eip, (void*)r->esp, 0, m->curg);
runtime·tracebackothers(m->curg);
runtime·dumpregs(r);
}
breakpoint();
exit(2);
runtime·breakpoint();
runtime·exit(2);
}
void
sigignore(int32, Siginfo*, void*)
runtime·sigignore(int32, Siginfo*, void*)
{
}
void
signalstack(byte *p, int32 n)
runtime·signalstack(byte *p, int32 n)
{
StackT st;
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
sigaltstack(&st, nil);
runtime·sigaltstack(&st, nil);
}
void
initsig(int32 queue)
runtime·initsig(int32 queue)
{
int32 i;
static Sigaction sa;
siginit();
runtime·siginit();
sa.sa_flags |= SA_SIGINFO|SA_ONSTACK;
sa.sa_mask = 0xFFFFFFFFU;
sa.sa_tramp = sigtramp; // sigtramp's job is to call into real handler
sa.sa_tramp = runtime·sigtramp; // runtime·sigtramp's job is to call into real handler
for(i = 0; i<NSIG; i++) {
if(sigtab[i].flags) {
if((sigtab[i].flags & SigQueue) != queue)
if(runtime·sigtab[i].flags) {
if((runtime·sigtab[i].flags & SigQueue) != queue)
continue;
if(sigtab[i].flags & (SigCatch | SigQueue)) {
sa.__sigaction_u.__sa_sigaction = sighandler;
if(runtime·sigtab[i].flags & (SigCatch | SigQueue)) {
sa.__sigaction_u.__sa_sigaction = runtime·sighandler;
} else {
sa.__sigaction_u.__sa_sigaction = sigignore;
sa.__sigaction_u.__sa_sigaction = runtime·sigignore;
}
if(sigtab[i].flags & SigRestart)
if(runtime·sigtab[i].flags & SigRestart)
sa.sa_flags |= SA_RESTART;
else
sa.sa_flags &= ~SA_RESTART;
sigaction(i, &sa, nil);
runtime·sigaction(i, &sa, nil);
}
}
}
......@@ -8,47 +8,47 @@
#include "386/asm.h"
TEXT notok(SB),7,$0
TEXT runtime·notok(SB),7,$0
MOVL $0xf1, 0xf1
RET
// Exit the entire program (like C exit)
TEXT exit(SB),7,$0
TEXT runtime·exit(SB),7,$0
MOVL $1, AX
INT $0x80
CALL notok(SB)
CALL runtime·notok(SB)
RET
// Exit this OS thread (like pthread_exit, which eventually
// calls __bsdthread_terminate).
TEXT exit1(SB),7,$0
TEXT runtime·exit1(SB),7,$0
MOVL $361, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT write(SB),7,$0
TEXT runtime·write(SB),7,$0
MOVL $4, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT ·mmap(SB),7,$0
TEXT runtime·mmap(SB),7,$0
MOVL $197, AX
INT $0x80
RET
TEXT ·munmap(SB),7,$0
TEXT runtime·munmap(SB),7,$0
MOVL $73, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// void gettime(int64 *sec, int32 *usec)
TEXT gettime(SB), 7, $32
TEXT runtime·gettime(SB), 7, $32
LEAL 12(SP), AX // must be non-nil, unused
MOVL AX, 4(SP)
MOVL $0, 8(SP) // time zone pointer
......@@ -63,11 +63,11 @@ TEXT gettime(SB), 7, $32
MOVL DX, (DI)
RET
TEXT sigaction(SB),7,$0
TEXT runtime·sigaction(SB),7,$0
MOVL $46, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// Sigtramp's job is to call the actual signal handler.
......@@ -78,7 +78,7 @@ TEXT sigaction(SB),7,$0
// 12(FP) signal number
// 16(FP) siginfo
// 20(FP) context
TEXT sigtramp(SB),7,$40
TEXT runtime·sigtramp(SB),7,$40
get_tls(CX)
// save g
......@@ -114,19 +114,19 @@ TEXT sigtramp(SB),7,$40
MOVL BX, 8(SP)
MOVL $184, AX // sigreturn(ucontext, infostyle)
INT $0x80
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT sigaltstack(SB),7,$0
TEXT runtime·sigaltstack(SB),7,$0
MOVL $53, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
// System call args are: func arg stack pthread flags.
TEXT bsdthread_create(SB),7,$32
TEXT runtime·bsdthread_create(SB),7,$32
MOVL $360, AX
// 0(SP) is where the caller PC would be; kernel skips it
MOVL func+12(FP), BX
......@@ -155,7 +155,7 @@ TEXT bsdthread_create(SB),7,$32
// DI = stack top
// SI = flags (= 0x1000000)
// SP = stack - C_32_STK_ALIGN
TEXT bsdthread_start(SB),7,$0
TEXT runtime·bsdthread_start(SB),7,$0
// set up ldt 7+id to point at m->tls.
// m->tls is at m+40. newosproc left
// the m->id in tls[0].
......@@ -167,7 +167,7 @@ TEXT bsdthread_start(SB),7,$0
PUSHL $32 // sizeof tls
PUSHL BP // &tls
PUSHL DI // tls #
CALL setldt(SB)
CALL runtime·setldt(SB)
POPL AX
POPL AX
POPL AX
......@@ -178,18 +178,18 @@ TEXT bsdthread_start(SB),7,$0
MOVL AX, g(BP)
MOVL DX, m(BP)
MOVL BX, m_procid(DX) // m->procid = thread port (for debuggers)
CALL stackcheck(SB) // smashes AX
CALL runtime·stackcheck(SB) // smashes AX
CALL CX // fn()
CALL exit1(SB)
CALL runtime·exit1(SB)
RET
// void bsdthread_register(void)
// registers callbacks for threadstart (see bsdthread_create above
// and wqthread and pthsize (not used). returns 0 on success.
TEXT bsdthread_register(SB),7,$40
TEXT runtime·bsdthread_register(SB),7,$40
MOVL $366, AX
// 0(SP) is where kernel expects caller PC; ignored
MOVL $bsdthread_start(SB), 4(SP) // threadstart
MOVL $runtime·bsdthread_start(SB), 4(SP) // threadstart
MOVL $0, 8(SP) // wqthread, not used by us
MOVL $0, 12(SP) // pthsize, not used by us
MOVL $0, 16(SP) // dummy_value [sic]
......@@ -197,7 +197,7 @@ TEXT bsdthread_register(SB),7,$40
MOVL $0, 24(SP) // dispatchqueue_offset
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// Invoke Mach system call.
......@@ -211,57 +211,57 @@ TEXT bsdthread_register(SB),7,$40
// in the high 16 bits that seems to be the
// argument count in bytes but is not always.
// INT $0x80 works fine for those.
TEXT sysenter(SB),7,$0
TEXT runtime·sysenter(SB),7,$0
POPL DX
MOVL SP, CX
BYTE $0x0F; BYTE $0x34; // SYSENTER
// returns to DX with SP set to CX
TEXT mach_msg_trap(SB),7,$0
TEXT runtime·mach_msg_trap(SB),7,$0
MOVL $-31, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
TEXT mach_reply_port(SB),7,$0
TEXT runtime·mach_reply_port(SB),7,$0
MOVL $-26, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
TEXT mach_task_self(SB),7,$0
TEXT runtime·mach_task_self(SB),7,$0
MOVL $-28, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
// Mach provides trap versions of the semaphore ops,
// instead of requiring the use of RPC.
// uint32 mach_semaphore_wait(uint32)
TEXT mach_semaphore_wait(SB),7,$0
TEXT runtime·mach_semaphore_wait(SB),7,$0
MOVL $-36, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
// uint32 mach_semaphore_timedwait(uint32, uint32, uint32)
TEXT mach_semaphore_timedwait(SB),7,$0
TEXT runtime·mach_semaphore_timedwait(SB),7,$0
MOVL $-38, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
// uint32 mach_semaphore_signal(uint32)
TEXT mach_semaphore_signal(SB),7,$0
TEXT runtime·mach_semaphore_signal(SB),7,$0
MOVL $-33, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
// uint32 mach_semaphore_signal_all(uint32)
TEXT mach_semaphore_signal_all(SB),7,$0
TEXT runtime·mach_semaphore_signal_all(SB),7,$0
MOVL $-34, AX
CALL sysenter(SB)
CALL runtime·sysenter(SB)
RET
// setldt(int entry, int address, int limit)
// entry and limit are ignored.
TEXT setldt(SB),7,$32
TEXT runtime·setldt(SB),7,$32
MOVL address+4(FP), BX // aka base
/*
......
......@@ -8,41 +8,41 @@
#include "signals.h"
void
dumpregs(Regs *r)
runtime·dumpregs(Regs *r)
{
printf("rax %X\n", r->rax);
printf("rbx %X\n", r->rbx);
printf("rcx %X\n", r->rcx);
printf("rdx %X\n", r->rdx);
printf("rdi %X\n", r->rdi);
printf("rsi %X\n", r->rsi);
printf("rbp %X\n", r->rbp);
printf("rsp %X\n", r->rsp);
printf("r8 %X\n", r->r8 );
printf("r9 %X\n", r->r9 );
printf("r10 %X\n", r->r10);
printf("r11 %X\n", r->r11);
printf("r12 %X\n", r->r12);
printf("r13 %X\n", r->r13);
printf("r14 %X\n", r->r14);
printf("r15 %X\n", r->r15);
printf("rip %X\n", r->rip);
printf("rflags %X\n", r->rflags);
printf("cs %X\n", r->cs);
printf("fs %X\n", r->fs);
printf("gs %X\n", r->gs);
runtime·printf("rax %X\n", r->rax);
runtime·printf("rbx %X\n", r->rbx);
runtime·printf("rcx %X\n", r->rcx);
runtime·printf("rdx %X\n", r->rdx);
runtime·printf("rdi %X\n", r->rdi);
runtime·printf("rsi %X\n", r->rsi);
runtime·printf("rbp %X\n", r->rbp);
runtime·printf("rsp %X\n", r->rsp);
runtime·printf("r8 %X\n", r->r8 );
runtime·printf("r9 %X\n", r->r9 );
runtime·printf("r10 %X\n", r->r10);
runtime·printf("r11 %X\n", r->r11);
runtime·printf("r12 %X\n", r->r12);
runtime·printf("r13 %X\n", r->r13);
runtime·printf("r14 %X\n", r->r14);
runtime·printf("r15 %X\n", r->r15);
runtime·printf("rip %X\n", r->rip);
runtime·printf("rflags %X\n", r->rflags);
runtime·printf("cs %X\n", r->cs);
runtime·printf("fs %X\n", r->fs);
runtime·printf("gs %X\n", r->gs);
}
String
signame(int32 sig)
runtime·signame(int32 sig)
{
if(sig < 0 || sig >= NSIG)
return emptystring;
return gostringnocopy((byte*)sigtab[sig].name);
return runtime·emptystring;
return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name);
}
void
sighandler(int32 sig, Siginfo *info, void *context)
runtime·sighandler(int32 sig, Siginfo *info, void *context)
{
Ucontext *uc;
Mcontext *mc;
......@@ -55,7 +55,7 @@ sighandler(int32 sig, Siginfo *info, void *context)
mc = uc->uc_mcontext;
r = &mc->ss;
if((gp = m->curg) != nil && (sigtab[sig].flags & SigPanic)) {
if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
// Work around Leopard bug that doesn't set FPE_INTDIV.
// Look at instruction to see if it is a divide.
// Not necessary in Snow Leopard (si_code will be != 0).
......@@ -77,91 +77,91 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->rip != 0.
// Only push runtime·sigpanic if r->rip != 0.
// If r->rip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// make the trace look like a call to runtime·sigpanic instead.
// (Otherwise the trace will end at runtime·sigpanic and we
// won't get to see who faulted.)
if(r->rip != 0) {
sp = (uintptr*)r->rsp;
*--sp = r->rip;
r->rsp = (uintptr)sp;
}
r->rip = (uintptr)sigpanic;
r->rip = (uintptr)runtime·sigpanic;
return;
}
if(sigtab[sig].flags & SigQueue) {
if(sigsend(sig) || (sigtab[sig].flags & SigIgnore))
if(runtime·sigtab[sig].flags & SigQueue) {
if(runtime·sigsend(sig) || (runtime·sigtab[sig].flags & SigIgnore))
return;
exit(2); // SIGINT, SIGTERM, etc
runtime·exit(2); // SIGINT, SIGTERM, etc
}
if(panicking) // traceback already printed
exit(2);
panicking = 1;
if(runtime·panicking) // traceback already printed
runtime·exit(2);
runtime·panicking = 1;
if(sig < 0 || sig >= NSIG){
printf("Signal %d\n", sig);
runtime·printf("Signal %d\n", sig);
}else{
printf("%s\n", sigtab[sig].name);
runtime·printf("%s\n", runtime·sigtab[sig].name);
}
printf("pc: %X\n", r->rip);
printf("\n");
runtime·printf("pc: %X\n", r->rip);
runtime·printf("\n");
if(gotraceback()){
traceback((void*)r->rip, (void*)r->rsp, 0, g);
tracebackothers(g);
dumpregs(r);
if(runtime·gotraceback()){
runtime·traceback((void*)r->rip, (void*)r->rsp, 0, g);
runtime·tracebackothers(g);
runtime·dumpregs(r);
}
breakpoint();
exit(2);
runtime·breakpoint();
runtime·exit(2);
}
void
sigignore(int32, Siginfo*, void*)
runtime·sigignore(int32, Siginfo*, void*)
{
}
void
signalstack(byte *p, int32 n)
runtime·signalstack(byte *p, int32 n)
{
StackT st;
st.ss_sp = p;
st.ss_size = n;
st.ss_flags = 0;
sigaltstack(&st, nil);
runtime·sigaltstack(&st, nil);
}
void
initsig(int32 queue)
runtime·initsig(int32 queue)
{
int32 i;
static Sigaction sa;
siginit();
runtime·siginit();
sa.sa_flags |= SA_SIGINFO|SA_ONSTACK;
sa.sa_mask = 0xFFFFFFFFU;
sa.sa_tramp = sigtramp; // sigtramp's job is to call into real handler
sa.sa_tramp = runtime·sigtramp; // runtime·sigtramp's job is to call into real handler
for(i = 0; i<NSIG; i++) {
if(sigtab[i].flags) {
if((sigtab[i].flags & SigQueue) != queue)
if(runtime·sigtab[i].flags) {
if((runtime·sigtab[i].flags & SigQueue) != queue)
continue;
if(sigtab[i].flags & (SigCatch | SigQueue)) {
sa.__sigaction_u.__sa_sigaction = sighandler;
if(runtime·sigtab[i].flags & (SigCatch | SigQueue)) {
sa.__sigaction_u.__sa_sigaction = runtime·sighandler;
} else {
sa.__sigaction_u.__sa_sigaction = sigignore;
sa.__sigaction_u.__sa_sigaction = runtime·sigignore;
}
if(sigtab[i].flags & SigRestart)
if(runtime·sigtab[i].flags & SigRestart)
sa.sa_flags |= SA_RESTART;
else
sa.sa_flags &= ~SA_RESTART;
sigaction(i, &sa, nil);
runtime·sigaction(i, &sa, nil);
}
}
}
......@@ -14,34 +14,34 @@
#include "amd64/asm.h"
// Exit the entire program (like C exit)
TEXT exit(SB),7,$0
TEXT runtime·exit(SB),7,$0
MOVL 8(SP), DI // arg 1 exit status
MOVL $(0x2000000+1), AX // syscall entry
SYSCALL
CALL notok(SB)
CALL runtime·notok(SB)
RET
// Exit this OS thread (like pthread_exit, which eventually
// calls __bsdthread_terminate).
TEXT exit1(SB),7,$0
TEXT runtime·exit1(SB),7,$0
MOVL 8(SP), DI // arg 1 exit status
MOVL $(0x2000000+361), AX // syscall entry
SYSCALL
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT write(SB),7,$0
TEXT runtime·write(SB),7,$0
MOVL 8(SP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count
MOVL $(0x2000000+4), AX // syscall entry
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// void gettime(int64 *sec, int32 *usec)
TEXT gettime(SB), 7, $32
TEXT runtime·gettime(SB), 7, $32
MOVQ SP, DI // must be non-nil, unused
MOVQ $0, SI
MOVQ $(0x2000000+116), AX
......@@ -52,7 +52,7 @@ TEXT gettime(SB), 7, $32
MOVL DX, (DI)
RET
TEXT sigaction(SB),7,$0
TEXT runtime·sigaction(SB),7,$0
MOVL 8(SP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact
......@@ -61,10 +61,10 @@ TEXT sigaction(SB),7,$0
MOVL $(0x2000000+46), AX // syscall entry
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT sigtramp(SB),7,$64
TEXT runtime·sigtramp(SB),7,$64
get_tls(BX)
// save g
......@@ -94,7 +94,7 @@ TEXT sigtramp(SB),7,$64
SYSCALL
INT $3 // not reached
TEXT ·mmap(SB),7,$0
TEXT runtime·mmap(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 prot
......@@ -105,31 +105,31 @@ TEXT ·mmap(SB),7,$0
SYSCALL
RET
TEXT ·munmap(SB),7,$0
TEXT runtime·munmap(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len
MOVL $(0x2000000+73), AX // syscall entry
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT notok(SB),7,$0
TEXT runtime·notok(SB),7,$0
MOVL $0xf1, BP
MOVQ BP, (BP)
RET
TEXT sigaltstack(SB),7,$0
TEXT runtime·sigaltstack(SB),7,$0
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ $(0x2000000+53), AX
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
TEXT bsdthread_create(SB),7,$0
TEXT runtime·bsdthread_create(SB),7,$0
// Set up arguments to bsdthread_create system call.
// The ones in quotes pass through to the thread callback
// uninterpreted, so we can put whatever we want there.
......@@ -158,7 +158,7 @@ TEXT bsdthread_create(SB),7,$0
// R8 = stack
// R9 = flags (= 0)
// SP = stack - C_64_REDZONE_LEN (= stack - 128)
TEXT bsdthread_start(SB),7,$0
TEXT runtime·bsdthread_start(SB),7,$0
MOVQ R8, SP // empirically, SP is very wrong but R8 is right
PUSHQ DX
......@@ -167,7 +167,7 @@ TEXT bsdthread_start(SB),7,$0
// set up thread local storage pointing at m->tls.
LEAQ m_tls(CX), DI
CALL settls(SB)
CALL runtime·settls(SB)
POPQ SI
POPQ CX
......@@ -178,16 +178,16 @@ TEXT bsdthread_start(SB),7,$0
MOVQ SI, m_procid(CX) // thread port is m->procid
MOVQ m_g0(CX), AX
MOVQ AX, g(BX)
CALL stackcheck(SB) // smashes AX, CX
CALL runtime·stackcheck(SB) // smashes AX, CX
CALL DX // fn
CALL exit1(SB)
CALL runtime·exit1(SB)
RET
// void bsdthread_register(void)
// registers callbacks for threadstart (see bsdthread_create above
// and wqthread and pthsize (not used). returns 0 on success.
TEXT bsdthread_register(SB),7,$0
MOVQ $bsdthread_start(SB), DI // threadstart
TEXT runtime·bsdthread_register(SB),7,$0
MOVQ $runtime·bsdthread_start(SB), DI // threadstart
MOVQ $0, SI // wqthread, not used by us
MOVQ $0, DX // pthsize, not used by us
MOVQ $0, R10 // dummy_value [sic]
......@@ -196,13 +196,13 @@ TEXT bsdthread_register(SB),7,$0
MOVQ $(0x2000000+366), AX // bsdthread_register
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// Mach system calls use 0x1000000 instead of the BSD's 0x2000000.
// uint32 mach_msg_trap(void*, uint32, uint32, uint32, uint32, uint32, uint32)
TEXT mach_msg_trap(SB),7,$0
TEXT runtime·mach_msg_trap(SB),7,$0
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVL 20(SP), DX
......@@ -216,17 +216,17 @@ TEXT mach_msg_trap(SB),7,$0
POPQ R11
RET
TEXT mach_task_self(SB),7,$0
TEXT runtime·mach_task_self(SB),7,$0
MOVL $(0x1000000+28), AX // task_self_trap
SYSCALL
RET
TEXT mach_thread_self(SB),7,$0
TEXT runtime·mach_thread_self(SB),7,$0
MOVL $(0x1000000+27), AX // thread_self_trap
SYSCALL
RET
TEXT mach_reply_port(SB),7,$0
TEXT runtime·mach_reply_port(SB),7,$0
MOVL $(0x1000000+26), AX // mach_reply_port
SYSCALL
RET
......@@ -235,14 +235,14 @@ TEXT mach_reply_port(SB),7,$0
// instead of requiring the use of RPC.
// uint32 mach_semaphore_wait(uint32)
TEXT mach_semaphore_wait(SB),7,$0
TEXT runtime·mach_semaphore_wait(SB),7,$0
MOVL 8(SP), DI
MOVL $(0x1000000+36), AX // semaphore_wait_trap
SYSCALL
RET
// uint32 mach_semaphore_timedwait(uint32, uint32, uint32)
TEXT mach_semaphore_timedwait(SB),7,$0
TEXT runtime·mach_semaphore_timedwait(SB),7,$0
MOVL 8(SP), DI
MOVL 12(SP), SI
MOVL 16(SP), DX
......@@ -251,21 +251,21 @@ TEXT mach_semaphore_timedwait(SB),7,$0
RET
// uint32 mach_semaphore_signal(uint32)
TEXT mach_semaphore_signal(SB),7,$0
TEXT runtime·mach_semaphore_signal(SB),7,$0
MOVL 8(SP), DI
MOVL $(0x1000000+33), AX // semaphore_signal_trap
SYSCALL
RET
// uint32 mach_semaphore_signal_all(uint32)
TEXT mach_semaphore_signal_all(SB),7,$0
TEXT runtime·mach_semaphore_signal_all(SB),7,$0
MOVL 8(SP), DI
MOVL $(0x1000000+34), AX // semaphore_signal_all_trap
SYSCALL
RET
// set tls base to DI
TEXT settls(SB),7,$32
TEXT runtime·settls(SB),7,$32
/*
* Same as in ../386/sys.s:/ugliness, different constant.
* See ../../../../libcgo/darwin_amd64.c for the derivation
......
......@@ -4,21 +4,21 @@
#include "malloc.h"
void*
SysAlloc(uintptr n)
runtime·SysAlloc(uintptr n)
{
void *v;
mstats.sys += n;
v = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) {
printf("mmap: errno=%p\n", v);
throw("mmap");
runtime·printf("mmap: errno=%p\n", v);
runtime·throw("mmap");
}
return v;
}
void
SysUnused(void *v, uintptr n)
runtime·SysUnused(void *v, uintptr n)
{
USED(v);
USED(n);
......@@ -26,15 +26,15 @@ SysUnused(void *v, uintptr n)
}
void
SysFree(void *v, uintptr n)
runtime·SysFree(void *v, uintptr n)
{
mstats.sys -= n;
runtime_munmap(v, n);
runtime·munmap(v, n);
}
void
SysMemInit(void)
runtime·SysMemInit(void)
{
// Code generators assume that references to addresses
// on the first page will fault. Map the page explicitly with
......@@ -42,5 +42,5 @@ SysMemInit(void)
// allocating that page as the virtual address space fills.
// Ignore any error, since other systems might be smart
// enough to never allow anything there.
// runtime_mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
// mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
}
......@@ -2,24 +2,24 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
int32 bsdthread_create(void*, M*, G*, void(*)(void));
void bsdthread_register(void);
int32 mach_msg_trap(MachHeader*, int32, uint32, uint32, uint32, uint32, uint32);
uint32 mach_reply_port(void);
void mach_semacquire(uint32);
uint32 mach_semcreate(void);
void mach_semdestroy(uint32);
void mach_semrelease(uint32);
void mach_semreset(uint32);
uint32 mach_task_self(void);
uint32 mach_task_self(void);
uint32 mach_thread_self(void);
uint32 mach_thread_self(void);
int32 runtime·bsdthread_create(void*, M*, G*, void(*)(void));
void runtime·bsdthread_register(void);
int32 runtime·mach_msg_trap(MachHeader*, int32, uint32, uint32, uint32, uint32, uint32);
uint32 runtime·mach_reply_port(void);
void runtime·mach_semacquire(uint32);
uint32 runtime·mach_semcreate(void);
void runtime·mach_semdestroy(uint32);
void runtime·mach_semrelease(uint32);
void runtime·mach_semreset(uint32);
uint32 runtime·mach_task_self(void);
uint32 runtime·mach_task_self(void);
uint32 runtime·mach_thread_self(void);
uint32 runtime·mach_thread_self(void);
struct Sigaction;
void sigaction(uintptr, struct Sigaction*, struct Sigaction*);
void runtime·sigaction(uintptr, struct Sigaction*, struct Sigaction*);
struct StackT;
void sigaltstack(struct StackT*, struct StackT*);
void sigtramp(void);
void sigpanic(void);
void runtime·sigaltstack(struct StackT*, struct StackT*);
void runtime·sigtramp(void);
void runtime·sigpanic(void);
......@@ -8,7 +8,7 @@
#define Q SigQueue
#define P SigPanic
SigTab sigtab[] = {
SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap",
/* 1 */ Q+R, "SIGHUP: terminal line hangup",
/* 2 */ Q+R, "SIGINT: interrupt",
......
This diff is collapsed.
......@@ -9,7 +9,7 @@ static uint64 uvinf = 0x7FF0000000000000ULL;
static uint64 uvneginf = 0xFFF0000000000000ULL;
uint32
float32tobits(float32 f)
runtime·float32tobits(float32 f)
{
// The obvious cast-and-pointer code is technically
// not valid, and gcc miscompiles it. Use a union instead.
......@@ -22,7 +22,7 @@ float32tobits(float32 f)
}
uint64
float64tobits(float64 f)
runtime·float64tobits(float64 f)
{
// The obvious cast-and-pointer code is technically
// not valid, and gcc miscompiles it. Use a union instead.
......@@ -35,7 +35,7 @@ float64tobits(float64 f)
}
float64
float64frombits(uint64 i)
runtime·float64frombits(uint64 i)
{
// The obvious cast-and-pointer code is technically
// not valid, and gcc miscompiles it. Use a union instead.
......@@ -48,7 +48,7 @@ float64frombits(uint64 i)
}
float32
float32frombits(uint32 i)
runtime·float32frombits(uint32 i)
{
// The obvious cast-and-pointer code is technically
// not valid, and gcc miscompiles it. Use a union instead.
......@@ -61,11 +61,11 @@ float32frombits(uint32 i)
}
bool
isInf(float64 f, int32 sign)
runtime·isInf(float64 f, int32 sign)
{
uint64 x;
x = float64tobits(f);
x = runtime·float64tobits(f);
if(sign == 0)
return x == uvinf || x == uvneginf;
if(sign > 0)
......@@ -74,27 +74,27 @@ isInf(float64 f, int32 sign)
}
float64
NaN(void)
runtime·NaN(void)
{
return float64frombits(uvnan);
return runtime·float64frombits(uvnan);
}
bool
isNaN(float64 f)
runtime·isNaN(float64 f)
{
uint64 x;
x = float64tobits(f);
return ((uint32)(x>>52) & 0x7FF) == 0x7FF && !isInf(f, 0);
x = runtime·float64tobits(f);
return ((uint32)(x>>52) & 0x7FF) == 0x7FF && !runtime·isInf(f, 0);
}
float64
Inf(int32 sign)
runtime·Inf(int32 sign)
{
if(sign >= 0)
return float64frombits(uvinf);
return runtime·float64frombits(uvinf);
else
return float64frombits(uvneginf);
return runtime·float64frombits(uvneginf);
}
enum
......@@ -105,7 +105,7 @@ enum
};
float64
frexp(float64 d, int32 *ep)
runtime·frexp(float64 d, int32 *ep)
{
uint64 x;
......@@ -113,36 +113,36 @@ frexp(float64 d, int32 *ep)
*ep = 0;
return 0;
}
x = float64tobits(d);
x = runtime·float64tobits(d);
*ep = (int32)((x >> SHIFT) & MASK) - BIAS;
x &= ~((uint64)MASK << SHIFT);
x |= (uint64)BIAS << SHIFT;
return float64frombits(x);
return runtime·float64frombits(x);
}
float64
ldexp(float64 d, int32 e)
runtime·ldexp(float64 d, int32 e)
{
uint64 x;
if(d == 0)
return 0;
x = float64tobits(d);
x = runtime·float64tobits(d);
e += (int32)(x >> SHIFT) & MASK;
if(e <= 0)
return 0; /* underflow */
if(e >= MASK){ /* overflow */
if(d < 0)
return Inf(-1);
return Inf(1);
return runtime·Inf(-1);
return runtime·Inf(1);
}
x &= ~((uint64)MASK << SHIFT);
x |= (uint64)e << SHIFT;
return float64frombits(x);
return runtime·float64frombits(x);
}
float64
modf(float64 d, float64 *ip)
runtime·modf(float64 d, float64 *ip)
{
float64 dd;
uint64 x;
......@@ -150,7 +150,7 @@ modf(float64 d, float64 *ip)
if(d < 1) {
if(d < 0) {
d = modf(-d, ip);
d = runtime·modf(-d, ip);
*ip = -*ip;
return -d;
}
......@@ -158,7 +158,7 @@ modf(float64 d, float64 *ip)
return d;
}
x = float64tobits(d);
x = runtime·float64tobits(d);
e = (int32)((x >> SHIFT) & MASK) - BIAS;
/*
......@@ -166,7 +166,7 @@ modf(float64 d, float64 *ip)
*/
if(e <= 64-11)
x &= ~(((uint64)1 << (64LL-11LL-e))-1);
dd = float64frombits(x);
dd = runtime·float64frombits(x);
*ip = dd;
return d - dd;
}
......
......@@ -7,7 +7,7 @@
#include "signals.h"
#include "os.h"
extern void sigtramp(void);
extern void runtime·sigtramp(void);
typedef struct sigaction {
union {
......@@ -19,33 +19,33 @@ typedef struct sigaction {
} Sigaction;
void
dumpregs(Mcontext *r)
runtime·dumpregs(Mcontext *r)
{
printf("eax %x\n", r->mc_eax);
printf("ebx %x\n", r->mc_ebx);
printf("ecx %x\n", r->mc_ecx);
printf("edx %x\n", r->mc_edx);
printf("edi %x\n", r->mc_edi);
printf("esi %x\n", r->mc_esi);
printf("ebp %x\n", r->mc_ebp);
printf("esp %x\n", r->mc_esp);
printf("eip %x\n", r->mc_eip);
printf("eflags %x\n", r->mc_eflags);
printf("cs %x\n", r->mc_cs);
printf("fs %x\n", r->mc_fs);
printf("gs %x\n", r->mc_gs);
runtime·printf("eax %x\n", r->mc_eax);
runtime·printf("ebx %x\n", r->mc_ebx);
runtime·printf("ecx %x\n", r->mc_ecx);
runtime·printf("edx %x\n", r->mc_edx);
runtime·printf("edi %x\n", r->mc_edi);
runtime·printf("esi %x\n", r->mc_esi);
runtime·printf("ebp %x\n", r->mc_ebp);
runtime·printf("esp %x\n", r->mc_esp);
runtime·printf("eip %x\n", r->mc_eip);
runtime·printf("eflags %x\n", r->mc_eflags);
runtime·printf("cs %x\n", r->mc_cs);
runtime·printf("fs %x\n", r->mc_fs);
runtime·printf("gs %x\n", r->mc_gs);
}
String
signame(int32 sig)
runtime·signame(int32 sig)
{
if(sig < 0 || sig >= NSIG)
return emptystring;
return gostringnocopy((byte*)sigtab[sig].name);
return runtime·emptystring;
return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name);
}
void
sighandler(int32 sig, Siginfo* info, void* context)
runtime·sighandler(int32 sig, Siginfo* info, void* context)
{
Ucontext *uc;
Mcontext *r;
......@@ -55,7 +55,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
uc = context;
r = &uc->uc_mcontext;
if((gp = m->curg) != nil && (sigtab[sig].flags & SigPanic)) {
if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
// Make it look like a call to the signal func.
// Have to pass arguments out of band since
// augmenting the stack frame would break
......@@ -64,91 +64,91 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->mc_eip != 0.
// Only push runtime·sigpanic if r->mc_eip != 0.
// If r->mc_eip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// make the trace look like a call to runtime·sigpanic instead.
// (Otherwise the trace will end at runtime·sigpanic and we
// won't get to see who faulted.)
if(r->mc_eip != 0) {
sp = (uintptr*)r->mc_esp;
*--sp = r->mc_eip;
r->mc_esp = (uintptr)sp;
}
r->mc_eip = (uintptr)sigpanic;
r->mc_eip = (uintptr)runtime·sigpanic;
return;
}
if(sigtab[sig].flags & SigQueue) {
if(sigsend(sig) || (sigtab[sig].flags & SigIgnore))
if(runtime·sigtab[sig].flags & SigQueue) {
if(runtime·sigsend(sig) || (runtime·sigtab[sig].flags & SigIgnore))
return;
exit(2); // SIGINT, SIGTERM, etc
runtime·exit(2); // SIGINT, SIGTERM, etc
}
if(panicking) // traceback already printed
exit(2);
panicking = 1;
if(runtime·panicking) // traceback already printed
runtime·exit(2);
runtime·panicking = 1;
if(sig < 0 || sig >= NSIG)
printf("Signal %d\n", sig);
runtime·printf("Signal %d\n", sig);
else
printf("%s\n", sigtab[sig].name);
runtime·printf("%s\n", runtime·sigtab[sig].name);
printf("PC=%X\n", r->mc_eip);
printf("\n");
runtime·printf("PC=%X\n", r->mc_eip);
runtime·printf("\n");
if(gotraceback()){
traceback((void*)r->mc_eip, (void*)r->mc_esp, 0, m->curg);
tracebackothers(m->curg);
dumpregs(r);
if(runtime·gotraceback()){
runtime·traceback((void*)r->mc_eip, (void*)r->mc_esp, 0, m->curg);
runtime·tracebackothers(m->curg);
runtime·dumpregs(r);
}
breakpoint();
exit(2);
runtime·breakpoint();
runtime·exit(2);
}
void
sigignore(void)
runtime·sigignore(void)
{
}
void
signalstack(byte *p, int32 n)
runtime·signalstack(byte *p, int32 n)
{
Sigaltstack st;
st.ss_sp = (int8*)p;
st.ss_size = n;
st.ss_flags = 0;
sigaltstack(&st, nil);
runtime·sigaltstack(&st, nil);
}
void
initsig(int32 queue)
runtime·initsig(int32 queue)
{
static Sigaction sa;
siginit();
runtime·siginit();
int32 i;
sa.sa_flags |= SA_ONSTACK | SA_SIGINFO;
sa.sa_mask = ~0x0ull;
for(i = 0; i < NSIG; i++) {
if(sigtab[i].flags) {
if((sigtab[i].flags & SigQueue) != queue)
if(runtime·sigtab[i].flags) {
if((runtime·sigtab[i].flags & SigQueue) != queue)
continue;
if(sigtab[i].flags & (SigCatch | SigQueue))
sa.__sigaction_u.__sa_sigaction = (void*) sigtramp;
if(runtime·sigtab[i].flags & (SigCatch | SigQueue))
sa.__sigaction_u.__sa_sigaction = (void*) runtime·sigtramp;
else
sa.__sigaction_u.__sa_sigaction = (void*) sigignore;
sa.__sigaction_u.__sa_sigaction = (void*) runtime·sigignore;
if(sigtab[i].flags & SigRestart)
if(runtime·sigtab[i].flags & SigRestart)
sa.sa_flags |= SA_RESTART;
else
sa.sa_flags &= ~SA_RESTART;
sigaction(i, &sa, nil);
runtime·sigaction(i, &sa, nil);
}
}
}
......@@ -8,17 +8,17 @@
#include "386/asm.h"
TEXT sys_umtx_op(SB),7,$-4
TEXT runtime·sys_umtx_op(SB),7,$-4
MOVL $454, AX
INT $0x80
RET
TEXT thr_new(SB),7,$-4
TEXT runtime·thr_new(SB),7,$-4
MOVL $455, AX
INT $0x80
RET
TEXT thr_start(SB),7,$0
TEXT runtime·thr_start(SB),7,$0
MOVL mm+0(FP), AX
MOVL m_g0(AX), BX
LEAL m_tls(AX), BP
......@@ -28,7 +28,7 @@ TEXT thr_start(SB),7,$0
PUSHL $32
PUSHL BP
PUSHL DI
CALL setldt(SB)
CALL runtime·setldt(SB)
POPL AX
POPL AX
POPL AX
......@@ -37,36 +37,36 @@ TEXT thr_start(SB),7,$0
MOVL BX, g(CX)
MOVL AX, m(CX)
CALL stackcheck(SB) // smashes AX
CALL mstart(SB)
CALL runtime·stackcheck(SB) // smashes AX
CALL runtime·mstart(SB)
MOVL 0, AX // crash (not reached)
// Exit the entire program (like C exit)
TEXT exit(SB),7,$-4
TEXT runtime·exit(SB),7,$-4
MOVL $1, AX
INT $0x80
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT exit1(SB),7,$-4
TEXT runtime·exit1(SB),7,$-4
MOVL $431, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT write(SB),7,$-4
TEXT runtime·write(SB),7,$-4
MOVL $4, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT notok(SB),7,$0
TEXT runtime·notok(SB),7,$0
MOVL $0xf1, 0xf1
RET
TEXT ·mmap(SB),7,$32
TEXT runtime·mmap(SB),7,$32
LEAL arg0+0(FP), SI
LEAL 4(SP), DI
CLD
......@@ -82,14 +82,14 @@ TEXT ·mmap(SB),7,$32
INT $0x80
RET
TEXT ·munmap(SB),7,$-4
TEXT runtime·munmap(SB),7,$-4
MOVL $73, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT gettime(SB), 7, $32
TEXT runtime·gettime(SB), 7, $32
MOVL $116, AX
LEAL 12(SP), BX
MOVL BX, 4(SP)
......@@ -106,14 +106,14 @@ TEXT gettime(SB), 7, $32
MOVL BX, (DI)
RET
TEXT sigaction(SB),7,$-4
TEXT runtime·sigaction(SB),7,$-4
MOVL $416, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT sigtramp(SB),7,$40
TEXT runtime·sigtramp(SB),7,$40
// g = m->gsignal
get_tls(DX)
MOVL m(DX), BP
......@@ -127,7 +127,7 @@ TEXT sigtramp(SB),7,$40
MOVL AX, 0(SP)
MOVL BX, 4(SP)
MOVL CX, 8(SP)
CALL sighandler(SB)
CALL runtime·sighandler(SB)
// g = m->curg
get_tls(DX)
......@@ -141,14 +141,14 @@ TEXT sigtramp(SB),7,$40
MOVL AX, 4(SP)
MOVL $417, AX // sigreturn(ucontext)
INT $0x80
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT sigaltstack(SB),7,$0
TEXT runtime·sigaltstack(SB),7,$0
MOVL $53, AX
INT $0x80
JAE 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
/*
......@@ -168,7 +168,7 @@ int i386_set_ldt(int, const union ldt_entry *, int);
*/
// setldt(int entry, int address, int limit)
TEXT setldt(SB),7,$32
TEXT runtime·setldt(SB),7,$32
MOVL address+4(FP), BX // aka base
// see comment in linux/386/sys.s; freebsd is similar
ADDL $0x8, BX
......@@ -193,7 +193,7 @@ TEXT setldt(SB),7,$32
MOVL $0xffffffff, 0(SP) // auto-allocate entry and return in AX
MOVL AX, 4(SP)
MOVL $1, 8(SP)
CALL i386_set_ldt(SB)
CALL runtime·i386_set_ldt(SB)
// compute segment selector - (entry*8+7)
SHLL $3, AX
......@@ -201,7 +201,7 @@ TEXT setldt(SB),7,$32
MOVW AX, GS
RET
TEXT i386_set_ldt(SB),7,$16
TEXT runtime·i386_set_ldt(SB),7,$16
LEAL args+0(FP), AX // 0(FP) == 4(SP) before SP got moved
MOVL $0, 0(SP) // syscall gap
MOVL $1, 4(SP)
......@@ -213,4 +213,4 @@ TEXT i386_set_ldt(SB),7,$16
INT $3
RET
GLOBL tlsoffset(SB),$4
GLOBL runtime·tlsoffset(SB),$4
......@@ -7,7 +7,7 @@
#include "signals.h"
#include "os.h"
extern void sigtramp(void);
extern void runtime·sigtramp(void);
typedef struct sigaction {
union {
......@@ -19,41 +19,41 @@ typedef struct sigaction {
} Sigaction;
void
dumpregs(Mcontext *r)
runtime·dumpregs(Mcontext *r)
{
printf("rax %X\n", r->mc_rax);
printf("rbx %X\n", r->mc_rbx);
printf("rcx %X\n", r->mc_rcx);
printf("rdx %X\n", r->mc_rdx);
printf("rdi %X\n", r->mc_rdi);
printf("rsi %X\n", r->mc_rsi);
printf("rbp %X\n", r->mc_rbp);
printf("rsp %X\n", r->mc_rsp);
printf("r8 %X\n", r->mc_r8 );
printf("r9 %X\n", r->mc_r9 );
printf("r10 %X\n", r->mc_r10);
printf("r11 %X\n", r->mc_r11);
printf("r12 %X\n", r->mc_r12);
printf("r13 %X\n", r->mc_r13);
printf("r14 %X\n", r->mc_r14);
printf("r15 %X\n", r->mc_r15);
printf("rip %X\n", r->mc_rip);
printf("rflags %X\n", r->mc_flags);
printf("cs %X\n", r->mc_cs);
printf("fs %X\n", r->mc_fs);
printf("gs %X\n", r->mc_gs);
runtime·printf("rax %X\n", r->mc_rax);
runtime·printf("rbx %X\n", r->mc_rbx);
runtime·printf("rcx %X\n", r->mc_rcx);
runtime·printf("rdx %X\n", r->mc_rdx);
runtime·printf("rdi %X\n", r->mc_rdi);
runtime·printf("rsi %X\n", r->mc_rsi);
runtime·printf("rbp %X\n", r->mc_rbp);
runtime·printf("rsp %X\n", r->mc_rsp);
runtime·printf("r8 %X\n", r->mc_r8 );
runtime·printf("r9 %X\n", r->mc_r9 );
runtime·printf("r10 %X\n", r->mc_r10);
runtime·printf("r11 %X\n", r->mc_r11);
runtime·printf("r12 %X\n", r->mc_r12);
runtime·printf("r13 %X\n", r->mc_r13);
runtime·printf("r14 %X\n", r->mc_r14);
runtime·printf("r15 %X\n", r->mc_r15);
runtime·printf("rip %X\n", r->mc_rip);
runtime·printf("rflags %X\n", r->mc_flags);
runtime·printf("cs %X\n", r->mc_cs);
runtime·printf("fs %X\n", r->mc_fs);
runtime·printf("gs %X\n", r->mc_gs);
}
String
signame(int32 sig)
runtime·signame(int32 sig)
{
if(sig < 0 || sig >= NSIG)
return emptystring;
return gostringnocopy((byte*)sigtab[sig].name);
return runtime·emptystring;
return runtime·gostringnocopy((byte*)runtime·sigtab[sig].name);
}
void
sighandler(int32 sig, Siginfo* info, void* context)
runtime·sighandler(int32 sig, Siginfo* info, void* context)
{
Ucontext *uc;
Mcontext *r;
......@@ -63,7 +63,7 @@ sighandler(int32 sig, Siginfo* info, void* context)
uc = context;
r = &uc->uc_mcontext;
if((gp = m->curg) != nil && (sigtab[sig].flags & SigPanic)) {
if((gp = m->curg) != nil && (runtime·sigtab[sig].flags & SigPanic)) {
// Make it look like a call to the signal func.
// Have to pass arguments out of band since
// augmenting the stack frame would break
......@@ -72,91 +72,91 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
// Only push sigpanic if r->mc_rip != 0.
// Only push runtime·sigpanic if r->mc_rip != 0.
// If r->mc_rip == 0, probably panicked because of a
// call to a nil func. Not pushing that onto sp will
// make the trace look like a call to sigpanic instead.
// (Otherwise the trace will end at sigpanic and we
// make the trace look like a call to runtime·sigpanic instead.
// (Otherwise the trace will end at runtime·sigpanic and we
// won't get to see who faulted.)
if(r->mc_rip != 0) {
sp = (uintptr*)r->mc_rsp;
*--sp = r->mc_rip;
r->mc_rsp = (uintptr)sp;
}
r->mc_rip = (uintptr)sigpanic;
r->mc_rip = (uintptr)runtime·sigpanic;
return;
}
if(sigtab[sig].flags & SigQueue) {
if(sigsend(sig) || (sigtab[sig].flags & SigIgnore))
if(runtime·sigtab[sig].flags & SigQueue) {
if(runtime·sigsend(sig) || (runtime·sigtab[sig].flags & SigIgnore))
return;
exit(2); // SIGINT, SIGTERM, etc
runtime·exit(2); // SIGINT, SIGTERM, etc
}
if(panicking) // traceback already printed
exit(2);
panicking = 1;
if(runtime·panicking) // traceback already printed
runtime·exit(2);
runtime·panicking = 1;
if(sig < 0 || sig >= NSIG)
printf("Signal %d\n", sig);
runtime·printf("Signal %d\n", sig);
else
printf("%s\n", sigtab[sig].name);
runtime·printf("%s\n", runtime·sigtab[sig].name);
printf("PC=%X\n", r->mc_rip);
printf("\n");
runtime·printf("PC=%X\n", r->mc_rip);
runtime·printf("\n");
if(gotraceback()){
traceback((void*)r->mc_rip, (void*)r->mc_rsp, 0, g);
tracebackothers(g);
dumpregs(r);
if(runtime·gotraceback()){
runtime·traceback((void*)r->mc_rip, (void*)r->mc_rsp, 0, g);
runtime·tracebackothers(g);
runtime·dumpregs(r);
}
breakpoint();
exit(2);
runtime·breakpoint();
runtime·exit(2);
}
void
sigignore(void)
runtime·sigignore(void)
{
}
void
signalstack(byte *p, int32 n)
runtime·signalstack(byte *p, int32 n)
{
Sigaltstack st;
st.ss_sp = (int8*)p;
st.ss_size = n;
st.ss_flags = 0;
sigaltstack(&st, nil);
runtime·sigaltstack(&st, nil);
}
void
initsig(int32 queue)
runtime·initsig(int32 queue)
{
static Sigaction sa;
siginit();
runtime·siginit();
int32 i;
sa.sa_flags |= SA_ONSTACK | SA_SIGINFO;
sa.sa_mask = ~0x0ull;
for(i = 0; i < NSIG; i++) {
if(sigtab[i].flags) {
if((sigtab[i].flags & SigQueue) != queue)
if(runtime·sigtab[i].flags) {
if((runtime·sigtab[i].flags & SigQueue) != queue)
continue;
if(sigtab[i].flags & (SigCatch | SigQueue))
sa.__sigaction_u.__sa_sigaction = (void*) sigtramp;
if(runtime·sigtab[i].flags & (SigCatch | SigQueue))
sa.__sigaction_u.__sa_sigaction = (void*) runtime·sigtramp;
else
sa.__sigaction_u.__sa_sigaction = (void*) sigignore;
sa.__sigaction_u.__sa_sigaction = (void*) runtime·sigignore;
if(sigtab[i].flags & SigRestart)
if(runtime·sigtab[i].flags & SigRestart)
sa.sa_flags |= SA_RESTART;
else
sa.sa_flags &= ~SA_RESTART;
sigaction(i, &sa, nil);
runtime·sigaction(i, &sa, nil);
}
}
}
......@@ -8,7 +8,7 @@
#include "amd64/asm.h"
TEXT sys_umtx_op(SB),7,$0
TEXT runtime·sys_umtx_op(SB),7,$0
MOVQ 8(SP), DI
MOVL 16(SP), SI
MOVL 20(SP), DX
......@@ -18,19 +18,19 @@ TEXT sys_umtx_op(SB),7,$0
SYSCALL
RET
TEXT thr_new(SB),7,$0
TEXT runtime·thr_new(SB),7,$0
MOVQ 8(SP), DI
MOVQ 16(SP), SI
MOVL $455, AX
SYSCALL
RET
TEXT thr_start(SB),7,$0
TEXT runtime·thr_start(SB),7,$0
MOVQ DI, R13 // m
// set up FS to point at m->tls
LEAQ m_tls(R13), DI
CALL settls(SB) // smashes DI
CALL runtime·settls(SB) // smashes DI
// set up m, g
get_tls(CX)
......@@ -38,36 +38,36 @@ TEXT thr_start(SB),7,$0
MOVQ m_g0(R13), DI
MOVQ DI, g(CX)
CALL stackcheck(SB)
CALL mstart(SB)
CALL runtime·stackcheck(SB)
CALL runtime·mstart(SB)
MOVQ 0, AX // crash (not reached)
// Exit the entire program (like C exit)
TEXT exit(SB),7,$-8
TEXT runtime·exit(SB),7,$-8
MOVL 8(SP), DI // arg 1 exit status
MOVL $1, AX
SYSCALL
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT exit1(SB),7,$-8
TEXT runtime·exit1(SB),7,$-8
MOVQ 8(SP), DI // arg 1 exit status
MOVL $431, AX
SYSCALL
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT write(SB),7,$-8
TEXT runtime·write(SB),7,$-8
MOVL 8(SP), DI // arg 1 fd
MOVQ 16(SP), SI // arg 2 buf
MOVL 24(SP), DX // arg 3 count
MOVL $4, AX
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT gettime(SB), 7, $32
TEXT runtime·gettime(SB), 7, $32
MOVL $116, AX
LEAQ 8(SP), DI
MOVQ $0, SI
......@@ -82,17 +82,17 @@ TEXT gettime(SB), 7, $32
MOVL BX, (DI)
RET
TEXT sigaction(SB),7,$-8
TEXT runtime·sigaction(SB),7,$-8
MOVL 8(SP), DI // arg 1 sig
MOVQ 16(SP), SI // arg 2 act
MOVQ 24(SP), DX // arg 3 oact
MOVL $416, AX
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT sigtramp(SB),7,$24-16
TEXT runtime·sigtramp(SB),7,$24-16
get_tls(CX)
MOVQ m(CX), AX
MOVQ m_gsignal(AX), AX
......@@ -100,10 +100,10 @@ TEXT sigtramp(SB),7,$24-16
MOVQ DI, 0(SP)
MOVQ SI, 8(SP)
MOVQ DX, 16(SP)
CALL sighandler(SB)
CALL runtime·sighandler(SB)
RET
TEXT ·mmap(SB),7,$0
TEXT runtime·mmap(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len
MOVL 24(SP), DX // arg 3 prot
......@@ -114,31 +114,31 @@ TEXT ·mmap(SB),7,$0
SYSCALL
RET
TEXT ·munmap(SB),7,$0
TEXT runtime·munmap(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), SI // arg 2 len
MOVL $73, AX
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
TEXT notok(SB),7,$-8
TEXT runtime·notok(SB),7,$-8
MOVL $0xf1, BP
MOVQ BP, (BP)
RET
TEXT sigaltstack(SB),7,$-8
TEXT runtime·sigaltstack(SB),7,$-8
MOVQ new+8(SP), DI
MOVQ old+16(SP), SI
MOVQ $53, AX
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
// set tls base to DI
TEXT settls(SB),7,$8
TEXT runtime·settls(SB),7,$8
ADDQ $16, DI // adjust for ELF: wants to use -16(FS) and -8(FS) for g and m
MOVQ DI, 0(SP)
MOVQ SP, SI
......@@ -146,5 +146,5 @@ TEXT settls(SB),7,$8
MOVQ $165, AX // sysarch
SYSCALL
JCC 2(PC)
CALL notok(SB)
CALL runtime·notok(SB)
RET
......@@ -4,21 +4,21 @@
#include "malloc.h"
void*
SysAlloc(uintptr n)
runtime·SysAlloc(uintptr n)
{
void *v;
mstats.sys += n;
v = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
v = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
if(v < (void*)4096) {
printf("mmap: errno=%p\n", v);
throw("mmap");
runtime·printf("mmap: errno=%p\n", v);
runtime·throw("mmap");
}
return v;
}
void
SysUnused(void *v, uintptr n)
runtime·SysUnused(void *v, uintptr n)
{
USED(v);
USED(n);
......@@ -26,15 +26,15 @@ SysUnused(void *v, uintptr n)
}
void
SysFree(void *v, uintptr n)
runtime·SysFree(void *v, uintptr n)
{
mstats.sys -= n;
runtime_munmap(v, n);
runtime·munmap(v, n);
}
void
SysMemInit(void)
runtime·SysMemInit(void)
{
// Code generators assume that references to addresses
// on the first page will fault. Map the page explicitly with
......@@ -42,5 +42,5 @@ SysMemInit(void)
// allocating that page as the virtual address space fills.
// Ignore any error, since other systems might be smart
// enough to never allow anything there.
runtime_mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
runtime·mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
}
int32 thr_new(ThrParam*, int32);
void sigpanic(void);
void sigaltstack(Sigaltstack*, Sigaltstack*);
int32 runtime·thr_new(ThrParam*, int32);
void runtime·sigpanic(void);
void runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
struct sigaction;
void sigaction(int32, struct sigaction*, struct sigaction*);
void runtime·sigaction(int32, struct sigaction*, struct sigaction*);
......@@ -8,7 +8,7 @@
#define Q SigQueue
#define P SigPanic
SigTab sigtab[] = {
SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap",
/* 1 */ Q+R, "SIGHUP: terminal line hangup",
/* 2 */ Q+R, "SIGINT: interrupt",
......
This diff is collapsed.
This diff is collapsed.
......@@ -63,11 +63,13 @@
}
*/
#define malloc mal
#define malloc runtime·mal
#define offsetof(s,m) (uint32)(&(((s*)0)->m))
#define memset(a,b,c) ·memclr((byte*)(a), (uint32)(c))
#define memcpy(a,b,c) mcpy((byte*)(a),(byte*)(b),(uint32)(c))
#define assert(a) if(!(a)) throw("assert")
#define memset(a,b,c) runtime·memclr((byte*)(a), (uint32)(c))
#define memcpy(a,b,c) runtime·mcpy((byte*)(a),(byte*)(b),(uint32)(c))
#define assert(a) if(!(a)) runtime·throw("assert")
#define free(x) runtime·free(x)
#define memmove(a,b,c) runtime·memmove(a, b, c)
struct hash; /* opaque */
struct hash_subtable; /* opaque */
......@@ -114,12 +116,12 @@ struct hash_iter {
/* Lookup *data in *h. If the data is found, return 1 and place a pointer to
the found element in *pres. Otherwise return 0 and place 0 in *pres. */
int32 hash_lookup (struct hash *h, void *data, void **pres);
// int32 hash_lookup (struct hash *h, void *data, void **pres);
/* Lookup *data in *h. If the data is found, execute (*data_del) (arg, p)
where p points to the data in the table, then remove it from *h and return
1. Otherwise return 0. */
int32 hash_remove (struct hash *h, void *data, void *arg);
// int32 hash_remove (struct hash *h, void *data, void *arg);
/* Lookup *data in *h. If the data is found, return 1, and place a pointer
to the found element in *pres. Otherwise, return 0, allocate a region
......@@ -129,10 +131,10 @@ int32 hash_remove (struct hash *h, void *data, void *arg);
If using garbage collection, it is the caller's responsibility to
add references for **pres if HASH_ADDED is returned. */
int32 hash_insert (struct hash *h, void *data, void **pres);
// int32 hash_insert (struct hash *h, void *data, void **pres);
/* Return the number of elements in the table. */
uint32 hash_count (struct hash *h);
// uint32 hash_count (struct hash *h);
/* The following call is useful only if not using garbage collection on the
table.
......@@ -141,18 +143,18 @@ uint32 hash_count (struct hash *h);
If other memory pointed to by user data must be freed, the caller is
responsible for doiing do by iterating over *h first; see
hash_iter_init()/hash_next(). */
void hash_destroy (struct hash *h);
// void hash_destroy (struct hash *h);
/*----- iteration -----*/
/* Initialize *it from *h. */
void hash_iter_init (struct hash *h, struct hash_iter *it);
// void hash_iter_init (struct hash *h, struct hash_iter *it);
/* Return the next used entry in the table which which *it was initialized. */
void *hash_next (struct hash_iter *it);
// void *hash_next (struct hash_iter *it);
/*---- test interface ----*/
/* Call (*data_visit) (arg, level, data) for every data entry in the table,
whether used or not. "level" is the subtable level, 0 means first level. */
/* TESTING ONLY: DO NOT USE THIS ROUTINE IN NORMAL CODE */
void hash_visit (struct hash *h, void (*data_visit) (void *arg, int32 level, void *data), void *arg);
// void hash_visit (struct hash *h, void (*data_visit) (void *arg, int32 level, void *data), void *arg);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -4,26 +4,26 @@
#include "malloc.h"
void*
SysAlloc(uintptr n)
runtime·SysAlloc(uintptr n)
{
void *p;
mstats.sys += n;
p = runtime_mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
p = runtime·mmap(nil, n, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANON|MAP_PRIVATE, -1, 0);
if(p < (void*)4096) {
if(p == (void*)EACCES) {
printf("mmap: access denied\n");
printf("If you're running SELinux, enable execmem for this process.\n");
exit(2);
runtime·printf("mmap: access denied\n");
runtime·printf("If you're running SELinux, enable execmem for this process.\n");
runtime·exit(2);
}
printf("mmap: errno=%p\n", p);
throw("mmap");
runtime·printf("mmap: errno=%p\n", p);
runtime·throw("mmap");
}
return p;
}
void
SysUnused(void *v, uintptr n)
runtime·SysUnused(void *v, uintptr n)
{
USED(v);
USED(n);
......@@ -31,14 +31,14 @@ SysUnused(void *v, uintptr n)
}
void
SysFree(void *v, uintptr n)
runtime·SysFree(void *v, uintptr n)
{
mstats.sys -= n;
runtime_munmap(v, n);
runtime·munmap(v, n);
}
void
SysMemInit(void)
runtime·SysMemInit(void)
{
// Code generators assume that references to addresses
// on the first page will fault. Map the page explicitly with
......@@ -46,5 +46,5 @@ SysMemInit(void)
// allocating that page as the virtual address space fills.
// Ignore any error, since other systems might be smart
// enough to never allow anything there.
runtime_mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
runtime·mmap(nil, 4096, PROT_NONE, MAP_FIXED|MAP_ANON|MAP_PRIVATE, -1, 0);
}
......@@ -3,11 +3,11 @@
// license that can be found in the LICENSE file.
// Linux-specific system calls
int32 futex(uint32*, int32, uint32, Timespec*, uint32*, uint32);
int32 clone(int32, void*, M*, G*, void(*)(void));
int32 runtime·futex(uint32*, int32, uint32, Timespec*, uint32*, uint32);
int32 runtime·clone(int32, void*, M*, G*, void(*)(void));
struct Sigaction;
void rt_sigaction(uintptr, struct Sigaction*, void*, uintptr);
void runtime·rt_sigaction(uintptr, struct Sigaction*, void*, uintptr);
void sigaltstack(Sigaltstack*, Sigaltstack*);
void sigpanic(void);
void runtime·sigaltstack(Sigaltstack*, Sigaltstack*);
void runtime·sigpanic(void);
......@@ -8,7 +8,7 @@
#define Q SigQueue
#define P SigPanic
SigTab sigtab[] = {
SigTab runtime·sigtab[] = {
/* 0 */ 0, "SIGNONE: no trap",
/* 1 */ Q+R, "SIGHUP: terminal line hangup",
/* 2 */ Q+R, "SIGINT: interrupt",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
#include "os.h"
void
initsig(int32 queue)
runtime·initsig(int32 queue)
{
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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