runtime: implement command line arguments in hosted environments

Implement command line arguments for Linux, MacOS and WASI.
This commit is contained in:
Ayke van Laethem
2021-04-16 15:20:20 +02:00
committed by Ron Evans
parent c47cdfa66f
commit 7b761fac78
8 changed files with 102 additions and 18 deletions
+6 -1
View File
@@ -23,7 +23,9 @@ func GOROOT() string {
return "/usr/local/go"
}
// TODO: fill with real args.
// This is the default set of arguments, if nothing else has been set.
// This may be overriden by modifying this global at runtime init (for example,
// on Linux where there are real command line arguments).
var args = []string{"/proc/self/exe"}
//go:linkname os_runtime_args os.runtime_args
@@ -47,6 +49,9 @@ func memmove(dst, src unsafe.Pointer, size uintptr)
// llvm.memset.p0i8.i32(ptr, 0, size, false).
func memzero(ptr unsafe.Pointer, size uintptr)
//export strlen
func strlen(ptr unsafe.Pointer) uintptr
// Compare two same-size buffers for equality.
func memequal(x, y unsafe.Pointer, n uintptr) bool {
for i := uintptr(0); i < n; i++ {