mirror of
https://github.com/golang/go
synced 2024-11-20 10:34:42 -07:00
syscall: prepare for 64-bit ints
This CL fixes code that incorrectly assumes that int is 32 bits wide. Specifically, the socketpair system call expects a pointer to a pair of int32s, not a pair of ints. Fix this inside the wrappers without changing the APIs. Update #2188. R=golang-dev, r CC=golang-dev https://golang.org/cl/6552063
This commit is contained in:
parent
9050550c12
commit
3d5ddffa30
@ -362,10 +362,15 @@ func Socket(domain, typ, proto int) (fd int, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int) (err error)
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
|
|
||||||
func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
|
func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
|
||||||
err = socketpair(domain, typ, proto, &fd)
|
var fdx [2]int32
|
||||||
|
err = socketpair(domain, typ, proto, &fdx)
|
||||||
|
if err == nil {
|
||||||
|
fd[0] = int(fdx[0])
|
||||||
|
fd[1] = int(fdx[1])
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,12 @@ func Socket(domain, typ, proto int) (fd int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
|
func Socketpair(domain, typ, proto int) (fd [2]int, err error) {
|
||||||
err = socketpair(domain, typ, proto, &fd)
|
var fdx [2]int32
|
||||||
|
err = socketpair(domain, typ, proto, &fdx)
|
||||||
|
if err == nil {
|
||||||
|
fd[0] = int(fdx[0])
|
||||||
|
fd[1] = int(fdx[1])
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func socketpair(domain int, typ int, flags int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
|
||||||
_, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, e := rawsocketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e != 0 {
|
if e != 0 {
|
||||||
err = e
|
err = e
|
||||||
|
@ -46,7 +46,7 @@ package syscall
|
|||||||
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error)
|
//sys getsockopt(s int, level int, name int, val uintptr, vallen *_Socklen) (err error)
|
||||||
//sys setsockopt(s int, level int, name int, val uintptr, vallen uintptr) (err error)
|
//sys setsockopt(s int, level int, name int, val uintptr, vallen uintptr) (err error)
|
||||||
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
//sysnb socket(domain int, typ int, proto int) (fd int, err error)
|
||||||
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int) (err error)
|
//sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
|
||||||
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
//sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
|
@ -37,7 +37,7 @@ func Seek(fd int, offset int64, whence int) (newoffset int64, err error)
|
|||||||
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
//sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
|
||||||
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
|
||||||
//sys sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (err error)
|
//sys sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (err error)
|
||||||
//sysnb socketpair(domain int, typ int, flags int, fd *[2]int) (err error)
|
//sysnb socketpair(domain int, typ int, flags int, fd *[2]int32) (err error)
|
||||||
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
//sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
|
||||||
//sys sendmsg(s int, msg *Msghdr, flags int) (err error)
|
//sys sendmsg(s int, msg *Msghdr, flags int) (err error)
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -1673,7 +1673,7 @@ func socket(domain int, typ int, proto int) (fd int, err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -1346,7 +1346,7 @@ func sendto(s int, buf []byte, flags int, to uintptr, addrlen _Socklen) (err err
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, flags int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
@ -131,7 +131,7 @@ func Shutdown(s int, how int) (err error) {
|
|||||||
|
|
||||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||||
|
|
||||||
func socketpair(domain int, typ int, proto int, fd *[2]int) (err error) {
|
func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
|
||||||
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
_, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
|
||||||
if e1 != 0 {
|
if e1 != 0 {
|
||||||
err = e1
|
err = e1
|
||||||
|
Loading…
Reference in New Issue
Block a user