Commit 34c312e1 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick Committed by Russ Cox

arm: use the correct stat syscalls

We were using the 64-bit struct with the old 32-bit
system calls.

http://code.google.com/p/go/issues/detail?id=1083

This also fixes up mksyscall.sh to generate
gofmt-compliant code.

R=rsc
CC=golang-dev, kaib
https://golang.org/cl/2148042
parent 832ed355
...@@ -73,7 +73,8 @@ while(<>) { ...@@ -73,7 +73,8 @@ while(<>) {
my @out = parseparamlist($out); my @out = parseparamlist($out);
# Go function header. # Go function header.
$text .= sprintf "func %s(%s) (%s) {\n", $func, join(', ', @in), join(', ', @out); my $out_decl = @out ? sprintf(" (%s)", join(', ', @out)) : "";
$text .= sprintf "func %s(%s)%s {\n", $func, join(', ', @in), $out_decl;
# Prepare arguments to Syscall. # Prepare arguments to Syscall.
my @args = (); my @args = ();
...@@ -88,15 +89,15 @@ while(<>) { ...@@ -88,15 +89,15 @@ while(<>) {
# Convert slice into pointer, length. # Convert slice into pointer, length.
# Have to be careful not to take address of &a[0] if len == 0: # Have to be careful not to take address of &a[0] if len == 0:
# pass nil in that case. # pass nil in that case.
$text .= "\tvar _p$n *$1;\n"; $text .= "\tvar _p$n *$1\n";
$text .= "\tif len($name) > 0 { _p$n = \&${name}[0]; }\n"; $text .= "\tif len($name) > 0 {\n\t\t_p$n = \&${name}[0]\n\t}\n";
push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))"; push @args, "uintptr(unsafe.Pointer(_p$n))", "uintptr(len($name))";
$n++; $n++;
} elsif($type eq "int64" && $_32bit ne "") { } elsif($type eq "int64" && $_32bit ne "") {
if($_32bit eq "big-endian") { if($_32bit eq "big-endian") {
push @args, "uintptr($name >> 32)", "uintptr($name)"; push @args, "uintptr($name>>32)", "uintptr($name)";
} else { } else {
push @args, "uintptr($name)", "uintptr($name >> 32)"; push @args, "uintptr($name)", "uintptr($name>>32)";
} }
} else { } else {
push @args, "uintptr($name)"; push @args, "uintptr($name)";
...@@ -159,19 +160,22 @@ while(<>) { ...@@ -159,19 +160,22 @@ while(<>) {
$ret[$i] = sprintf("r%d", $i); $ret[$i] = sprintf("r%d", $i);
$ret[$i+1] = sprintf("r%d", $i+1); $ret[$i+1] = sprintf("r%d", $i+1);
} }
$body .= "\t$name = $type($reg);\n"; $body .= "\t$name = $type($reg)\n";
} }
if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") { if ($ret[0] eq "_" && $ret[1] eq "_" && $ret[2] eq "_") {
$text .= "\t$call;\n"; $text .= "\t$call\n";
} else { } else {
$text .= "\t$ret[0], $ret[1], $ret[2] := $call;\n"; $text .= "\t$ret[0], $ret[1], $ret[2] := $call\n";
} }
$text .= $body; $text .= $body;
$text .= "\treturn;\n"; $text .= "\treturn\n";
$text .= "}\n\n"; $text .= "}\n\n";
} }
chomp $text;
chomp $text;
if($errors) { if($errors) {
exit 1; exit 1;
} }
...@@ -185,6 +189,5 @@ package syscall ...@@ -185,6 +189,5 @@ package syscall
import "unsafe" import "unsafe"
$text $text
EOF EOF
exit 0; exit 0;
...@@ -36,15 +36,15 @@ func NsecToTimeval(nsec int64) (tv Timeval) { ...@@ -36,15 +36,15 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
//sys Chown(path string, uid int, gid int) (errno int) //sys Chown(path string, uid int, gid int) (errno int)
//sys Fchown(fd int, uid int, gid int) (errno int) //sys Fchown(fd int, uid int, gid int) (errno int)
//sys Fstat(fd int, stat *Stat_t) (errno int) //sys Fstat(fd int, stat *Stat_t) (errno int) = SYS_FSTAT64
//sys Fstatfs(fd int, buf *Statfs_t) (errno int) //sys Fstatfs(fd int, buf *Statfs_t) (errno int) = SYS_FSTATFS64
//sys Getegid() (egid int) //sys Getegid() (egid int)
//sys Geteuid() (euid int) //sys Geteuid() (euid int)
//sys Getgid() (gid int) //sys Getgid() (gid int)
//sys Getuid() (uid int) //sys Getuid() (uid int)
//sys Lchown(path string, uid int, gid int) (errno int) //sys Lchown(path string, uid int, gid int) (errno int)
//sys Listen(s int, n int) (errno int) //sys Listen(s int, n int) (errno int)
//sys Lstat(path string, stat *Stat_t) (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 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 Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, errno int) = SYS__NEWSELECT
//sys Setfsgid(gid int) (errno int) //sys Setfsgid(gid int) (errno int)
...@@ -55,8 +55,8 @@ func NsecToTimeval(nsec int64) (tv Timeval) { ...@@ -55,8 +55,8 @@ func NsecToTimeval(nsec int64) (tv Timeval) {
//sys Setresuid(ruid int, euid int, suid int) (errno int) //sys Setresuid(ruid int, euid int, suid int) (errno int)
//sys Setreuid(ruid int, euid int) (errno int) //sys Setreuid(ruid int, euid int) (errno int)
//sys Shutdown(fd int, how int) (errno int) //sys Shutdown(fd int, how int) (errno int)
//sys Stat(path string, stat *Stat_t) (errno int) //sys Stat(path string, stat *Stat_t) (errno int) = SYS_STAT64
//sys Statfs(path string, buf *Statfs_t) (errno int) //sys Statfs(path string, buf *Statfs_t) (errno int) = SYS_STATFS64
// TODO(kaib): add support for tracing // TODO(kaib): add support for tracing
func (r *PtraceRegs) PC() uint64 { return 0 } func (r *PtraceRegs) PC() uint64 { return 0 }
......
...@@ -680,13 +680,13 @@ func Fchown(fd int, uid int, gid int) (errno int) { ...@@ -680,13 +680,13 @@ func Fchown(fd int, uid int, gid int) (errno int) {
} }
func Fstat(fd int, stat *Stat_t) (errno int) { func Fstat(fd int, stat *Stat_t) (errno int) {
_, _, e1 := Syscall(SYS_FSTAT, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0) _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
errno = int(e1) errno = int(e1)
return return
} }
func Fstatfs(fd int, buf *Statfs_t) (errno int) { func Fstatfs(fd int, buf *Statfs_t) (errno int) {
_, _, e1 := Syscall(SYS_FSTATFS, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0) _, _, e1 := Syscall(SYS_FSTATFS64, uintptr(fd), uintptr(unsafe.Pointer(buf)), 0)
errno = int(e1) errno = int(e1)
return return
} }
...@@ -728,7 +728,7 @@ func Listen(s int, n int) (errno int) { ...@@ -728,7 +728,7 @@ func Listen(s int, n int) (errno int) {
} }
func Lstat(path string, stat *Stat_t) (errno int) { func Lstat(path string, stat *Stat_t) (errno int) {
_, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(stat)), 0) _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(stat)), 0)
errno = int(e1) errno = int(e1)
return return
} }
...@@ -796,13 +796,13 @@ func Shutdown(fd int, how int) (errno int) { ...@@ -796,13 +796,13 @@ func Shutdown(fd int, how int) (errno int) {
} }
func Stat(path string, stat *Stat_t) (errno int) { func Stat(path string, stat *Stat_t) (errno int) {
_, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(stat)), 0) _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(stat)), 0)
errno = int(e1) errno = int(e1)
return return
} }
func Statfs(path string, buf *Statfs_t) (errno int) { func Statfs(path string, buf *Statfs_t) (errno int) {
_, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(buf)), 0) _, _, e1 := Syscall(SYS_STATFS64, uintptr(unsafe.Pointer(StringBytePtr(path))), uintptr(unsafe.Pointer(buf)), 0)
errno = int(e1) errno = int(e1)
return return
} }
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