summaryrefslogtreecommitdiff
path: root/src/pkg/syscall
diff options
context:
space:
mode:
authorIvan Krasin <krasin@golang.org>2010-06-30 14:58:21 -0700
committerIvan Krasin <krasin@golang.org>2010-06-30 14:58:21 -0700
commitf73da39896bc9a09088ed4fe090d7b6308f80da5 (patch)
treea8d665682fa6b78ec2d52e624bff27c98c6dfd1f /src/pkg/syscall
parent16234d0566433f78d7c8fee2f6200685f5250a9b (diff)
downloadgolang-f73da39896bc9a09088ed4fe090d7b6308f80da5.tar.gz
syscall: add socketpair
R=rsc CC=golang-dev http://codereview.appspot.com/1319042 Committer: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/pkg/syscall')
-rw-r--r--src/pkg/syscall/syscall_bsd.go5
-rw-r--r--src/pkg/syscall/syscall_linux.go5
-rw-r--r--src/pkg/syscall/syscall_linux_386.go7
-rw-r--r--src/pkg/syscall/zsyscall_darwin_386.go9
-rw-r--r--src/pkg/syscall/zsyscall_darwin_amd64.go8
-rw-r--r--src/pkg/syscall/zsyscall_freebsd_386.go8
-rw-r--r--src/pkg/syscall/zsyscall_freebsd_amd64.go9
-rw-r--r--src/pkg/syscall/zsyscall_linux_amd64.go8
-rw-r--r--src/pkg/syscall/zsyscall_linux_arm.go8
9 files changed, 67 insertions, 0 deletions
diff --git a/src/pkg/syscall/syscall_bsd.go b/src/pkg/syscall/syscall_bsd.go
index c773daa7c..14dfab153 100644
--- a/src/pkg/syscall/syscall_bsd.go
+++ b/src/pkg/syscall/syscall_bsd.go
@@ -323,6 +323,11 @@ func Socket(domain, typ, proto int) (fd, errno int) {
return
}
+func Socketpair(domain, typ, proto int) (fd [2]int, errno int) {
+ fd, errno = socketpair(domain, typ, proto)
+ return
+}
+
func SetsockoptInt(fd, level, opt int, value int) (errno int) {
var n = int32(value)
return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), 4)
diff --git a/src/pkg/syscall/syscall_linux.go b/src/pkg/syscall/syscall_linux.go
index bf124bd13..2ce3c0882 100644
--- a/src/pkg/syscall/syscall_linux.go
+++ b/src/pkg/syscall/syscall_linux.go
@@ -368,6 +368,11 @@ func Socket(domain, typ, proto int) (fd, errno int) {
return
}
+func Socketpair(domain, typ, proto int) (fd [2]int, errno int) {
+ fd, errno = socketpair(domain, typ, proto)
+ return
+}
+
func SetsockoptInt(fd, level, opt int, value int) (errno int) {
var n = int32(value)
return setsockopt(fd, level, opt, uintptr(unsafe.Pointer(&n)), 4)
diff --git a/src/pkg/syscall/syscall_linux_386.go b/src/pkg/syscall/syscall_linux_386.go
index 4dfaddc43..4a2e92f0a 100644
--- a/src/pkg/syscall/syscall_linux_386.go
+++ b/src/pkg/syscall/syscall_linux_386.go
@@ -100,6 +100,13 @@ func getpeername(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, errno = socketcall(_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ return
+}
+
func bind(s int, addr uintptr, addrlen _Socklen) (errno int) {
_, errno = socketcall(_BIND, uintptr(s), uintptr(addr), uintptr(addrlen), 0, 0, 0)
return
diff --git a/src/pkg/syscall/zsyscall_darwin_386.go b/src/pkg/syscall/zsyscall_darwin_386.go
index 6e46cfbc4..78e21ca44 100644
--- a/src/pkg/syscall/zsyscall_darwin_386.go
+++ b/src/pkg/syscall/zsyscall_darwin_386.go
@@ -59,6 +59,15 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
+
func setsockopt(s int, level int, name int, val uintptr, vallen int) (errno int) {
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
errno = int(e1)
diff --git a/src/pkg/syscall/zsyscall_darwin_amd64.go b/src/pkg/syscall/zsyscall_darwin_amd64.go
index cb963171a..96a4bd0f0 100644
--- a/src/pkg/syscall/zsyscall_darwin_amd64.go
+++ b/src/pkg/syscall/zsyscall_darwin_amd64.go
@@ -59,6 +59,14 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
func setsockopt(s int, level int, name int, val uintptr, vallen int) (errno int) {
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
errno = int(e1)
diff --git a/src/pkg/syscall/zsyscall_freebsd_386.go b/src/pkg/syscall/zsyscall_freebsd_386.go
index 96e9da6a4..611beacf6 100644
--- a/src/pkg/syscall/zsyscall_freebsd_386.go
+++ b/src/pkg/syscall/zsyscall_freebsd_386.go
@@ -59,6 +59,14 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
func setsockopt(s int, level int, name int, val uintptr, vallen int) (errno int) {
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
errno = int(e1)
diff --git a/src/pkg/syscall/zsyscall_freebsd_amd64.go b/src/pkg/syscall/zsyscall_freebsd_amd64.go
index c45e6fe35..f6c050ee5 100644
--- a/src/pkg/syscall/zsyscall_freebsd_amd64.go
+++ b/src/pkg/syscall/zsyscall_freebsd_amd64.go
@@ -59,6 +59,15 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
+
func setsockopt(s int, level int, name int, val uintptr, vallen int) (errno int) {
_, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
errno = int(e1)
diff --git a/src/pkg/syscall/zsyscall_linux_amd64.go b/src/pkg/syscall/zsyscall_linux_amd64.go
index b57296a54..87e545987 100644
--- a/src/pkg/syscall/zsyscall_linux_amd64.go
+++ b/src/pkg/syscall/zsyscall_linux_amd64.go
@@ -786,6 +786,14 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (errno int) {
_, _, e1 := Syscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
errno = int(e1)
diff --git a/src/pkg/syscall/zsyscall_linux_arm.go b/src/pkg/syscall/zsyscall_linux_arm.go
index 7e872ce3d..36ff34294 100644
--- a/src/pkg/syscall/zsyscall_linux_arm.go
+++ b/src/pkg/syscall/zsyscall_linux_arm.go
@@ -628,6 +628,14 @@ func socket(domain int, typ int, proto int) (fd int, errno int) {
return
}
+func socketpair(domain int, typ int, proto int) (fd [2]int, errno int) {
+ var f [2]int
+ _, _, e1 := Syscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(&f)), 0, 0)
+ fd = f
+ errno = int(e1)
+ return
+}
+
func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (errno int) {
_, _, e1 := Syscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
errno = int(e1)