runtime·symtabinit();
runtime·stackinit();
runtime·mallocinit();
- runtime·gcinit();
runtime·chaninit();
mcommoninit(g->m);
// need to allocated memory.
runtime·newErrorCString(0, &i);
- // Initialize the cached gotraceback value, since
- // gotraceback calls getenv, which mallocs on Plan 9.
- runtime·gotraceback(nil);
-
runtime·goargs();
runtime·goenvs();
runtime·parsedebugvars();
+ runtime·gcinit();
runtime·sched.lastpoll = runtime·nanotime();
procs = 1;
// The cached value is a uint32 in which the low bit
// is the "crash" setting and the top 31 bits are the
// gotraceback value.
-static uint32 traceback_cache = ~(uint32)0;
+static uint32 traceback_cache = 2<<1;
// The GOTRACEBACK environment variable controls the
// behavior of a Go program that is crashing and exiting.
int32
runtime·gotraceback(bool *crash)
{
- byte *p;
- uint32 x;
-
if(crash != nil)
*crash = false;
if(g->m->traceback != 0)
return g->m->traceback;
- x = runtime·atomicload(&traceback_cache);
- if(x == ~(uint32)0) {
- p = runtime·getenv("GOTRACEBACK");
- if(p == nil)
- p = (byte*)"";
- if(p[0] == '\0')
- x = 1<<1;
- else if(runtime·strcmp(p, (byte*)"crash") == 0)
- x = (2<<1) | 1;
- else
- x = runtime·atoi(p)<<1;
- runtime·atomicstore(&traceback_cache, x);
- }
if(crash != nil)
- *crash = x&1;
- return x>>1;
+ *crash = traceback_cache&1;
+ return traceback_cache>>1;
}
int32
syscall·envs.array = (byte*)s;
syscall·envs.len = n;
syscall·envs.cap = n;
-
- traceback_cache = ~(uint32)0;
}
int32
break;
p++;
}
+
+ p = runtime·getenv("GOTRACEBACK");
+ if(p == nil)
+ p = (byte*)"";
+ if(p[0] == '\0')
+ traceback_cache = 1<<1;
+ else if(runtime·strcmp(p, (byte*)"crash") == 0)
+ traceback_cache = (2<<1) | 1;
+ else
+ traceback_cache = runtime·atoi(p)<<1;
}
// Poor mans 64-bit division.