WASI & darwin: support env variables based on libc

Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This commit is contained in:
Takeshi Yoneda
2021-02-17 23:50:53 +09:00
committed by Ron Evans
parent c299386906
commit 9841ac4acd
9 changed files with 115 additions and 12 deletions
+56
View File
@@ -0,0 +1,56 @@
package syscall
// This file defines errno and constants to match the darwin libsystem ABI.
// Values have been copied from src/syscall/zerrors_darwin_amd64.go.
// This function returns the error location in the darwin ABI.
// Discovered by compiling the following code using Clang:
//
// #include <errno.h>
// int getErrno() {
// return errno;
// }
//
//export __error
func libc___error() *int32
// getErrno returns the current C errno. It may not have been caused by the last
// call, so it should only be relied upon when the last call indicates an error
// (for example, by returning -1).
func getErrno() Errno {
errptr := libc___error()
return Errno(uintptr(*errptr))
}
const (
ENOENT Errno = 0x2
EEXIST Errno = 0x11
EINTR Errno = 0x4
EMFILE Errno = 0x18
EAGAIN Errno = 0x23
ETIMEDOUT Errno = 0x3c
ENOSYS Errno = 0x4e
EWOULDBLOCK Errno = EAGAIN
)
type Signal int
const (
SIGCHLD Signal = 0x14
SIGINT Signal = 0x2
SIGKILL Signal = 0x9
SIGTRAP Signal = 0x5
SIGQUIT Signal = 0x3
SIGTERM Signal = 0xf
)
const (
O_RDONLY = 0x0
O_WRONLY = 0x1
O_RDWR = 0x2
O_APPEND = 0x8
O_SYNC = 0x80
O_CREAT = 0x200
O_TRUNC = 0x400
O_EXCL = 0x800
)