Source file
src/syscall/syscall_illumos.go
1
2
3
4
5
6
7
8
9 package syscall
10
11 import "unsafe"
12
13
14
15
16
17
18
19 var (
20 procAccept4,
21 procFlock libcFunc
22 )
23
24 func Accept4(fd int, flags int) (int, Sockaddr, error) {
25 var rsa RawSockaddrAny
26 var addrlen _Socklen = SizeofSockaddrAny
27 nfd, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procAccept4)), 4, uintptr(fd), uintptr(unsafe.Pointer(&rsa)), uintptr(unsafe.Pointer(&addrlen)), uintptr(flags), 0, 0)
28 if errno != 0 {
29 return 0, nil, errno
30 }
31 if addrlen > SizeofSockaddrAny {
32 panic("RawSockaddrAny too small")
33 }
34 sa, err := anyToSockaddr(&rsa)
35 if err != nil {
36 Close(int(nfd))
37 return 0, nil, err
38 }
39 return int(nfd), sa, nil
40 }
41
42 func Flock(fd int, how int) error {
43 _, _, errno := sysvicall6(uintptr(unsafe.Pointer(&procFlock)), 2, uintptr(fd), uintptr(how), 0, 0, 0, 0)
44 if errno != 0 {
45 return errno
46 }
47 return nil
48 }
49
View as plain text