// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
package poll
// This file implements accept for platforms that provide a fast path for
// setting SetNonblock and CloseOnExec.
-//go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
package poll
// This file implements accept for platforms that do not provide a fast path for
// setting SetNonblock and CloseOnExec.
-//go:build aix || darwin || (js && wasm) || (solaris && !illumos)
+//go:build aix || darwin || (js && wasm)
package poll
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
package socktest
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
-//go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
package net
// This file implements sysSocket for platforms that provide a fast path for
// setting SetNonblock and CloseOnExec.
-//go:build dragonfly || freebsd || illumos || linux || netbsd || openbsd
+//go:build dragonfly || freebsd || linux || netbsd || openbsd || solaris
package net
// This file implements sysSocket for platforms that do not provide a fast path
// for setting SetNonblock and CloseOnExec.
-//go:build aix || darwin || (solaris && !illumos)
+//go:build aix || darwin
package net
#cgo openbsd LDFLAGS: -lpthread
#cgo aix LDFLAGS: -Wl,-berok
#cgo solaris LDFLAGS: -lxnet
-#cgo illumos LDFLAGS: -lsocket
+#cgo solaris LDFLAGS: -lsocket
#cgo CFLAGS: -Wall -Werror
import "unsafe"
-//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
//go:cgo_import_dynamic libc_flock flock "libc.so"
-//go:linkname procAccept4 libc_accept4
//go:linkname procFlock libc_flock
-var (
- procAccept4,
- procFlock libcFunc
-)
-
-func Accept4(fd int, flags int) (int, Sockaddr, error) {
- var rsa RawSockaddrAny
- var addrlen _Socklen = SizeofSockaddrAny
- nfd, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procAccept4)), 4, uintptr(fd), uintptr(unsafe.Pointer(&rsa)), uintptr(unsafe.Pointer(&addrlen)), uintptr(flags), 0, 0)
- if errno != 0 {
- return 0, nil, errno
- }
- if addrlen > SizeofSockaddrAny {
- panic("RawSockaddrAny too small")
- }
- sa, err := anyToSockaddr(&rsa)
- if err != nil {
- Close(int(nfd))
- return 0, nil, err
- }
- return int(nfd), sa, nil
-}
+var procFlock libcFunc
func Flock(fd int, how int) error {
_, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0)
return err
}
+//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
+
+func Accept4(fd int, flags int) (int, Sockaddr, error) {
+ var rsa RawSockaddrAny
+ var addrlen _Socklen = SizeofSockaddrAny
+ nfd, err := accept4(fd, &rsa, &addrlen, flags)
+ if err != nil {
+ return 0, nil, err
+ }
+ if addrlen > SizeofSockaddrAny {
+ panic("RawSockaddrAny too small")
+ }
+ sa, err := anyToSockaddr(&rsa)
+ if err != nil {
+ Close(nfd)
+ return 0, nil, err
+ }
+ return nfd, sa, nil
+}
+
func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
if sa.Port < 0 || sa.Port > 0xFFFF {
return nil, 0, EINVAL
import "unsafe"
//go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so"
+//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so"
//go:cgo_import_dynamic libc_Getcwd getcwd "libc.so"
//go:cgo_import_dynamic libc_getgroups getgroups "libc.so"
//go:cgo_import_dynamic libc_setgroups setgroups "libc.so"
//go:cgo_import_dynamic libc_utimensat utimensat "libc.so"
//go:linkname libc_pipe2 libc_pipe2
+//go:linkname libc_accept4 libc_accept4
//go:linkname libc_Getcwd libc_Getcwd
//go:linkname libc_getgroups libc_getgroups
//go:linkname libc_setgroups libc_setgroups
var (
libc_pipe2,
+ libc_accept4,
libc_Getcwd,
libc_getgroups,
libc_setgroups,
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
+ r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&libc_accept4)), 4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
+ fd = int(r0)
+ if e1 != 0 {
+ err = errnoErr(e1)
+ }
+ return
+}
+
+// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
+
func Getcwd(buf []byte) (n int, err error) {
var _p0 *byte
if len(buf) > 0 {