aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/syscall
diff options
context:
space:
mode:
authorDan Kegel <[email protected]>2021-12-11 11:53:02 -0800
committerRon Evans <[email protected]>2021-12-13 23:05:17 +0100
commit51fc78c100ea055bdd2eccf0527472c2f9b33ed0 (patch)
treecdfe9e0f6f68aa0554f1f0b8182de7ef6c4c3542 /src/syscall
parente4f2b9c0037a757ccb03fe2c8563e33a55e9901e (diff)
downloadtinygo-51fc78c100ea055bdd2eccf0527472c2f9b33ed0.tar.gz
tinygo-51fc78c100ea055bdd2eccf0527472c2f9b33ed0.zip
os: implement and smoketest os.Clearenv
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/syscall_libc.go11
-rw-r--r--src/syscall/syscall_nonhosted.go5
2 files changed, 16 insertions, 0 deletions
diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go
index 05df16fd7..25c778650 100644
--- a/src/syscall/syscall_libc.go
+++ b/src/syscall/syscall_libc.go
@@ -151,6 +151,17 @@ func Unsetenv(key string) (err error) {
return
}
+func Clearenv() {
+ for _, s := range Environ() {
+ for j := 0; j < len(s); j++ {
+ if s[j] == '=' {
+ Unsetenv(s[0:j])
+ break
+ }
+ }
+ }
+}
+
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
addr := libc_mmap(nil, uintptr(length), int32(prot), int32(flags), int32(fd), uintptr(offset))
if addr == unsafe.Pointer(^uintptr(0)) {
diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go
index 9e5b70fdc..be1b32c7b 100644
--- a/src/syscall/syscall_nonhosted.go
+++ b/src/syscall/syscall_nonhosted.go
@@ -77,6 +77,11 @@ func Unsetenv(key string) (err error) {
return ENOSYS
}
+func Clearenv() (err error) {
+ // stub for now
+ return ENOSYS
+}
+
func Environ() []string {
env := runtime_envs()
envCopy := make([]string, len(env))