From 2281fa97ef7b0c26324634d5a22f04babdac8713 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Fri, 13 Apr 2018 16:10:16 +0200 Subject: [PATCH] unix: don't export any padding/alignment fields on all platforms On linux/s390x these fields are already hidden. Don't export them on any other platform either. Preparatory CL for https://golang.org/cl/106656 Change-Id: I421a0ba41ff46081e2576be212e246a4dd982a67 Reviewed-on: https://go-review.googlesource.com/106838 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Matt Layher Reviewed-by: Ian Lance Taylor --- unix/mkpost.go | 9 ++--- unix/ztypes_linux_386.go | 60 ++++++++++++++++----------------- unix/ztypes_linux_amd64.go | 26 +++++++-------- unix/ztypes_linux_arm.go | 62 +++++++++++++++++------------------ unix/ztypes_linux_arm64.go | 28 ++++++++-------- unix/ztypes_linux_mips.go | 24 +++++++------- unix/ztypes_linux_mips64.go | 24 +++++++------- unix/ztypes_linux_mips64le.go | 24 +++++++------- unix/ztypes_linux_mipsle.go | 24 +++++++------- unix/ztypes_linux_ppc64.go | 34 +++++++++---------- unix/ztypes_linux_ppc64le.go | 34 +++++++++---------- 11 files changed, 173 insertions(+), 176 deletions(-) diff --git a/unix/mkpost.go b/unix/mkpost.go index 23590bda..7938fe7b 100644 --- a/unix/mkpost.go +++ b/unix/mkpost.go @@ -69,12 +69,9 @@ func main() { removePaddingFieldsRegex := regexp.MustCompile(`Pad_cgo_\d+`) b = removePaddingFieldsRegex.ReplaceAll(b, []byte("_")) - // We refuse to export private fields on s390x - if goarch == "s390x" && goos == "linux" { - // Remove padding, hidden, or unused fields - removeFieldsRegex = regexp.MustCompile(`\bX_\S+`) - b = removeFieldsRegex.ReplaceAll(b, []byte("_")) - } + // Remove padding, hidden, or unused fields + removeFieldsRegex = regexp.MustCompile(`\bX_\S+`) + b = removeFieldsRegex.ReplaceAll(b, []byte("_")) // Remove the first line of warning from cgo b = b[bytes.IndexByte(b, '\n')+1:] diff --git a/unix/ztypes_linux_386.go b/unix/ztypes_linux_386.go index 8a205748..113f48b7 100644 --- a/unix/ztypes_linux_386.go +++ b/unix/ztypes_linux_386.go @@ -96,24 +96,24 @@ type Rlimit struct { type _Gid_t uint32 type Stat_t struct { - Dev uint64 - X__pad1 uint16 - _ [2]byte - X__st_ino uint32 - Mode uint32 - Nlink uint32 - Uid uint32 - Gid uint32 - Rdev uint64 - X__pad2 uint16 - _ [2]byte - Size int64 - Blksize int32 - Blocks int64 - Atim Timespec - Mtim Timespec - Ctim Timespec - Ino uint64 + Dev uint64 + _ uint16 + _ [2]byte + _ uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + _ uint16 + _ [2]byte + Size int64 + Blksize int32 + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Ino uint64 } type Statfs_t struct { @@ -132,9 +132,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -171,7 +171,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -583,12 +583,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -683,7 +683,7 @@ type Sysinfo_t struct { Totalhigh uint32 Freehigh uint32 Unit uint32 - X_f [8]int8 + _ [8]int8 } type Utsname struct { @@ -739,7 +739,7 @@ const ( ) type Sigset_t struct { - X__val [32]uint32 + _ [32]uint32 } const RNDGETENTCNT = 0x80045200 diff --git a/unix/ztypes_linux_amd64.go b/unix/ztypes_linux_amd64.go index ccf81371..fa0ad6cb 100644 --- a/unix/ztypes_linux_amd64.go +++ b/unix/ztypes_linux_amd64.go @@ -105,7 +105,7 @@ type Stat_t struct { Mode uint32 Uid uint32 Gid uint32 - X__pad0 int32 + _ int32 Rdev uint64 Size int64 Blksize int64 @@ -132,9 +132,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -171,7 +171,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -587,12 +587,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -698,7 +698,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]int8 + _ [0]int8 _ [4]byte } @@ -757,7 +757,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x80045200 diff --git a/unix/ztypes_linux_arm.go b/unix/ztypes_linux_arm.go index d7b05e57..9b7b32e7 100644 --- a/unix/ztypes_linux_arm.go +++ b/unix/ztypes_linux_arm.go @@ -96,25 +96,25 @@ type Rlimit struct { type _Gid_t uint32 type Stat_t struct { - Dev uint64 - X__pad1 uint16 - _ [2]byte - X__st_ino uint32 - Mode uint32 - Nlink uint32 - Uid uint32 - Gid uint32 - Rdev uint64 - X__pad2 uint16 - _ [6]byte - Size int64 - Blksize int32 - _ [4]byte - Blocks int64 - Atim Timespec - Mtim Timespec - Ctim Timespec - Ino uint64 + Dev uint64 + _ uint16 + _ [2]byte + _ uint32 + Mode uint32 + Nlink uint32 + Uid uint32 + Gid uint32 + Rdev uint64 + _ uint16 + _ [6]byte + Size int64 + Blksize int32 + _ [4]byte + Blocks int64 + Atim Timespec + Mtim Timespec + Ctim Timespec + Ino uint64 } type Statfs_t struct { @@ -134,9 +134,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -173,7 +173,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -587,12 +587,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -671,7 +671,7 @@ type Sysinfo_t struct { Totalhigh uint32 Freehigh uint32 Unit uint32 - X_f [8]uint8 + _ [8]uint8 } type Utsname struct { @@ -728,7 +728,7 @@ const ( ) type Sigset_t struct { - X__val [32]uint32 + _ [32]uint32 } const RNDGETENTCNT = 0x80045200 diff --git a/unix/ztypes_linux_arm64.go b/unix/ztypes_linux_arm64.go index 27d8b405..52f8b3fa 100644 --- a/unix/ztypes_linux_arm64.go +++ b/unix/ztypes_linux_arm64.go @@ -106,10 +106,10 @@ type Stat_t struct { Uid uint32 Gid uint32 Rdev uint64 - X__pad1 uint64 + _ uint64 Size int64 Blksize int32 - X__pad2 int32 + _ int32 Blocks int64 Atim Timespec Mtim Timespec @@ -133,9 +133,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -172,7 +172,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -588,12 +588,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -676,7 +676,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]int8 + _ [0]int8 _ [4]byte } @@ -736,7 +736,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x80045200 diff --git a/unix/ztypes_linux_mips.go b/unix/ztypes_linux_mips.go index 7d451aa0..3af42dd3 100644 --- a/unix/ztypes_linux_mips.go +++ b/unix/ztypes_linux_mips.go @@ -133,9 +133,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -172,7 +172,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -586,12 +586,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -676,7 +676,7 @@ type Sysinfo_t struct { Totalhigh uint32 Freehigh uint32 Unit uint32 - X_f [8]int8 + _ [8]int8 } type Utsname struct { @@ -733,7 +733,7 @@ const ( ) type Sigset_t struct { - X__val [32]uint32 + _ [32]uint32 } const RNDGETENTCNT = 0x40045200 diff --git a/unix/ztypes_linux_mips64.go b/unix/ztypes_linux_mips64.go index cbe92308..6779a909 100644 --- a/unix/ztypes_linux_mips64.go +++ b/unix/ztypes_linux_mips64.go @@ -133,9 +133,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -172,7 +172,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -588,12 +588,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -679,7 +679,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]int8 + _ [0]int8 _ [4]byte } @@ -738,7 +738,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x40045200 diff --git a/unix/ztypes_linux_mips64le.go b/unix/ztypes_linux_mips64le.go index 990468f5..6c070ce0 100644 --- a/unix/ztypes_linux_mips64le.go +++ b/unix/ztypes_linux_mips64le.go @@ -133,9 +133,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -172,7 +172,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -588,12 +588,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -679,7 +679,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]int8 + _ [0]int8 _ [4]byte } @@ -738,7 +738,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x40045200 diff --git a/unix/ztypes_linux_mipsle.go b/unix/ztypes_linux_mipsle.go index 3433a8f6..57e35d13 100644 --- a/unix/ztypes_linux_mipsle.go +++ b/unix/ztypes_linux_mipsle.go @@ -133,9 +133,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -172,7 +172,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -586,12 +586,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -676,7 +676,7 @@ type Sysinfo_t struct { Totalhigh uint32 Freehigh uint32 Unit uint32 - X_f [8]int8 + _ [8]int8 } type Utsname struct { @@ -733,7 +733,7 @@ const ( ) type Sigset_t struct { - X__val [32]uint32 + _ [32]uint32 } const RNDGETENTCNT = 0x40045200 diff --git a/unix/ztypes_linux_ppc64.go b/unix/ztypes_linux_ppc64.go index 5748d80c..afe5de7d 100644 --- a/unix/ztypes_linux_ppc64.go +++ b/unix/ztypes_linux_ppc64.go @@ -105,7 +105,7 @@ type Stat_t struct { Mode uint32 Uid uint32 Gid uint32 - X__pad2 int32 + _ int32 Rdev uint64 Size int64 Blksize int64 @@ -134,9 +134,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -173,7 +173,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -589,12 +589,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -686,7 +686,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]uint8 + _ [0]uint8 _ [4]byte } @@ -709,10 +709,10 @@ type Ustat_t struct { } type EpollEvent struct { - Events uint32 - X_padFd int32 - Fd int32 - Pad int32 + Events uint32 + _ int32 + Fd int32 + Pad int32 } const ( @@ -746,7 +746,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x40045200 diff --git a/unix/ztypes_linux_ppc64le.go b/unix/ztypes_linux_ppc64le.go index ca54d447..c0692890 100644 --- a/unix/ztypes_linux_ppc64le.go +++ b/unix/ztypes_linux_ppc64le.go @@ -105,7 +105,7 @@ type Stat_t struct { Mode uint32 Uid uint32 Gid uint32 - X__pad2 int32 + _ int32 Rdev uint64 Size int64 Blksize int64 @@ -134,9 +134,9 @@ type Statfs_t struct { } type StatxTimestamp struct { - Sec int64 - Nsec uint32 - X__reserved int32 + Sec int64 + Nsec uint32 + _ int32 } type Statx_t struct { @@ -173,7 +173,7 @@ type Dirent struct { } type Fsid struct { - X__val [2]int32 + _ [2]int32 } type Flock_t struct { @@ -589,12 +589,12 @@ type RtAttr struct { } type IfInfomsg struct { - Family uint8 - X__ifi_pad uint8 - Type uint16 - Index int32 - Flags uint32 - Change uint32 + Family uint8 + _ uint8 + Type uint16 + Index int32 + Flags uint32 + Change uint32 } type IfAddrmsg struct { @@ -686,7 +686,7 @@ type Sysinfo_t struct { Totalhigh uint64 Freehigh uint64 Unit uint32 - X_f [0]uint8 + _ [0]uint8 _ [4]byte } @@ -709,10 +709,10 @@ type Ustat_t struct { } type EpollEvent struct { - Events uint32 - X_padFd int32 - Fd int32 - Pad int32 + Events uint32 + _ int32 + Fd int32 + Pad int32 } const ( @@ -746,7 +746,7 @@ const ( ) type Sigset_t struct { - X__val [16]uint64 + _ [16]uint64 } const RNDGETENTCNT = 0x40045200