mirror of
https://github.com/golang/sys.git
synced 2026-02-08 03:36:03 +03:00
unix: change Solaris Iovec.Base to *byte
Every other Iovec.Base field is *byte, and that is the only reasonable value for Go. This is not backward compatible but we've made changes like this before. For golang/go#52885 Change-Id: I9a313a7931966a2483a322edd5c06c8cdca2557a Reviewed-on: https://go-review.googlesource.com/c/sys/+/412496 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Gopher Robot
parent
4f61da869c
commit
175b2fd9d6
@@ -20,10 +20,9 @@ func bytes2iovec(bs [][]byte) []Iovec {
|
||||
for i, b := range bs {
|
||||
iovecs[i].SetLen(len(b))
|
||||
if len(b) > 0 {
|
||||
// somehow Iovec.Base on illumos is (*int8), not (*byte)
|
||||
iovecs[i].Base = (*int8)(unsafe.Pointer(&b[0]))
|
||||
iovecs[i].Base = &b[0]
|
||||
} else {
|
||||
iovecs[i].Base = (*int8)(unsafe.Pointer(&_zero))
|
||||
iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero))
|
||||
}
|
||||
}
|
||||
return iovecs
|
||||
|
||||
@@ -457,10 +457,10 @@ func recvmsgRaw(fd int, p, oob []byte, flags int, rsa *RawSockaddrAny) (n, oobn
|
||||
msg.Namelen = uint32(SizeofSockaddrAny)
|
||||
var iov Iovec
|
||||
if len(p) > 0 {
|
||||
iov.Base = (*int8)(unsafe.Pointer(&p[0]))
|
||||
iov.Base = &p[0]
|
||||
iov.SetLen(len(p))
|
||||
}
|
||||
var dummy int8
|
||||
var dummy byte
|
||||
if len(oob) > 0 {
|
||||
// receive at least one normal byte
|
||||
if len(p) == 0 {
|
||||
@@ -486,10 +486,10 @@ func sendmsgN(fd int, p, oob []byte, ptr unsafe.Pointer, salen _Socklen, flags i
|
||||
msg.Namelen = uint32(salen)
|
||||
var iov Iovec
|
||||
if len(p) > 0 {
|
||||
iov.Base = (*int8)(unsafe.Pointer(&p[0]))
|
||||
iov.Base = &p[0]
|
||||
iov.SetLen(len(p))
|
||||
}
|
||||
var dummy int8
|
||||
var dummy byte
|
||||
if len(oob) > 0 {
|
||||
// send at least one normal byte
|
||||
if len(p) == 0 {
|
||||
|
||||
@@ -74,6 +74,12 @@ struct sockaddr_any {
|
||||
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
|
||||
};
|
||||
|
||||
// go_iovec is used to get *byte as the base address for Iovec.
|
||||
struct goIovec {
|
||||
void* iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
|
||||
*/
|
||||
import "C"
|
||||
|
||||
@@ -150,7 +156,7 @@ type _Socklen C.socklen_t
|
||||
|
||||
type Linger C.struct_linger
|
||||
|
||||
type Iovec C.struct_iovec
|
||||
type Iovec C.struct_goIovec
|
||||
|
||||
type IPMreq C.struct_ip_mreq
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ type Linger struct {
|
||||
}
|
||||
|
||||
type Iovec struct {
|
||||
Base *int8
|
||||
Base *byte
|
||||
Len uint64
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user