Commit ad73de2f authored by Giles Lean's avatar Giles Lean Committed by Russ Cox

syscall: Create syscall_bsd.go for code used by Darwin and other *BSDs

In this change I'd like to combine the common code that is
present in syscall_darwin.go and syscall_freebsd.go.  I
have three reasons for wanting to do this now:

1. reducing code duplication is nearly always good :-)
2. the duplication will get worse if I duplicate this code
   a third time for the NetBSD port I'm working on, which
   I need to do almost immediately
3. by making this change all in one lump and ignoring any
   commonality with the syscall_linux*.go files the diff
   is long but, I think, readable

In future it may be possible to cherry pick functions that
also apply to Linux and put them in (say) syscall_unix.go,
and of course some functions may diverge in future and have
to move out to OS or architecture specific files, but today
I want just the low hanging fruit.

Tested and passed on:

  Darwin (Snow Leopard, 10.6): amd64 and 386
  FreeBSD (8.0-RELEASE):       386 only(*)

(*) All my virtualisation software has stopped playing nice
with FreeBSD for the moment, so I don't have facilities to
test the amd64 port.  As the OS X port is OK and the diff
looks all right to my eyes I shall keep my fingers crossed.
If someone with a FreeBSD/amd64 system cares to test and
report I would be appreciative.

2010-03-27 update: I have replaced my virtualisation software, and have working FreeBSD/i386 and FreeBSD/amd64 virtual machines again.

As I hoped (and expected -- programmers are optimists :-) the code built and passed all but the two currently known to fail tests on FreeBSD/amd64. I rechecked FreeBSD/i386 too: same results.

R=rsc
CC=golang-dev
https://golang.org/cl/751041
parent d0ffee8a
......@@ -18,9 +18,11 @@ GOFILES=\
ztypes_$(GOOS)_$(GOARCH).go\
GOFILES_freebsd=\
syscall_bsd.go\
syscall_unix.go\
GOFILES_darwin=\
syscall_bsd.go\
syscall_unix.go\
GOFILES_linux=\
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// mksyscall.sh -l32 syscall_darwin.go syscall_darwin_386.go
// mksyscall.sh -l32 syscall_bsd.go syscall_darwin.go syscall_darwin_386.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
......@@ -121,15 +121,15 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
return
}
func kill(pid int, signum int, posix int) (errno int) {
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
func fcntl(fd int, cmd int, arg int) (val int, errno int) {
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
errno = int(e1)
return
}
func fcntl(fd int, cmd int, arg int) (val int, errno int) {
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
func kill(pid int, signum int, posix int) (errno int) {
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
errno = int(e1)
return
}
......
// mksyscall.sh syscall_darwin.go syscall_darwin_amd64.go
// mksyscall.sh syscall_bsd.go syscall_darwin.go syscall_darwin_amd64.go
// MACHINE GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
package syscall
......@@ -121,15 +121,15 @@ func sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr)
return
}
func kill(pid int, signum int, posix int) (errno int) {
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
func fcntl(fd int, cmd int, arg int) (val int, errno int) {
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
errno = int(e1)
return
}
func fcntl(fd int, cmd int, arg int) (val int, errno int) {
r0, _, e1 := Syscall(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg))
val = int(r0)
func kill(pid int, signum int, posix int) (errno int) {
_, _, e1 := Syscall(SYS_KILL, uintptr(pid), uintptr(signum), uintptr(posix))
errno = int(e1)
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