libgo: adjust NetBSD-specific types for stable syscall API
authorNikhil Benesch <nikhil.benesch@gmail.com>
Mon, 19 Oct 2020 02:07:34 +0000 (02:07 +0000)
committerIan Lance Taylor <iant@golang.org>
Tue, 20 Oct 2020 20:01:26 +0000 (13:01 -0700)
The backwards-compatibility guarantees of the syscall package
require some munging of the C API inferred by mksysinfo.sh.
Specifically, the RTM_RESOLVE constant must be added if it is
missing, and the stat_t struct must use the suffix "timespec"
rather than "tim" for its time-related fields.

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/263519

gcc/go/gofrontend/MERGE
libgo/mksysinfo.sh

index 4ac0e8c6fc62e8cf801982281afec54702370921..fb7aa3e6eaeca12b11556ec22f0a6a659183d3cb 100644 (file)
@@ -1,4 +1,4 @@
-6662382a279dd5a5f99307e9b609654717638b24
+b2be94556bbc98f565fc277e30a038c742bf28a4
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 607c97d26fe4a4ef85837f183073a85675b7d0e0..deac5ce8d67d592458581bd57aa5be3598333c08 100755 (executable)
@@ -507,6 +507,13 @@ if grep 'define st_dev st_fsid' gen-sysinfo.go > /dev/null 2>&1; then
   st_dev='-e s/st_fsid/Dev/'
 fi
 
+# For historical reasons Go uses the suffix "timespec" instead of "tim" for
+# stat_t's time fields on NetBSD.
+st_times='-e s/st_atim/Atim/ -e s/st_mtim/Mtim/ -e s/st_ctim/Ctim/'
+if test "${GOOS}" = "netbsd"; then
+    st_times='-e s/st_atim/Atimespec/ -e s/st_mtim/Mtimespec/ -e s/st_ctim/Ctimespec/'
+fi
+
 # The stat type.
 # Prefer largefile variant if available.
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
@@ -517,6 +524,7 @@ else
 fi | sed -e 's/type _stat64/type Stat_t/' \
          -e 's/type _stat/type Stat_t/' \
          ${st_dev} \
+         ${st_times} \
          -e 's/st_ino/Ino/g' \
          -e 's/st_nlink/Nlink/' \
          -e 's/st_mode/Mode/' \
@@ -526,9 +534,6 @@ fi | sed -e 's/type _stat64/type Stat_t/' \
          -e 's/st_size/Size/' \
          -e 's/st_blksize/Blksize/' \
          -e 's/st_blocks/Blocks/' \
-         -e 's/st_atim/Atim/' \
-         -e 's/st_mtim/Mtim/' \
-         -e 's/st_ctim/Ctim/' \
          -e 's/\([^a-zA-Z0-9_]\)_timeval\([^a-zA-Z0-9_]\)/\1Timeval\2/g' \
          -e 's/\([^a-zA-Z0-9_]\)_timespec_t\([^a-zA-Z0-9_]\)/\1Timespec\2/g' \
          -e 's/\([^a-zA-Z0-9_]\)_st_timespec_t\([^a-zA-Z0-9_]\)/\1StTimespec\2/g' \
@@ -1055,6 +1060,13 @@ grep '^const _RTCF' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTCF[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _RTM' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTM[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
+if test "${GOOS}" = "netbsd"; then
+  if ! grep "RTM_RESOLVE" ${OUT} >/dev/null 2>&1; then
+    # NetBSD 8.0 removed RTM_RESOLVE, but it is part of the syscall package's
+    # stable API, so add it manually.
+    echo "const RTM_RESOLVE = 0xb" >> ${OUT}
+  fi
+fi
 grep '^const _RTN' gen-sysinfo.go | \
     sed -e 's/^\(const \)_\(RTN[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
 grep '^const _RTPROT' gen-sysinfo.go | \