unix: support compiling with gccgo on linux/386

Implement socketcall and rawsocketcall in addition to seek (already
introduced in CL 100076) to support compiling with gccgo on linux/386

Change-Id: Iaa51aa159a4743ae0e394f541ff196e2d28aa27f
Reviewed-on: https://go-review.googlesource.com/117697
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
diff --git a/unix/syscall_linux_386.go b/unix/syscall_linux_386.go
index bb8e4fb..f17872f 100644
--- a/unix/syscall_linux_386.go
+++ b/unix/syscall_linux_386.go
@@ -10,7 +10,6 @@
 package unix
 
 import (
-	"syscall"
 	"unsafe"
 )
 
@@ -157,10 +156,6 @@
 	return setrlimit(resource, &rl)
 }
 
-// Underlying system call writes to newoffset via pointer.
-// Implemented in assembly to avoid allocation.
-func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
-
 func Seek(fd int, offset int64, whence int) (newoffset int64, err error) {
 	newoffset, errno := seek(fd, offset, whence)
 	if errno != 0 {
@@ -206,9 +201,6 @@
 	_SENDMMSG    = 20
 )
 
-func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
-func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
-
 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
 	fd, e := socketcall(_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), 0, 0, 0)
 	if e != 0 {
diff --git a/unix/syscall_linux_gc_386.go b/unix/syscall_linux_gc_386.go
new file mode 100644
index 0000000..070bd38
--- /dev/null
+++ b/unix/syscall_linux_gc_386.go
@@ -0,0 +1,16 @@
+// 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.
+
+// +build linux,!gccgo,386
+
+package unix
+
+import "syscall"
+
+// Underlying system call writes to newoffset via pointer.
+// Implemented in assembly to avoid allocation.
+func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno)
+
+func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
+func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (n int, err syscall.Errno)
diff --git a/unix/syscall_linux_gccgo.go b/unix/syscall_linux_gccgo.go
deleted file mode 100644
index df9c123..0000000
--- a/unix/syscall_linux_gccgo.go
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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.
-
-// +build linux
-// +build gccgo
-// +build 386 arm
-
-package unix
-
-import (
-	"syscall"
-	"unsafe"
-)
-
-func seek(fd int, offset int64, whence int) (newoffset int64, err syscall.Errno) {
-	offsetLow := uint32(offset & 0xffffffff)
-	offsetHigh := uint32((offset >> 32) & 0xffffffff)
-	_, _, err = Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
-	return newoffset, err
-}
diff --git a/unix/syscall_linux_gccgo_386.go b/unix/syscall_linux_gccgo_386.go
new file mode 100644
index 0000000..308eb7a
--- /dev/null
+++ b/unix/syscall_linux_gccgo_386.go
@@ -0,0 +1,30 @@
+// 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.
+
+// +build linux,gccgo,386
+
+package unix
+
+import (
+	"syscall"
+	"unsafe"
+)
+
+func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
+	var newoffset int64
+	offsetLow := uint32(offset & 0xffffffff)
+	offsetHigh := uint32((offset >> 32) & 0xffffffff)
+	_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
+	return newoffset, err
+}
+
+func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) {
+	fd, _, err := Syscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0)
+	return int(fd), err
+}
+
+func rawsocketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) {
+	fd, _, err := RawSyscall(SYS_SOCKETCALL, uintptr(call), uintptr(unsafe.Pointer(&a0)), 0)
+	return int(fd), err
+}
diff --git a/unix/syscall_linux_gccgo_arm.go b/unix/syscall_linux_gccgo_arm.go
new file mode 100644
index 0000000..aa7fc9e
--- /dev/null
+++ b/unix/syscall_linux_gccgo_arm.go
@@ -0,0 +1,20 @@
+// 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.
+
+// +build linux,gccgo,arm
+
+package unix
+
+import (
+	"syscall"
+	"unsafe"
+)
+
+func seek(fd int, offset int64, whence int) (int64, syscall.Errno) {
+	var newoffset int64
+	offsetLow := uint32(offset & 0xffffffff)
+	offsetHigh := uint32((offset >> 32) & 0xffffffff)
+	_, _, err := Syscall6(SYS__LLSEEK, uintptr(fd), uintptr(offsetHigh), uintptr(offsetLow), uintptr(unsafe.Pointer(&newoffset)), uintptr(whence), 0)
+	return newoffset, err
+}