Commit 1142b60d authored by Russ Cox's avatar Russ Cox

syscall/arm: correct 64-bit system call arguments

Thanks to kaib for the tip.

R=ken2
CC=golang-dev
https://golang.org/cl/2596043
parent c00f9f49
......@@ -48,8 +48,8 @@ TEXT ·Syscall6(SB),7,$0
MOVW 24(SP), R4
MOVW 28(SP), R5
SWI $0
MOVW $0xfffff001, R1
CMP R1, R0
MOVW $0xfffff001, R6
CMP R6, R0
BLS ok6
MOVW $-1, R1
MOVW R1, 32(SP) // r1
......@@ -61,12 +61,44 @@ TEXT ·Syscall6(SB),7,$0
RET
ok6:
MOVW R0, 32(SP) // r1
MOVW R1, 36(SP) // r2
MOVW $0, R0
MOVW R0, 36(SP) // r2
MOVW R0, 40(SP) // errno
BL runtime·exitsyscall(SB)
RET
#define SYS__LLSEEK 140 /* from zsysnum_linux_arm.go */
// func Seek(fd int, offset int64, whence int) (newoffset int64, errno int)
// Implemented in assembly to avoid allocation when
// taking the address of the return value newoffset.
// Underlying system call is
// llseek(int fd, int offhi, int offlo, int64 *result, int whence)
TEXT ·Seek(SB),7,$0
BL runtime·entersyscall(SB)
MOVW $SYS__LLSEEK, R7 // syscall entry
MOVW 4(SP), R0 // fd
MOVW 12(SP), R1 // offset-high
MOVW 8(SP), R2 // offset-low
MOVW $20(SP), R3
MOVW 16(SP), R4 // whence
SWI $0
MOVW $0xfffff001, R6
CMP R6, R0
BLS okseek
MOVW $0, R1
MOVW R1, 20(SP)
MOVW R1, 24(SP)
RSB $0, R0, R0
MOVW R0, 28(SP) // errno
BL runtime·exitsyscall(SB)
RET
okseek:
// system call filled in newoffset already
MOVW $0, R0
MOVW R0, 28(SP) // errno
BL runtime·exitsyscall(SB)
RET
// func RawSyscall(trap uintptr, a1, a2, a3 uintptr) (r1, r2, err uintptr);
TEXT ·RawSyscall(SB),7,$0
MOVW 4(SP), R7 // syscall entry
......@@ -90,3 +122,4 @@ ok1:
MOVW R0, 24(SP) // r2
MOVW R0, 28(SP) // errno
RET
......@@ -646,8 +646,6 @@ func PtraceDetach(pid int) (errno int) { return ptrace(PTRACE_DETACH, pid, 0, 0)
//sys Nanosleep(time *Timespec, leftover *Timespec) (errno int)
//sys Pause() (errno int)
//sys PivotRoot(newroot string, putold string) (errno int) = SYS_PIVOT_ROOT
//sys Pread(fd int, p []byte, offset int64) (n int, errno int) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, errno int) = SYS_PWRITE64
//sys Read(fd int, p []byte) (n int, errno int)
//sys Readlink(path string, buf []byte) (n int, errno int)
//sys Rename(oldpath string, newpath string) (errno int)
......
......@@ -38,6 +38,8 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
//sys Iopl(level int) (errno int)
//sys Lchown(path string, uid int, gid int) (errno int) = SYS_LCHOWN32
//sys Lstat(path string, stat *Stat_t) (errno int) = SYS_LSTAT64
//sys Pread(fd int, p []byte, offset int64) (n int, errno int) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, errno int) = SYS_PWRITE64
//sys Setfsgid(gid int) (errno int) = SYS_SETFSGID32
//sys Setfsuid(uid int) (errno int) = SYS_SETFSUID32
//sys Setgid(gid int) (errno int) = SYS_SETGID32
......
......@@ -17,6 +17,8 @@ package syscall
//sys Lchown(path string, uid int, gid int) (errno int)
//sys Listen(s int, n int) (errno int)
//sys Lstat(path string, stat *Stat_t) (errno int)
//sys Pread(fd int, p []byte, offset int64) (n int, errno int) = SYS_PREAD64
//sys Pwrite(fd int, p []byte, offset int64) (n int, errno int) = SYS_PWRITE64
//sys Seek(fd int, offset int64, whence int) (off int64, errno int) = SYS_LSEEK
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, errno int)
//sys Setfsgid(gid int) (errno int)
......
......@@ -4,6 +4,8 @@
package syscall
import "unsafe"
func Getpagesize() int { return 4096 }
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
......@@ -21,6 +23,35 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
return
}
// Pread and Pwrite are special: they insert padding before the int64.
// (Ftruncate and truncate are not; go figure.)
func Pread(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
n = int(r0)
errno = int(e1)
return
}
func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
n = int(r0)
errno = int(e1)
return
}
// Seek is defined in assembly.
func Seek(fd int, offset int64, whence int) (newoffset int64, errno int)
//sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, errno int)
//sys bind(s int, addr uintptr, addrlen _Socklen) (errno int)
//sys connect(s int, addr uintptr, addrlen _Socklen) (errno int)
......@@ -45,7 +76,6 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
//sys Lchown(path string, uid int, gid int) (errno int)
//sys Listen(s int, n int) (errno int)
//sys Lstat(path string, stat *Stat_t) (errno int) = SYS_LSTAT64
//sys Seek(fd int, offset int64, whence int) (off int64, errno int) = SYS_LSEEK
//sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, errno int) = SYS__NEWSELECT
//sys Setfsgid(gid int) (errno int)
//sys Setfsuid(uid int) (errno int)
......
......@@ -472,32 +472,6 @@ func PivotRoot(newroot string, putold string) (errno int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Read(fd int, p []byte) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
......@@ -862,6 +836,32 @@ func Lstat(path string, stat *Stat_t) (errno int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Setfsgid(gid int) (errno int) {
_, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0)
errno = int(e1)
......
......@@ -472,32 +472,6 @@ func PivotRoot(newroot string, putold string) (errno int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Read(fd int, p []byte) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
......@@ -878,6 +852,32 @@ func Lstat(path string, stat *Stat_t) (errno int) {
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pread(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Pwrite(fd int, p []byte, offset int64) (n int, errno int) {
var _p0 unsafe.Pointer
if len(p) > 0 {
_p0 = unsafe.Pointer(&p[0])
}
r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
n = int(r0)
errno = int(e1)
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Seek(fd int, offset int64, whence int) (off int64, errno int) {
r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
off = int64(r0)
......
This diff is collapsed.
......@@ -4,7 +4,7 @@
// Manual corrections: TODO(rsc): need to fix godefs
// remove duplicate PtraceRegs type
// change RawSockaddrUnix field to Path [108]int8 (was uint8()
// change RawSockaddrUnix field to Path [108]int8 (was uint8)
// add padding to EpollEvent
package syscall
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment