-87945b620b2100d33e27f33e6276a4e4e5890659
+069afe85f38c099660c5d81950d65248ed4fc516
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build hurd linux dragonfly openbsd solaris
+// +build aix hurd linux dragonfly openbsd solaris
package tar
writeLock lockType = syscall.F_WRLCK
)
-type inode = uint64 // type of syscall.Stat_t.Ino
+// type of syscall.Stat_t.Ino for 64 bits architectures.
+// For 32 bits architecture, it's easier to cast it instead.
+type inode = uint64
type inodeLock struct {
owner File
if err != nil {
return err
}
- ino := fi.Sys().(*syscall.Stat_t).Ino
+ ino := uint64(fi.Sys().(*syscall.Stat_t).Ino)
mu.Lock()
if i, dup := inodes[f]; dup && i != ino {
// 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
+// +build hurd linux solaris,386 solaris,sparc
package unix
// 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
"unsafe"
)
-//go:cgo_import_dynamic libc_ioctl ioctl "libc.a/shr_64.o"
-//go:linkname libc_ioctl libc_ioctl
-var libc_ioctl uintptr
-
-// Implemented in syscall/syscall_aix.go.
-func syscall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno)
+//extern __go_ioctl_ptr
+func ioctl(int32, int32, unsafe.Pointer) int32
func Ioctl(fd int, cmd int, args uintptr) (err error) {
- _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_ioctl)), 3, uintptr(fd), uintptr(cmd), uintptr(args), 0, 0, 0)
- if e1 != 0 {
- err = e1
+ if ioctl(int32(fd), int32(cmd), unsafe.Pointer(args)) < 0 {
+ return syscall.GetErrno()
}
return
}
const _RTAX_IFA = 5
const _RTAX_MAX = 8
+const _SIOCGIFMTU = -0x3fd796aa
+
func getIfList() ([]byte, error) {
needed, err := syscall.Getkerninfo(_KINFO_RT_IFLIST, 0, 0, 0)
if err != nil {
}
if ifm.Type == syscall.RTM_IFINFO {
if ifindex == 0 || ifindex == int(ifm.Index) {
- sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[syscall.SizeofIfMsghdr]))
+ sdl := (*rawSockaddrDatalink)(unsafe.Pointer(&tab[unsafe.Sizeof(syscall.IfMsgHdr)]))
ifi := &Interface{Index: int(ifm.Index), Flags: linkFlags(ifm.Flags)}
ifi.Name = string(sdl.Data[:sdl.Nlen])
if err != nil {
return nil, err
}
- err = unix.Ioctl(sock, syscall.SIOCGIFMTU, uintptr(unsafe.Pointer(ifr)))
+ err = unix.Ioctl(sock, _SIOCGIFMTU, uintptr(unsafe.Pointer(ifr)))
if err != nil {
return nil, err
}
if ifm.Type == syscall.RTM_NEWADDR {
if ifi == nil || ifi.Index == int(ifm.Index) {
mask := ifm.Addrs
- off := uint(syscall.SizeofIfMsghdr)
+ off := uint(unsafe.Sizeof(syscall.IfMsgHdr))
var iprsa, nmrsa *syscall.RawSockaddr
for i := uint(0); i < _RTAX_MAX; i++ {
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-// +build aix nacl hurd js,wasm
+// +build nacl hurd js,wasm
package net
+++ /dev/null
-// 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 net
-
-import "syscall"
-
-func setIPv4MulticastInterface(fd *netFD, ifi *Interface) error {
- return syscall.ENOPROTOOPT
-}
-
-func setIPv4MulticastLoopback(fd *netFD, v bool) error {
- return syscall.ENOPROTOOPT
-}
//extern pathconf
func libc_pathconf(*byte, int) int
-//extern fdopendir
-func libc_fdopendir(int32) *syscall.DIR
-
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
if n[i] == 0 {
//extern closedir64
func libc_closedir(*syscall.DIR) int
+
+//extern fdopendir64
+func libc_fdopendir(int32) *syscall.DIR
//extern closedir
func libc_closedir(*syscall.DIR) int
+
+//extern fdopendir
+func libc_fdopendir(int32) *syscall.DIR
+++ /dev/null
-// Copyright 2018 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 os
-
-import "syscall"
-
-// gethostname syscall cannot be used because it also returns the domain.
-// Therefore, hostname is retrieve with uname syscall and the Nodename field.
-
-func hostname() (name string, err error) {
- var u syscall.Utsname
- if errno := syscall.Uname(&u); errno != nil {
- return "", NewSyscallError("uname", errno)
- }
- b := make([]byte, len(u.Nodename))
- i := 0
- for ; i < len(u.Nodename); i++ {
- if u.Nodename[i] == 0 {
- break
- }
- b[i] = byte(u.Nodename[i])
- }
- return string(b[:i]), nil
-}
// we further limit it to 31 bits.
//
// WebAssembly currently has a limit of 4GB linear memory.
- heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix
+ heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*(sys.GoosAix*_64bit)
// maxAlloc is the maximum size of an allocation. On 64-bit,
// it's theoretically possible to allocate 1<<heapAddrBits bytes. On
// logHeapArenaBytes is log_2 of heapArenaBytes. For clarity,
// prefer using heapArenaBytes where possible (we need the
// constant to compute some other constants).
- logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*sys.GoosAix
+ logHeapArenaBytes = (6+20)*(_64bit*(1-sys.GoosWindows)*(1-sys.GoosAix)) + (2+20)*(_64bit*sys.GoosWindows) + (2+20)*(1-_64bit) + (8+20)*(sys.GoosAix*_64bit)
// heapArenaBitmapBytes is the size of each heap arena's bitmap.
heapArenaBitmapBytes = heapArenaBytes / (sys.PtrSize * 8 / 2)
//
// We use the L1 map on aix/ppc64 to keep the same L2 value
// as on Linux.
- arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*sys.GoosAix
+ arenaL1Bits = 6*(_64bit*sys.GoosWindows) + 12*(sys.GoosAix*_64bit)
// arenaL2Bits is the number of bits of the arena number
// covered by the second level arena index.
func sysMap(v unsafe.Pointer, n uintptr, sysStat *uint64) {
mSysStatInc(sysStat, n)
+ if GOOS == "aix" {
+ // AIX does not allow mapping a range that is already mapped.
+ // So always unmap first even if it is already unmapped.
+ munmap(v, n)
+ }
p, err := mmap(v, n, _PROT_READ|_PROT_WRITE, _MAP_ANON|_MAP_FIXED|_MAP_PRIVATE, mmapFD, 0)
if err == _ENOMEM {
throw("runtime: out of memory")
const _POLLOUT = 0x0002
const _POLLHUP = 0x2000
const _POLLERR = 0x4000
-const _O_NONBLOCK = 0x4
var (
pfds []pollfd
if clock_gettime(_CLOCK_REALTIME, &ts) != 0 {
throw("clock_gettime")
}
- ts.tv_sec += ns / 1e9
- ts.tv_nsec += ns % 1e9
- if ts.tv_nsec >= 1e9 {
- ts.tv_sec++
- ts.tv_nsec -= 1e9
+
+ sec := int64(ts.tv_sec) + ns/1e9
+ nsec := int64(ts.tv_nsec) + ns%1e9
+ if nsec >= 1e9 {
+ sec++
+ nsec -= 1e9
+ }
+ if sec != int64(timespec_sec_t(sec)) {
+ // Handle overflows (timespec_sec_t is 32-bit in 32-bit applications)
+ sec = 1<<31 - 1
}
+ ts.tv_sec = timespec_sec_t(sec)
+ ts.tv_nsec = timespec_nsec_t(nsec)
if sem_timedwait((*semt)(unsafe.Pointer(_m_.mos.waitsema)), &ts) != 0 {
err := errno()
// +build !nacl
// +build !js
// +build !darwin
-// +build !aix
package runtime
// +build !darwin
// +build !windows
// +build !freebsd
-// +build !aix
-
package runtime
func walltime() (sec int64, nsec int32)
+++ /dev/null
-// Copyright 2015 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
-
-package syscall
-
-import "unsafe"
-
-//go:cgo_import_dynamic libc_Getpgid getpgid "libc.a/shr_64.o"
-//go:cgo_import_dynamic libc_Getpgrp getpgrp "libc.a/shr_64.o"
-
-//go:linkname libc_Getpgid libc_Getpgid
-//go:linkname libc_Getpgrp libc_Getpgrp
-
-var (
- libc_Getpgid,
- libc_Getpgrp libcFunc
-)
-
-func Getpgid(pid int) (pgid int, err error) {
- r0, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_Getpgid)), 1, uintptr(pid), 0, 0, 0, 0, 0)
- pgid = int(r0)
- if e1 != 0 {
- err = e1
- }
- return
-}
-
-func Getpgrp() (pgrp int) {
- r0, _, _ := syscall6(uintptr(unsafe.Pointer(&libc_Getpgrp)), 0, 0, 0, 0, 0, 0, 0)
- pgrp = int(r0)
- return
-}
-
-var Ioctl = ioctl
// execveLibc is non-nil on OS using libc syscall, set to execve in exec_libc.go; this
// avoids a build dependency for other platforms.
-var execveLibc func(path uintptr, argv uintptr, envp uintptr) Errno
var execveDarwin func(path *byte, argv **byte, envp **byte) error
// Exec invokes the execve(2) system call.
var err1 error
if runtime.GOOS == "solaris" || runtime.GOOS == "aix" || runtime.GOOS == "hurd" {
// RawSyscall should never be used on Solaris or AIX.
- err1 = execveLibc(
- uintptr(unsafe.Pointer(argv0p)),
- uintptr(unsafe.Pointer(&argvp[0])),
- uintptr(unsafe.Pointer(&envvp[0])))
+ err1 = raw_execve(argv0p, &argvp[0], &envvp[0])
} else if runtime.GOOS == "darwin" {
// Similarly on Darwin.
err1 = execveDarwin(argv0p, &argvp[0], &envvp[0])
+++ /dev/null
-// Copyright 2018 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
-
-import "unsafe"
-
-// On AIX, there is no flock() system call.
-
-// FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command.
-func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) {
- _, _, e1 := syscall6(uintptr(unsafe.Pointer(&libc_fcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0)
- if e1 != 0 {
- err = errnoErr(e1)
- }
- return
-}
"unsafe"
)
+// For exec_unix.go.
+const SYS_EXECVE = 0
+
//sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error)
//open64at(dirfd _C_int, path *byte, flags _C_int, mode Mode_t) _C_int
func Unlinkat(dirfd int, path string) (err error) {
return unlinkat(dirfd, path, 0)
}
+
+//sys Getkerninfo(op int32, where uintptr, size uintptr, arg int64) (i int32, err error)
+//getkerninfo(op _C_int, where *byte, size *byte, arg _C_long) _C_int
--- /dev/null
+// Copyright 2009 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 hurd linux netbsd openbsd solaris
+
+package syscall
+
+//extern __go_syscall6
+func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
+
+// Do a system call. We look at the size of uintptr to see how to pass
+// the arguments, so that we don't pass a 64-bit value when the function
+// expects a 32-bit one.
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+ Entersyscall()
+ SetErrno(0)
+ r := syscall6(trap, a1, a2, a3, 0, 0, 0)
+ err = GetErrno()
+ Exitsyscall()
+ return r, 0, err
+}
+
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+ Entersyscall()
+ SetErrno(0)
+ r := syscall6(trap, a1, a2, a3, a4, a5, a6)
+ err = GetErrno()
+ Exitsyscall()
+ return r, 0, err
+}
+
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+ SetErrno(0)
+ r := syscall6(trap, a1, a2, a3, 0, 0, 0)
+ err = GetErrno()
+ return r, 0, err
+}
+
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+ SetErrno(0)
+ r := syscall6(trap, a1, a2, a3, a4, a5, a6)
+ err = GetErrno()
+ return r, 0, err
+}
--- /dev/null
+// Copyright 2010 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 rtems
+
+// These are stubs.
+
+package syscall
+
+func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+ z := -1
+ return uintptr(z), 0, ENOSYS
+}
+
+func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+ z := -1
+ return uintptr(z), 0, ENOSYS
+}
+
+func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
+ z := -1
+ return uintptr(z), 0, ENOSYS
+}
+
+func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
+ z := -1
+ return uintptr(z), 0, ENOSYS
+}
+++ /dev/null
-// Copyright 2010 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 rtems
-
-// These are stubs.
-
-package syscall
-
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
- z := -1
- return uintptr(z), 0, uintptr(ENOSYS)
-}
-
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
- z := -1
- return uintptr(z), 0, uintptr(ENOSYS)
-}
-
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) {
- z := -1
- return uintptr(z), 0, uintptr(ENOSYS)
-}
-
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
- z := -1
- return uintptr(z), 0, uintptr(ENOSYS)
-}
Stderr = 2
)
-//extern __go_syscall6
-func syscall6(trap uintptr, a1, a2, a3, a4, a5, a6 uintptr) uintptr
-
const (
darwin64Bit = runtime.GOOS == "darwin" && sizeofPtr == 8
dragonfly64Bit = runtime.GOOS == "dragonfly" && sizeofPtr == 8
solaris64Bit = runtime.GOOS == "solaris" && sizeofPtr == 8
)
-// Do a system call. We look at the size of uintptr to see how to pass
-// the arguments, so that we don't pass a 64-bit value when the function
-// expects a 32-bit one.
-func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
- Entersyscall()
- SetErrno(0)
- r := syscall6(trap, a1, a2, a3, 0, 0, 0)
- err = GetErrno()
- Exitsyscall()
- return r, 0, err
-}
-
-func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
- Entersyscall()
- SetErrno(0)
- r := syscall6(trap, a1, a2, a3, a4, a5, a6)
- err = GetErrno()
- Exitsyscall()
- return r, 0, err
-}
-
-func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno) {
- SetErrno(0)
- r := syscall6(trap, a1, a2, a3, 0, 0, 0)
- err = GetErrno()
- return r, 0, err
-}
-
-func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err Errno) {
- SetErrno(0)
- r := syscall6(trap, a1, a2, a3, a4, a5, a6)
- err = GetErrno()
- return r, 0, err
-}
-
// clen returns the index of the first NULL byte in n or len(n) if n contains no NULL byte.
func clen(n []byte) int {
for i := 0; i < len(n); i++ {
-e 's/ifi_change/Change/' \
>> ${OUT}
+# The if_msghdr struct.
+grep '^type _if_msghdr ' gen-sysinfo.go | \
+ sed -e 's/_if_msghdr/IfMsgHdr/' \
+ -e 's/ifm_msglen/Msglen/' \
+ -e 's/ifm_version/Version/' \
+ -e 's/ifm_type/Type/' \
+ -e 's/ifm_addrs/Addrs/' \
+ -e 's/ifm_flags/Flags/' \
+ -e 's/ifm_index/Index/' \
+ -e 's/ifm_addrlen/Addrlen/' \
+ >> ${OUT}
+
# The interface information types and flags.
grep '^const _IFA' gen-sysinfo.go | \
sed -e 's/^\(const \)_\(IFA[^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
#endif
+#ifdef HAVE_SYSCALL
+
// __go_syscall6 is called by both the runtime and syscall packages.
// We use uintptr_t to make sure that the types match, since the Go
// and C "int" types are not the same.
{
return syscall (flag, a1, a2, a3, a4, a5, a6);
}
+
+#endif