libgo patch committed: Support stat and device numbers on AIX

Message ID CAOyqgcWZL93A=nM_5_-C7nuGXf7wr-J8W7z+cDV8uap7LDeJZg@mail.gmail.com
State New
Headers show
Series
  • libgo patch committed: Support stat and device numbers on AIX
Related show

Commit Message

Ian Lance Taylor Jan. 17, 2018, 6:34 p.m.
This patch by Tony Reix adds support for stat and device numbers on
AIX.  Bootstrapped and ran Go tests on x86_64-pc-linux-gnu.  Committed
to  mainline.

Ian

Patch

Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 256794)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@ 
-ca805b704fc141d7ad61f8fcd3badbaa04b7e363
+3ea7fc3b918210e7248dbc51d90af20639dc4167
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/archive/tar/stat_actime1.go
===================================================================
--- libgo/go/archive/tar/stat_actime1.go	(revision 256593)
+++ libgo/go/archive/tar/stat_actime1.go	(working copy)
@@ -2,7 +2,7 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux dragonfly openbsd solaris
+// +build aix linux dragonfly openbsd solaris
 
 package tar
 
Index: libgo/go/archive/tar/stat_unix.go
===================================================================
--- libgo/go/archive/tar/stat_unix.go	(revision 256593)
+++ libgo/go/archive/tar/stat_unix.go	(working copy)
@@ -2,7 +2,7 @@ 
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build linux darwin dragonfly freebsd openbsd netbsd solaris
+// +build aix linux darwin dragonfly freebsd openbsd netbsd solaris
 
 package tar
 
@@ -54,6 +54,16 @@  func statUnix(fi os.FileInfo, h *Header)
 	if h.Typeflag == TypeChar || h.Typeflag == TypeBlock {
 		dev := uint64(sys.Rdev) // May be int32 or uint32
 		switch runtime.GOOS {
+		case "aix":
+			var major, minor uint32
+			if runtime.GOARCH == "ppc64" {
+				major = uint32((dev & 0x3fffffff00000000) >> 32)
+				minor = uint32((dev & 0x00000000ffffffff) >> 0)
+			} else {
+				major = uint32((dev >> 16) & 0xffff)
+				minor = uint32(dev & 0xffff)
+			}
+			h.Devmajor, h.Devminor = int64(major), int64(minor)
 		case "linux":
 			// Copied from golang.org/x/sys/unix/dev_linux.go.
 			major := uint32((dev & 0x00000000000fff00) >> 8)