-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syscall: implement syscalls on Darwin using libSystem
There are still some references to the bare Syscall functions in the stdlib. I will root those out in a following CL. (This CL is big enough as it is.) Most are in vendor directories: cmd/vendor/golang.org/x/sys/unix/ vendor/golang_org/x/net/route/syscall.go syscall/bpf_bsd.go syscall/exec_unix.go syscall/flock.go Update #17490 Change-Id: I69ab707811530c26b652b291cadee92f5bf5c1a4 Reviewed-on: https://go-review.googlesource.com/c/141639 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
- Loading branch information
Showing
42 changed files
with
4,996 additions
and
689 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package poll | ||
|
||
import "syscall" | ||
|
||
// Fsync wraps syscall.Fsync. | ||
func (fd *FD) Fsync() error { | ||
if err := fd.incref(); err != nil { | ||
return err | ||
} | ||
defer fd.decref() | ||
return syscall.Fsync(fd.Sysfd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build darwin | ||
|
||
package poll | ||
|
||
import ( | ||
"syscall" | ||
_ "unsafe" // for go:linkname | ||
) | ||
|
||
// Implemented in syscall/syscall_darwin.go. | ||
//go:linkname writev syscall.writev | ||
func writev(fd int, iovecs []syscall.Iovec) (uintptr, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build dragonfly freebsd linux netbsd openbsd | ||
|
||
package poll | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
func writev(fd int, iovecs []syscall.Iovec) (uintptr, error) { | ||
r, _, e := syscall.Syscall(syscall.SYS_WRITEV, uintptr(fd), uintptr(unsafe.Pointer(&iovecs[0])), uintptr(len(iovecs))) | ||
if e != 0 { | ||
return r, syscall.Errno(e) | ||
} | ||
return r, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// This exists solely so we can linkname in symbols from syscall. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build darwin | ||
|
||
package unix | ||
|
||
import ( | ||
"syscall" | ||
_ "unsafe" // for go:linkname | ||
) | ||
|
||
func IsNonblock(fd int) (nonblocking bool, err error) { | ||
flag, e1 := fcntl(fd, syscall.F_GETFL, 0) | ||
if e1 != nil { | ||
return false, e1 | ||
} | ||
return flag&syscall.O_NONBLOCK != 0, nil | ||
} | ||
|
||
// Implemented in syscall/syscall_darwin.go. | ||
//go:linkname fcntl syscall.fcntl | ||
func fcntl(fd int, cmd int, arg int) (int, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2018 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// +build darwin | ||
// +build 386 arm | ||
|
||
package runtime | ||
|
||
import "unsafe" | ||
|
||
//go:linkname syscall_syscall9 syscall.syscall9 | ||
//go:nosplit | ||
//go:cgo_unsafe_args | ||
func syscall_syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2, err uintptr) { | ||
entersyscallblock() | ||
libcCall(unsafe.Pointer(funcPC(syscall9)), unsafe.Pointer(&fn)) | ||
exitsyscall() | ||
return | ||
} | ||
func syscall9() |
Oops, something went wrong.