From 1fb6828e5bff043c4052f75fd5f8290386b08acd Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Thu, 13 Apr 2023 23:53:53 +0200 Subject: [PATCH] unix: convert Iovec.Base to *byte in mkpost.go on solaris Instead of defining a dedicated type goIovec with the correct *byte type for its Base field like CL 412496 did, modify the Base field of the original type Iovec (generated from struct iovec) in mkpost.go. This is akin to how we already change []int8 to []byte for several other types. Fixes golang/go#55997 Change-Id: If30799bb2bfe6d17678370b45348ff0b7c5de2e9 Reviewed-on: https://go-review.googlesource.com/c/sys/+/484635 Run-TryBot: Tobias Klauser Auto-Submit: Tobias Klauser Reviewed-by: David Chase TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- unix/mkpost.go | 11 +++++++++++ unix/types_solaris.go | 8 +------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/unix/mkpost.go b/unix/mkpost.go index 5624847c6..3d19d3fa7 100644 --- a/unix/mkpost.go +++ b/unix/mkpost.go @@ -101,6 +101,17 @@ func main() { }) } + if goos == "solaris" { + // Convert *int8 to *byte in Iovec.Base like on every other platform. + convertIovecBase := regexp.MustCompile(`Base\s+\*int8`) + iovecType := regexp.MustCompile(`type Iovec struct {[^}]*}`) + iovecStructs := iovecType.FindAll(b, -1) + for _, s := range iovecStructs { + newNames := convertIovecBase.ReplaceAll(s, []byte("Base *byte")) + b = bytes.Replace(b, s, newNames, 1) + } + } + // Intentionally export __val fields in Fsid and Sigset_t valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__(bits|val)(\s+\S+\s+)}`) b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$4}")) diff --git a/unix/types_solaris.go b/unix/types_solaris.go index 98a4d8596..89e4c51e2 100644 --- a/unix/types_solaris.go +++ b/unix/types_solaris.go @@ -76,12 +76,6 @@ 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; -}; - // Solaris and the major illumos distributions ship a 3rd party tun/tap driver // from https://github.com/kaizawa/tuntap // It supports a pair of IOCTLs defined at @@ -164,7 +158,7 @@ type _Socklen C.socklen_t type Linger C.struct_linger -type Iovec C.struct_goIovec +type Iovec C.struct_iovec type IPMreq C.struct_ip_mreq