Skip to content

Commit 1fb6828

Browse files
tklausergopherbot
authored andcommitted
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 <[email protected]> Auto-Submit: Tobias Klauser <[email protected]> Reviewed-by: David Chase <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 3125361 commit 1fb6828

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

unix/mkpost.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ func main() {
101101
})
102102
}
103103

104+
if goos == "solaris" {
105+
// Convert *int8 to *byte in Iovec.Base like on every other platform.
106+
convertIovecBase := regexp.MustCompile(`Base\s+\*int8`)
107+
iovecType := regexp.MustCompile(`type Iovec struct {[^}]*}`)
108+
iovecStructs := iovecType.FindAll(b, -1)
109+
for _, s := range iovecStructs {
110+
newNames := convertIovecBase.ReplaceAll(s, []byte("Base *byte"))
111+
b = bytes.Replace(b, s, newNames, 1)
112+
}
113+
}
114+
104115
// Intentionally export __val fields in Fsid and Sigset_t
105116
valRegex := regexp.MustCompile(`type (Fsid|Sigset_t) struct {(\s+)X__(bits|val)(\s+\S+\s+)}`)
106117
b = valRegex.ReplaceAll(b, []byte("type $1 struct {${2}Val$4}"))

unix/types_solaris.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ struct sockaddr_any {
7676
char pad[sizeof(union sockaddr_all) - sizeof(struct sockaddr)];
7777
};
7878
79-
// go_iovec is used to get *byte as the base address for Iovec.
80-
struct goIovec {
81-
void* iov_base;
82-
size_t iov_len;
83-
};
84-
8579
// Solaris and the major illumos distributions ship a 3rd party tun/tap driver
8680
// from https://github.com/kaizawa/tuntap
8781
// It supports a pair of IOCTLs defined at
@@ -164,7 +158,7 @@ type _Socklen C.socklen_t
164158

165159
type Linger C.struct_linger
166160

167-
type Iovec C.struct_goIovec
161+
type Iovec C.struct_iovec
168162

169163
type IPMreq C.struct_ip_mreq
170164

0 commit comments

Comments
 (0)