-
Notifications
You must be signed in to change notification settings - Fork 17.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/poll, internal/syscall/unix, net, runtime: convert openbsd (…
…except mips64) to direct libc calls Call libc wrappers directly rather than calling using syscall(2). Updates #36435 Change-Id: I40be410c7472f7d89cbec2ebdc7c841c7726ca4a Reviewed-on: https://go-review.googlesource.com/c/go/+/425637 Reviewed-by: David Chase <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Joel Sing <[email protected]>
- Loading branch information
Showing
14 changed files
with
60 additions
and
26 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
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 |
---|---|---|
@@ -1,25 +1,17 @@ | ||
// Copyright 2016 The Go Authors. All rights reserved. | ||
// Copyright 2022 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 unix | ||
//go:build openbsd && !mips64 | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
package unix | ||
|
||
// getentropy(2)'s syscall number, from /usr/src/sys/kern/syscalls.master | ||
const entropyTrap uintptr = 7 | ||
import _ "unsafe" // for linkname | ||
|
||
// GetEntropy calls the OpenBSD getentropy system call. | ||
func GetEntropy(p []byte) error { | ||
_, _, errno := syscall.Syscall(entropyTrap, | ||
uintptr(unsafe.Pointer(&p[0])), | ||
uintptr(len(p)), | ||
0) | ||
if errno != 0 { | ||
return errno | ||
} | ||
return nil | ||
return getentropy(p) | ||
} | ||
|
||
//go:linkname getentropy syscall.getentropy | ||
func getentropy(p []byte) 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,25 @@ | ||
// Copyright 2016 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 unix | ||
|
||
import ( | ||
"syscall" | ||
"unsafe" | ||
) | ||
|
||
// getentropy(2)'s syscall number, from /usr/src/sys/kern/syscalls.master | ||
const entropyTrap uintptr = 7 | ||
|
||
// GetEntropy calls the OpenBSD getentropy system call. | ||
func GetEntropy(p []byte) error { | ||
_, _, errno := syscall.Syscall(entropyTrap, | ||
uintptr(unsafe.Pointer(&p[0])), | ||
uintptr(len(p)), | ||
0) | ||
if errno != 0 { | ||
return errno | ||
} | ||
return 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
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,15 @@ | ||
// Copyright 2022 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. | ||
|
||
//go:build openbsd && !mips64 | ||
|
||
package runtime | ||
|
||
func Fcntl(fd, cmd, arg uintptr) (uintptr, uintptr) { | ||
r := fcntl(int32(fd), int32(cmd), int32(arg)) | ||
if r < 0 { | ||
return ^uintptr(0), uintptr(-r) | ||
} | ||
return uintptr(r), 0 | ||
} |
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