Patchwork [gccgo] Fix Syscall types

login
register
mail settings
Submitter Ian Taylor
Date July 2, 2010, 2:55 p.m.
Message ID <mcrmxuakk6s.fsf@google.com>
Download mbox | patch
Permalink /patch/57668/
State New
Headers show

Comments

Ian Taylor - July 2, 2010, 2:55 p.m.
This patch from Christopher Wedgwood fixes the types used by the
Syscall function.  I messed it up such that it always used 32-bit types
on 64-bit systems.  Committed to gccgo branch.

Ian

Patch

diff -r 4421ae82aa69 libgo/syscalls/syscall.go
--- a/libgo/syscalls/syscall.go	Fri Jul 02 07:42:23 2010 -0700
+++ b/libgo/syscalls/syscall.go	Fri Jul 02 07:52:08 2010 -0700
@@ -18,13 +18,12 @@ 
 func libc_syscall32(trap int32, a1, a2, a3, a4, a5, a6 int32) int32 __asm__ ("syscall");
 func libc_syscall64(trap int64, a1, a2, a3, a4, a5, a6 int64) int64 __asm__ ("syscall");
 
-// Do a system call.  We look at the size of int to see how to pass
+// 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, err uintptr) {
   var r uintptr;
-  var i int;
-  if unsafe.Sizeof(i) == 4 {
+  if unsafe.Sizeof(r) == 4 {
     r1 := libc_syscall32(int32(trap), int32(a1), int32(a2), int32(a3), 0, 0, 0);
     r = uintptr(r1);
   } else {
@@ -36,8 +35,7 @@ 
 
 func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) {
   var r uintptr;
-  var i int;
-  if unsafe.Sizeof(i) == 4 {
+  if unsafe.Sizeof(r) == 4 {
     r1 := libc_syscall32(int32(trap), int32(a1), int32(a2), int32(a3),
     			 int32(a4), int32(a5), int32(a6));
     r = uintptr(r1);