This libgo patch, based on one by Rainer Orth, uses more largefile functions. With this patch we consistently call __go_openat for openat and we use fstatat64, creat64, sendfile64, and getdents64 where needed. This is for PR 89447. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline.
Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 269443) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -959260238817af3205fb9907dd92319291e6a893 +3106ec19626d75d8275be16c86421132548fa13e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/internal/syscall/unix/at.go =================================================================== --- libgo/go/internal/syscall/unix/at.go (revision 269196) +++ libgo/go/internal/syscall/unix/at.go (working copy) @@ -13,12 +13,9 @@ import ( //extern unlinkat func unlinkat(int32, *byte, int32) int32 -//extern openat +//extern __go_openat func openat(int32, *byte, int32, syscall.Mode_t) int32 -//extern fstatat -func fstatat(int32, *byte, *syscall.Stat_t, int32) int32 - func Unlinkat(dirfd int, path string, flags int) error { var p *byte p, err := syscall.BytePtrFromString(path) Index: libgo/go/internal/syscall/unix/at_largefile.go =================================================================== --- libgo/go/internal/syscall/unix/at_largefile.go (nonexistent) +++ libgo/go/internal/syscall/unix/at_largefile.go (working copy) @@ -0,0 +1,14 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build aix hurd linux solaris,386 solaris,sparc + +package unix + +import ( + "syscall" +) + +//extern fstatat64 +func fstatat(int32, *byte, *syscall.Stat_t, int32) int32 Index: libgo/go/internal/syscall/unix/at_regfile.go =================================================================== --- libgo/go/internal/syscall/unix/at_regfile.go (nonexistent) +++ libgo/go/internal/syscall/unix/at_regfile.go (working copy) @@ -0,0 +1,18 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !aix +// +build !hurd +// +build !linux +// +build !solaris !386 +// +build !solaris !sparc + +package unix + +import ( + "syscall" +) + +//extern fstatat +func fstatat(int32, *byte, *syscall.Stat_t, int32) int32 Index: libgo/go/syscall/libcall_bsd.go =================================================================== --- libgo/go/syscall/libcall_bsd.go (revision 269196) +++ libgo/go/syscall/libcall_bsd.go (working copy) @@ -13,8 +13,6 @@ import ( "unsafe" ) -//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) -//sendfile(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { if race.Enabled { race.ReleaseMerge(unsafe.Pointer(&ioSync)) Index: libgo/go/syscall/libcall_bsd_largefile.go =================================================================== --- libgo/go/syscall/libcall_bsd_largefile.go (nonexistent) +++ libgo/go/syscall/libcall_bsd_largefile.go (working copy) @@ -0,0 +1,10 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build solaris,386 solaris,sparc + +package syscall + +//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) +//sendfile64(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t Index: libgo/go/syscall/libcall_bsd_regfile.go =================================================================== --- libgo/go/syscall/libcall_bsd_regfile.go (nonexistent) +++ libgo/go/syscall/libcall_bsd_regfile.go (working copy) @@ -0,0 +1,10 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build darwin dragonfly freebsd netbsd openbsd solaris,amd64 solaris,sparc64 + +package syscall + +//sys sendfile(outfd int, infd int, offset *Offset_t, count int) (written int, err error) +//sendfile(outfd _C_int, infd _C_int, offset *Offset_t, count Size_t) Ssize_t Index: libgo/go/syscall/libcall_posix.go =================================================================== --- libgo/go/syscall/libcall_posix.go (revision 269196) +++ libgo/go/syscall/libcall_posix.go (working copy) @@ -184,9 +184,6 @@ func FDZero(set *FdSet) { //sys Close(fd int) (err error) //close(fd _C_int) _C_int -//sys Creat(path string, mode uint32) (fd int, err error) -//creat(path *byte, mode Mode_t) _C_int - //sysnb Dup(oldfd int) (fd int, err error) //dup(oldfd _C_int) _C_int Index: libgo/go/syscall/libcall_posix_largefile.go =================================================================== --- libgo/go/syscall/libcall_posix_largefile.go (revision 269196) +++ libgo/go/syscall/libcall_posix_largefile.go (working copy) @@ -8,6 +8,9 @@ package syscall +//sys Creat(path string, mode uint32) (fd int, err error) +//creat64(path *byte, mode Mode_t) _C_int + //sys Fstat(fd int, stat *Stat_t) (err error) //fstat64(fd _C_int, stat *Stat_t) _C_int Index: libgo/go/syscall/libcall_posix_regfile.go =================================================================== --- libgo/go/syscall/libcall_posix_regfile.go (revision 269196) +++ libgo/go/syscall/libcall_posix_regfile.go (working copy) @@ -13,6 +13,9 @@ package syscall +//sys Creat(path string, mode uint32) (fd int, err error) +//creat(path *byte, mode Mode_t) _C_int + //sys Fstat(fd int, stat *Stat_t) (err error) //fstat(fd _C_int, stat *Stat_t) _C_int Index: libgo/go/syscall/libcall_solaris.go =================================================================== --- libgo/go/syscall/libcall_solaris.go (revision 269196) +++ libgo/go/syscall/libcall_solaris.go (nonexistent) @@ -1,12 +0,0 @@ -// Copyright 2017 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package syscall - -//sys Getdents(fd int, buf []byte) (n int, err error) -//getdents(fd _C_int, buf *byte, nbyte Size_t) _C_int - -func ReadDirent(fd int, buf []byte) (n int, err error) { - return Getdents(fd, buf) -} Index: libgo/go/syscall/libcall_solaris_largefile.go =================================================================== --- libgo/go/syscall/libcall_solaris_largefile.go (nonexistent) +++ libgo/go/syscall/libcall_solaris_largefile.go (working copy) @@ -0,0 +1,14 @@ +// Copyright 2019 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build solaris,386 solaris,sparc + +package syscall + +//sys Getdents(fd int, buf []byte) (n int, err error) +//getdents64(fd _C_int, buf *byte, nbyte Size_t) _C_int + +func ReadDirent(fd int, buf []byte) (n int, err error) { + return Getdents(fd, buf) +} Index: libgo/go/syscall/libcall_solaris_regfile.go =================================================================== --- libgo/go/syscall/libcall_solaris_regfile.go (nonexistent) +++ libgo/go/syscall/libcall_solaris_regfile.go (working copy) @@ -0,0 +1,14 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build solaris,amd64 solaris,sparc64 + +package syscall + +//sys Getdents(fd int, buf []byte) (n int, err error) +//getdents(fd _C_int, buf *byte, nbyte Size_t) _C_int + +func ReadDirent(fd int, buf []byte) (n int, err error) { + return Getdents(fd, buf) +}