From: Alex Brainman Date: Wed, 12 Jan 2011 00:48:15 +0000 (+1100) Subject: runtime: revert 6974:1f3c3696babb X-Git-Tag: weekly.2011-01-12~16 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=a41d85498eed6b606d261e3da84c760538d71b4f;p=gostls13.git runtime: revert 6974:1f3c3696babb I missed that environment is used during runtime setup, well before go init() functions run. Implemented os-dependent runtime.goenvs functions to allow for different unix, plan9 and windows versions of environment discovery. R=rsc, paulzhol CC=golang-dev https://golang.org/cl/3787046 --- diff --git a/src/pkg/os/env_windows.go b/src/pkg/os/env_windows.go index ad50610ee6..d2b159dfba 100644 --- a/src/pkg/os/env_windows.go +++ b/src/pkg/os/env_windows.go @@ -114,7 +114,6 @@ func TempDir() string { func init() { var argc int32 - Envs = Environ() cmd := syscall.GetCommandLine() argv, e := syscall.CommandLineToArgv(cmd, &argc) if e != 0 { diff --git a/src/pkg/runtime/darwin/thread.c b/src/pkg/runtime/darwin/thread.c index 185f0ce963..d69c624128 100644 --- a/src/pkg/runtime/darwin/thread.c +++ b/src/pkg/runtime/darwin/thread.c @@ -148,6 +148,12 @@ runtime·osinit(void) runtime·bsdthread_register(); } +void +runtime·goenvs(void) +{ + runtime·goenvs_unix(); +} + void runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void)) { diff --git a/src/pkg/runtime/freebsd/thread.c b/src/pkg/runtime/freebsd/thread.c index fc80dfb77f..9bd8838335 100644 --- a/src/pkg/runtime/freebsd/thread.c +++ b/src/pkg/runtime/freebsd/thread.c @@ -163,6 +163,12 @@ runtime·osinit(void) { } +void +runtime·goenvs(void) +{ + runtime·goenvs_unix(); +} + // Called to initialize a new m (including the bootstrap m). void runtime·minit(void) diff --git a/src/pkg/runtime/linux/thread.c b/src/pkg/runtime/linux/thread.c index 9c9fc755b2..979260ba1d 100644 --- a/src/pkg/runtime/linux/thread.c +++ b/src/pkg/runtime/linux/thread.c @@ -263,6 +263,12 @@ runtime·osinit(void) { } +void +runtime·goenvs(void) +{ + runtime·goenvs_unix(); +} + // Called to initialize a new m (including the bootstrap m). void runtime·minit(void) diff --git a/src/pkg/runtime/plan9/thread.c b/src/pkg/runtime/plan9/thread.c index f1bd1ffbe2..fa96552a91 100644 --- a/src/pkg/runtime/plan9/thread.c +++ b/src/pkg/runtime/plan9/thread.c @@ -17,6 +17,11 @@ runtime·osinit(void) { } +void +runtime·goenvs(void) +{ +} + void runtime·initsig(int32 queue) { diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index d469e7c5b7..e9a19d9504 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -111,6 +111,7 @@ runtime·schedinit(void) runtime·mallocinit(); runtime·goargs(); + runtime·goenvs(); // For debugging: // Allocate internal symbol table representation now, diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index dbdc0f2ac6..9d3efe966d 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -152,34 +152,36 @@ int32 runtime·isplan9; void runtime·goargs(void) { - String *gargv; - String *genvv; - int32 i, envc; + String *s; + int32 i; // for windows implementation see "os" package if(Windows) return; - if(runtime·isplan9) - envc=0; - else - for(envc=0; argv[argc+1+envc] != 0; envc++) - ; - - gargv = runtime·malloc(argc*sizeof gargv[0]); - genvv = runtime·malloc(envc*sizeof genvv[0]); - + s = runtime·malloc(argc*sizeof s[0]); for(i=0; i