From 68b4255a9644a838898bfc6567bae97585c2e871 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 4 Nov 2010 14:00:19 -0400 Subject: runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/pkg/runtime/runtime.c | 207 ++++++++++++++++++++++------------------------ 1 file changed, 101 insertions(+), 106 deletions(-) (limited to 'src/pkg/runtime/runtime.c') diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index 9b874cec8d..0b19e108ed 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -4,87 +4,90 @@ #include "runtime.h" -int32 panicking = 0; -int32 maxround = sizeof(uintptr); -int32 fd = 1; +enum { + maxround = sizeof(uintptr), +}; + +int32 runtime·panicking = 0; +int32 runtime·fd = 1; int32 -gotraceback(void) +runtime·gotraceback(void) { byte *p; - p = getenv("GOTRACEBACK"); + p = runtime·getenv("GOTRACEBACK"); if(p == nil || p[0] == '\0') return 1; // default is on - return atoi(p); + return runtime·atoi(p); } void -panic(int32 unused) +runtime·dopanic(int32 unused) { - fd = 2; - if(panicking) { - printf("double panic\n"); - exit(3); + runtime·fd = 2; + if(runtime·panicking) { + runtime·printf("double panic\n"); + runtime·exit(3); } - panicking++; + runtime·panicking++; - printf("\npanic PC=%X\n", (uint64)(uintptr)&unused); - if(gotraceback()){ - traceback(·getcallerpc(&unused), getcallersp(&unused), 0, g); - tracebackothers(g); + runtime·printf("\npanic PC=%X\n", (uint64)(uintptr)&unused); + if(runtime·gotraceback()){ + runtime·traceback(runtime·getcallerpc(&unused), runtime·getcallersp(&unused), 0, g); + runtime·tracebackothers(g); } - breakpoint(); // so we can grab it in a debugger - exit(2); + runtime·breakpoint(); // so we can grab it in a debugger + runtime·exit(2); } void -·panicindex(void) +runtime·panicindex(void) { - panicstring("index out of range"); + runtime·panicstring("index out of range"); } void -·panicslice(void) +runtime·panicslice(void) { - panicstring("slice bounds out of range"); + runtime·panicstring("slice bounds out of range"); } void -·throwreturn(void) +runtime·throwreturn(void) { // can only happen if compiler is broken - throw("no return at end of a typed function - compiler is broken"); + runtime·throw("no return at end of a typed function - compiler is broken"); } void -·throwinit(void) +runtime·throwinit(void) { // can only happen with linker skew - throw("recursive call during initialization - linker skew"); + runtime·throw("recursive call during initialization - linker skew"); } void -throw(int8 *s) +runtime·throw(int8 *s) { - fd = 2; - printf("throw: %s\n", s); - panic(-1); + runtime·fd = 2; + runtime·printf("throw: %s\n", s); + runtime·dopanic(0); *(int32*)0 = 0; // not reached - exit(1); // even more not reached + runtime·exit(1); // even more not reached } void -panicstring(int8 *s) +runtime·panicstring(int8 *s) { Eface err; - ·newErrorString(gostringnocopy((byte*)s), &err); - ·panic(err); + runtime·newErrorString(runtime·gostringnocopy((byte*)s), &err); + runtime·panic(err); } void -mcpy(byte *t, byte *f, uint32 n) +runtime·mcpy(byte *t, byte *f, uint32 n) { while(n > 0) { *t = *f; @@ -95,7 +98,7 @@ mcpy(byte *t, byte *f, uint32 n) } int32 -mcmp(byte *s1, byte *s2, uint32 n) +runtime·mcmp(byte *s1, byte *s2, uint32 n) { uint32 i; byte c1, c2; @@ -113,7 +116,7 @@ mcmp(byte *s1, byte *s2, uint32 n) byte* -mchr(byte *p, byte c, byte *ep) +runtime·mchr(byte *p, byte c, byte *ep) { for(; p < ep; p++) if(*p == c) @@ -122,7 +125,7 @@ mchr(byte *p, byte c, byte *ep) } uint32 -rnd(uint32 n, uint32 m) +runtime·rnd(uint32 n, uint32 m) { uint32 r; @@ -141,38 +144,38 @@ Slice os·Args; Slice os·Envs; void -args(int32 c, uint8 **v) +runtime·args(int32 c, uint8 **v) { argc = c; argv = v; } -int32 isplan9; +int32 runtime·isplan9; void -goargs(void) +runtime·goargs(void) { String *gargv; String *genvv; int32 i, envc; - if(isplan9) + if(runtime·isplan9) envc=0; else for(envc=0; argv[argc+1+envc] != 0; envc++) ; - gargv = malloc(argc*sizeof gargv[0]); - genvv = malloc(envc*sizeof genvv[0]); + gargv = runtime·malloc(argc*sizeof gargv[0]); + genvv = runtime·malloc(envc*sizeof genvv[0]); for(i=0; isrc; - retline = funcline(f, retpc-1); + retline = runtime·funcline(f, retpc-1); retbool = true; } FLUSH(&retfile); @@ -525,15 +520,15 @@ void } void -·Callers(int32 skip, Slice pc, int32 retn) +runtime·Callers(int32 skip, Slice pc, int32 retn) { - retn = callers(skip, (uintptr*)pc.array, pc.len); + retn = runtime·callers(skip, (uintptr*)pc.array, pc.len); FLUSH(&retn); } void -·FuncForPC(uintptr pc, void *retf) +runtime·FuncForPC(uintptr pc, void *retf) { - retf = findfunc(pc); + retf = runtime·findfunc(pc); FLUSH(&retf); } -- cgit v1.3-5-g9baa