mirror of
https://github.com/golang/sys.git
synced 2026-01-29 15:12:09 +03:00
unix: fix Signalfd function signature on linux
The kernel raw syscall takes an additional parameter specifying the size of the Sigset_t parameter, returns a file descriptor and sets errno. Add a uintptr maxSize parameter, adjust the return to be (newfd int, err error). Add the _NSIG #define and a wrapper to call with maxSize set to _C__NSIG/8 as done in glibc/musl. Change-Id: I277db0aab5c12364533c26ea800b7f394ec83ae4 Reviewed-on: https://go-review.googlesource.com/c/sys/+/178858 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Ian Lance Taylor
parent
9cd6430ef9
commit
adf421d2ca
@@ -804,6 +804,8 @@ const (
|
||||
|
||||
type Sigset_t C.sigset_t
|
||||
|
||||
const _C__NSIG = C._NSIG
|
||||
|
||||
type SignalfdSiginfo C.struct_signalfd_siginfo
|
||||
|
||||
const PERF_IOC_FLAG_GROUP = C.PERF_IOC_FLAG_GROUP
|
||||
|
||||
@@ -1537,9 +1537,13 @@ func Setgid(uid int) (err error) {
|
||||
return EOPNOTSUPP
|
||||
}
|
||||
|
||||
func Signalfd(fd int, sigmask *Sigset_t, flags int) (newfd int, err error) {
|
||||
return signalfd(fd, sigmask, _C__NSIG/8, flags)
|
||||
}
|
||||
|
||||
//sys Setpriority(which int, who int, prio int) (err error)
|
||||
//sys Setxattr(path string, attr string, data []byte, flags int) (err error)
|
||||
//sys Signalfd(fd int, mask *Sigset_t, flags int) = SYS_SIGNALFD4
|
||||
//sys signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) = SYS_SIGNALFD4
|
||||
//sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error)
|
||||
//sys Sync()
|
||||
//sys Syncfs(fd int) (err error)
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1381,8 +1381,12 @@ func Setxattr(path string, attr string, data []byte, flags int) (err error) {
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func Signalfd(fd int, mask *Sigset_t, flags int) {
|
||||
SyscallNoError(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(mask)), uintptr(flags))
|
||||
func signalfd(fd int, sigmask *Sigset_t, maskSize uintptr, flags int) (newfd int, err error) {
|
||||
r0, _, e1 := Syscall6(SYS_SIGNALFD4, uintptr(fd), uintptr(unsafe.Pointer(sigmask)), uintptr(maskSize), uintptr(flags), 0, 0)
|
||||
newfd = int(r0)
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -829,6 +829,8 @@ type Sigset_t struct {
|
||||
Val [32]uint32
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -842,6 +842,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -818,6 +818,8 @@ type Sigset_t struct {
|
||||
Val [32]uint32
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -821,6 +821,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -823,6 +823,8 @@ type Sigset_t struct {
|
||||
Val [32]uint32
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x80
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -823,6 +823,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x80
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -823,6 +823,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x80
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -823,6 +823,8 @@ type Sigset_t struct {
|
||||
Val [32]uint32
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x80
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -831,6 +831,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -831,6 +831,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -848,6 +848,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -844,6 +844,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
@@ -826,6 +826,8 @@ type Sigset_t struct {
|
||||
Val [16]uint64
|
||||
}
|
||||
|
||||
const _C__NSIG = 0x41
|
||||
|
||||
type SignalfdSiginfo struct {
|
||||
Signo uint32
|
||||
Errno int32
|
||||
|
||||
Reference in New Issue
Block a user