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 {
+1 -1
View File
@@ -414,7 +414,7 @@ func (s *Stat_t) convertFrom(old *stat_freebsd11_t) {
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,
+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
}
+4 -4
View File
@@ -66,10 +66,10 @@ type Stat_t struct {
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
+4 -4
View File
@@ -71,10 +71,10 @@ type Stat_t struct {
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
+4 -4
View File
@@ -67,10 +67,10 @@ type Stat_t struct {
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
+4 -4
View File
@@ -71,10 +71,10 @@ type Stat_t struct {
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
+1 -1
View File
@@ -61,7 +61,7 @@ type Stat_t struct {
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
+6 -6
View File
@@ -71,14 +71,14 @@ type Stat_t struct {
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
@@ -104,7 +104,7 @@ type stat_freebsd11_t struct {
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
_ [8]byte _ [8]byte
} }
+2 -2
View File
@@ -74,7 +74,7 @@ type Stat_t struct {
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
@@ -100,7 +100,7 @@ type stat_freebsd11_t struct {
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+2 -2
View File
@@ -76,7 +76,7 @@ type Stat_t struct {
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
@@ -102,7 +102,7 @@ type stat_freebsd11_t struct {
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+2 -2
View File
@@ -74,7 +74,7 @@ type Stat_t struct {
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
@@ -100,7 +100,7 @@ type stat_freebsd11_t struct {
Flags uint32 Flags uint32
Gen uint32 Gen uint32
Lspare int32 Lspare int32
Birthtim Timespec Btim Timespec
} }
type Statfs_t struct { type Statfs_t struct {
+4 -4
View File
@@ -64,10 +64,10 @@ type Stat_t struct {
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
+7 -7
View File
@@ -60,24 +60,24 @@ 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
+7 -7
View File
@@ -61,24 +61,24 @@ 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
+7 -7
View File
@@ -60,24 +60,24 @@ 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