mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
os: implement and smoketest os.Setenv
This commit is contained in:
@@ -132,6 +132,16 @@ func Getenv(key string) (value string, found bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func Setenv(key, val string) (err error) {
|
||||
keydata := cstring(key)
|
||||
valdata := cstring(val)
|
||||
errCode := libc_setenv(&keydata[0], &valdata[0], 1)
|
||||
if errCode != 0 {
|
||||
err = getErrno()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
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)) {
|
||||
@@ -192,6 +202,10 @@ func libc_write(fd int32, buf *byte, count uint) int
|
||||
//export getenv
|
||||
func libc_getenv(name *byte) *byte
|
||||
|
||||
// int setenv(const char *name, const char *val, int replace);
|
||||
//export setenv
|
||||
func libc_setenv(name *byte, val *byte, replace int32) int32
|
||||
|
||||
// ssize_t read(int fd, void *buf, size_t count);
|
||||
//export read
|
||||
func libc_read(fd int32, buf *byte, count uint) int
|
||||
|
||||
@@ -67,6 +67,11 @@ func Getenv(key string) (value string, found bool) {
|
||||
return "", false
|
||||
}
|
||||
|
||||
func Setenv(key, val string) (err error) {
|
||||
// stub for now
|
||||
return ENOSYS
|
||||
}
|
||||
|
||||
func Environ() []string {
|
||||
env := runtime_envs()
|
||||
envCopy := make([]string, len(env))
|
||||
|
||||
Reference in New Issue
Block a user