diff options
| author | Brad Fitzpatrick <bradfitz@golang.org> | 2011-05-02 12:38:13 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2011-05-02 12:38:13 -0700 |
| commit | 623e7de1871c627ab976113dec4bccf5a807eb74 (patch) | |
| tree | a8794d53eed3b6e3136490d912caf8a15776f7dc /src/pkg/runtime/proc.c | |
| parent | f985638b94bb72c80e5e27c284d37eabe7d09aea (diff) | |
| download | go-623e7de1871c627ab976113dec4bccf5a807eb74.tar.xz | |
os: make Setenv update C environment variables
Fixes #1569
R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4456045
Diffstat (limited to 'src/pkg/runtime/proc.c')
| -rw-r--r-- | src/pkg/runtime/proc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pkg/runtime/proc.c b/src/pkg/runtime/proc.c index 52784854fd..61faa15594 100644 --- a/src/pkg/runtime/proc.c +++ b/src/pkg/runtime/proc.c @@ -1343,3 +1343,26 @@ runtime·setcpuprofilerate(void (*fn)(uintptr*, int32), int32 hz) if(hz != 0) runtime·resetcpuprofiler(hz); } + +void (*libcgo_setenv)(byte**); + +void +os·setenv_c(String k, String v) +{ + byte *arg[2]; + + if(libcgo_setenv == nil) + return; + + arg[0] = runtime·malloc(k.len + 1); + runtime·mcpy(arg[0], k.str, k.len); + arg[0][k.len] = 0; + + arg[1] = runtime·malloc(v.len + 1); + runtime·mcpy(arg[1], v.str, v.len); + arg[1][v.len] = 0; + + runtime·asmcgocall(libcgo_setenv, arg); + runtime·free(arg[0]); + runtime·free(arg[1]); +} |
