syscall: move uses of Syscall to libSystem on darwin

Miscellaneous additional conversions from raw syscalls
to using their libc equivalent.

Update #17490

Change-Id: If9ab22cc1d676c1f20fb161ebf02b0c28f71585d
Reviewed-on: https://go-review.googlesource.com/c/148257
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Keith Randall 2018-11-07 15:27:16 -08:00 committed by Keith Randall
parent 5d6e8f3142
commit c9762b8a7e
14 changed files with 378 additions and 75 deletions

View file

@ -248,7 +248,8 @@ func runtime_AfterExec()
// execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this
// avoids a build dependency for other platforms.
var execveLibc func(path uintptr, argv uintptr, envp uintptr) (err Errno)
var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno
var execveDarwin func(path *byte, argv **byte, envp **byte) error
// Exec invokes the execve(2) system call.
func Exec(argv0 string, argv []string, envv []string) (err error) {
@ -266,13 +267,16 @@ func Exec(argv0 string, argv []string, envv []string) (err error) {
}
runtime_BeforeExec()
var err1 Errno
var err1 error
if runtime.GOOS == "solaris" || runtime.GOOS == "aix" {
// RawSyscall should never be used on Solaris or AIX.
err1 = execveLibc(
uintptr(unsafe.Pointer(argv0p)),
uintptr(unsafe.Pointer(&argvp[0])),
uintptr(unsafe.Pointer(&envvp[0])))
} else if runtime.GOOS == "darwin" {
// Similarly on Darwin.
err1 = execveDarwin(argv0p, &argvp[0], &envvp[0])
} else {
_, _, err1 = RawSyscall(SYS_EXECVE,
uintptr(unsafe.Pointer(argv0p)),