unix: rename Stat_t time fields to [AMCB]tim

Birthtime/Birthtimespec was renamed to Btim to match the others.
Also unexport the [ACMB]tim_ext fields on freebsd 386.
Update mkpost.go to do the renames.

Ran the following on the existing ztypes_*.go files:

  #!/bin/sh
  set -e

  for f in ztypes_*.go; do
      cat $f | go run mkpost.go | gofmt > $f.tmp
      mv $f.tmp $f
  done;

  cat ztypes_freebsd_386.go | env GOOS=freebsd GOARCH=386 go run mkpost.go | gofmt > ztypes_freebsd_386.go.tmp
  mv ztypes_freebsd_386.go{.tmp,}

Fixes golang/go#31735

Change-Id: I15765d690ee8d2be6bbb37f465322bc019722e08
Reviewed-on: https://go-review.googlesource.com/c/sys/+/175157
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Yuval Pavel Zholkover
2019-05-15 19:05:49 +00:00
committed by Brad Fitzpatrick
parent 06a5c49444
commit 87c872767d
16 changed files with 354 additions and 335 deletions
+9
View File
@@ -96,6 +96,15 @@ func main() {
cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`) cgoCommandRegex := regexp.MustCompile(`(cgo -godefs .*)`)
b = cgoCommandRegex.ReplaceAll(b, []byte(replacement)) b = cgoCommandRegex.ReplaceAll(b, []byte(replacement))
// Rename Stat_t time fields
if goos == "freebsd" && goarch == "386" {
// Hide Stat_t.[AMCB]tim_ext fields
renameStatTimeExtFieldsRegex := regexp.MustCompile(`[AMCB]tim_ext`)
b = renameStatTimeExtFieldsRegex.ReplaceAll(b, []byte("_"))
}
renameStatTimeFieldsRegex := regexp.MustCompile(`([AMCB])(?:irth)?time?(?:spec)?\s+(Timespec|StTimespec)`)
b = renameStatTimeFieldsRegex.ReplaceAll(b, []byte("${1}tim ${2}"))
// gofmt // gofmt
b, err = format.Source(b) b, err = format.Source(b)
if err != nil { if err != nil {
+16 -16
View File
@@ -404,22 +404,22 @@ func roundup(x, y int) int {
func (s *Stat_t) convertFrom(old *stat_freebsd11_t) { func (s *Stat_t) convertFrom(old *stat_freebsd11_t) {
*s = Stat_t{ *s = Stat_t{
Dev: uint64(old.Dev), Dev: uint64(old.Dev),
Ino: uint64(old.Ino), Ino: uint64(old.Ino),
Nlink: uint64(old.Nlink), Nlink: uint64(old.Nlink),
Mode: old.Mode, Mode: old.Mode,
Uid: old.Uid, Uid: old.Uid,
Gid: old.Gid, Gid: old.Gid,
Rdev: uint64(old.Rdev), Rdev: uint64(old.Rdev),
Atim: old.Atim, Atim: old.Atim,
Mtim: old.Mtim, Mtim: old.Mtim,
Ctim: old.Ctim, Ctim: old.Ctim,
Birthtim: old.Birthtim, Btim: old.Btim,
Size: old.Size, Size: old.Size,
Blocks: old.Blocks, Blocks: old.Blocks,
Blksize: old.Blksize, Blksize: old.Blksize,
Flags: old.Flags, Flags: old.Flags,
Gen: uint64(old.Gen), Gen: uint64(old.Gen),
} }
} }
+10
View File
@@ -58,3 +58,13 @@ func TestUname(t *testing.T) {
t.Logf("OS: %s/%s %s", utsname.Sysname[:], utsname.Machine[:], utsname.Release[:]) t.Logf("OS: %s/%s %s", utsname.Sysname[:], utsname.Machine[:], utsname.Release[:])
} }
// Test that this compiles. (Issue #31735)
func TestStatFieldNames(t *testing.T) {
var st unix.Stat_t
var ts *unix.Timespec
ts = &st.Atim
ts = &st.Mtim
ts = &st.Ctim
_ = ts
}
+18 -18
View File
@@ -59,24 +59,24 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev int32 Dev int32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Ino uint64 Ino uint64
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev int32 Rdev int32
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Qspare [2]int64 Qspare [2]int64
} }
type Statfs_t struct { type Statfs_t struct {
+19 -19
View File
@@ -63,25 +63,25 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev int32 Dev int32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Ino uint64 Ino uint64
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev int32 Rdev int32
_ [4]byte _ [4]byte
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Qspare [2]int64 Qspare [2]int64
} }
type Statfs_t struct { type Statfs_t struct {
+18 -18
View File
@@ -60,24 +60,24 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev int32 Dev int32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Ino uint64 Ino uint64
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev int32 Rdev int32
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Qspare [2]int64 Qspare [2]int64
} }
type Statfs_t struct { type Statfs_t struct {
+19 -19
View File
@@ -63,25 +63,25 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev int32 Dev int32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Ino uint64 Ino uint64
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev int32 Rdev int32
_ [4]byte _ [4]byte
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Qspare [2]int64 Qspare [2]int64
} }
type Statfs_t struct { type Statfs_t struct {
+19 -19
View File
@@ -57,25 +57,25 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Ino uint64 Ino uint64
Nlink uint32 Nlink uint32
Dev uint32 Dev uint32
Mode uint16 Mode uint16
Padding1 uint16 _1 uint16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint32 Rdev uint32
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize uint32 Blksize uint32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Qspare1 int64 Qspare1 int64
Qspare2 int64 Qspare2 int64
} }
type Statfs_t struct { type Statfs_t struct {
+41 -41
View File
@@ -62,50 +62,50 @@ const (
) )
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Ino uint64 Ino uint64
Nlink uint64 Nlink uint64
Mode uint16 Mode uint16
_0 int16 _0 int16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
_1 int32 _1 int32
Rdev uint64 Rdev uint64
Atim_ext int32 _ int32
Atim Timespec Atim Timespec
Mtim_ext int32 _ int32
Mtim Timespec Mtim Timespec
Ctim_ext int32 _ int32
Ctim Timespec Ctim Timespec
Btim_ext int32 _ int32
Birthtim Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint64 Gen uint64
Spare [10]uint64 Spare [10]uint64
} }
type stat_freebsd11_t struct { type stat_freebsd11_t struct {
Dev uint32 Dev uint32
Ino uint32 Ino uint32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint32 Rdev uint32
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
_ [8]byte _ [8]byte
} }
type Statfs_t struct { type Statfs_t struct {
+36 -36
View File
@@ -62,45 +62,45 @@ const (
) )
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Ino uint64 Ino uint64
Nlink uint64 Nlink uint64
Mode uint16 Mode uint16
_0 int16 _0 int16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
_1 int32 _1 int32
Rdev uint64 Rdev uint64
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Birthtim Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint64 Gen uint64
Spare [10]uint64 Spare [10]uint64
} }
type stat_freebsd11_t struct { type stat_freebsd11_t struct {
Dev uint32 Dev uint32
Ino uint32 Ino uint32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint32 Rdev uint32
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+36 -36
View File
@@ -64,45 +64,45 @@ const (
) )
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Ino uint64 Ino uint64
Nlink uint64 Nlink uint64
Mode uint16 Mode uint16
_0 int16 _0 int16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
_1 int32 _1 int32
Rdev uint64 Rdev uint64
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Birthtim Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint64 Gen uint64
Spare [10]uint64 Spare [10]uint64
} }
type stat_freebsd11_t struct { type stat_freebsd11_t struct {
Dev uint32 Dev uint32
Ino uint32 Ino uint32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint32 Rdev uint32
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+36 -36
View File
@@ -62,45 +62,45 @@ const (
) )
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Ino uint64 Ino uint64
Nlink uint64 Nlink uint64
Mode uint16 Mode uint16
_0 int16 _0 int16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
_1 int32 _1 int32
Rdev uint64 Rdev uint64
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Birthtim Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint64 Gen uint64
Spare [10]uint64 Spare [10]uint64
} }
type stat_freebsd11_t struct { type stat_freebsd11_t struct {
Dev uint32 Dev uint32
Ino uint32 Ino uint32
Mode uint16 Mode uint16
Nlink uint16 Nlink uint16
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint32 Rdev uint32
Atim Timespec Atim Timespec
Mtim Timespec Mtim Timespec
Ctim Timespec Ctim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize int32 Blksize int32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+17 -17
View File
@@ -57,23 +57,23 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Mode uint32 Mode uint32
Ino uint64 Ino uint64
Nlink uint32 Nlink uint32
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Rdev uint64 Rdev uint64
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize uint32 Blksize uint32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Spare [2]uint32 Spare [2]uint32
} }
type Statfs_t [0]byte type Statfs_t [0]byte
+20 -20
View File
@@ -58,26 +58,26 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Mode uint32 Mode uint32
Pad_cgo_0 [4]byte _ [4]byte
Ino uint64 Ino uint64
Nlink uint32 Nlink uint32
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Pad_cgo_1 [4]byte _ [4]byte
Rdev uint64 Rdev uint64
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize uint32 Blksize uint32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Spare [2]uint32 Spare [2]uint32
Pad_cgo_2 [4]byte _ [4]byte
} }
type Statfs_t [0]byte type Statfs_t [0]byte
+20 -20
View File
@@ -59,26 +59,26 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Mode uint32 Mode uint32
Pad_cgo_0 [4]byte _ [4]byte
Ino uint64 Ino uint64
Nlink uint32 Nlink uint32
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Pad_cgo_1 [4]byte _ [4]byte
Rdev uint64 Rdev uint64
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize uint32 Blksize uint32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Spare [2]uint32 Spare [2]uint32
Pad_cgo_2 [4]byte _ [4]byte
} }
type Statfs_t [0]byte type Statfs_t [0]byte
+20 -20
View File
@@ -58,26 +58,26 @@ type Rlimit struct {
type _Gid_t uint32 type _Gid_t uint32
type Stat_t struct { type Stat_t struct {
Dev uint64 Dev uint64
Mode uint32 Mode uint32
Pad_cgo_0 [4]byte _ [4]byte
Ino uint64 Ino uint64
Nlink uint32 Nlink uint32
Uid uint32 Uid uint32
Gid uint32 Gid uint32
Pad_cgo_1 [4]byte _ [4]byte
Rdev uint64 Rdev uint64
Atimespec Timespec Atim Timespec
Mtimespec Timespec Mtim Timespec
Ctimespec Timespec Ctim Timespec
Birthtimespec Timespec Btim Timespec
Size int64 Size int64
Blocks int64 Blocks int64
Blksize uint32 Blksize uint32
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Spare [2]uint32 Spare [2]uint32
Pad_cgo_2 [4]byte _ [4]byte
} }
type Statfs_t [0]byte type Statfs_t [0]byte