From 52b67c4154c87bd3e26213308dd92199cb3e5593 Mon Sep 17 00:00:00 2001 From: ian Date: Mon, 30 Apr 2012 16:04:17 +0000 Subject: [PATCH] PR go/52586 mksysinfo, syscall: Make sure SYS_GETDENTS64 is defined. Fixes build on MIPS GNU/Linux. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186986 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgo/go/syscall/libcall_linux.go | 6 +++++- libgo/mksysinfo.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libgo/go/syscall/libcall_linux.go b/libgo/go/syscall/libcall_linux.go index 7c9f05e..8d7da19 100644 --- a/libgo/go/syscall/libcall_linux.go +++ b/libgo/go/syscall/libcall_linux.go @@ -203,7 +203,11 @@ func Getdents(fd int, buf []byte) (n int, err error) { p = (*byte)(unsafe.Pointer(&_zero)) } Entersyscall() - r1, _, errno := Syscall(SYS_GETDENTS64, uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(buf))) + s := SYS_GETDENTS64 + if s == 0 { + s = SYS_GETDENTS + } + r1, _, errno := Syscall(uintptr(s), uintptr(fd), uintptr(unsafe.Pointer(p)), uintptr(len(buf))) n = int(r1) if n < 0 { err = errno diff --git a/libgo/mksysinfo.sh b/libgo/mksysinfo.sh index db61a73..655337f 100755 --- a/libgo/mksysinfo.sh +++ b/libgo/mksysinfo.sh @@ -224,6 +224,14 @@ grep '^const _SYS_' gen-sysinfo.go | \ echo "const $sup = _$sys" >> ${OUT} done +# The GNU/Linux support wants to use SYS_GETDENTS64 if available. +if ! grep '^const SYS_GETDENTS ' ${OUT} >/dev/null 2>&1; then + echo "const SYS_GETDENTS = 0" >> ${OUT} +fi +if ! grep '^const SYS_GETDENTS64 ' ${OUT} >/dev/null 2>&1; then + echo "const SYS_GETDENTS64 = 0" >> ${OUT} +fi + # Stat constants. grep '^const _S_' gen-sysinfo.go | \ sed -e 's/^\(const \)_\(S_[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT} -- 2.7.4