aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/env_posix.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/env_posix.go')
-rw-r--r--src/runtime/env_posix.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/runtime/env_posix.go b/src/runtime/env_posix.go
index 6c04f6cc70..dd57872d7c 100644
--- a/src/runtime/env_posix.go
+++ b/src/runtime/env_posix.go
@@ -32,7 +32,8 @@ func gogetenv(key string) string {
return ""
}
-var _cgo_setenv uintptr // pointer to C function
+var _cgo_setenv uintptr // pointer to C function
+var _cgo_unsetenv uintptr // pointer to C function
// Update the C environment if cgo is loaded.
// Called from syscall.Setenv.
@@ -44,6 +45,16 @@ func syscall_setenv_c(k string, v string) {
asmcgocall(unsafe.Pointer(_cgo_setenv), unsafe.Pointer(&arg))
}
+// Update the C environment if cgo is loaded.
+// Called from syscall.unsetenv.
+func syscall_unsetenv_c(k string) {
+ if _cgo_unsetenv == 0 {
+ return
+ }
+ arg := [1]unsafe.Pointer{cstring(k)}
+ asmcgocall(unsafe.Pointer(_cgo_unsetenv), unsafe.Pointer(&arg))
+}
+
func cstring(s string) unsafe.Pointer {
p := make([]byte, len(s)+1)
sp := (*_string)(unsafe.Pointer(&s))