golang.org/x/net@v0.25.1-0.20240516223405-c87a5b62e243/internal/socket/sys_zos_s390x.go (about) 1 // Copyright 2020 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package socket 6 7 import ( 8 "net" 9 "syscall" 10 "unsafe" 11 ) 12 13 func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 func syscall_syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 15 16 func probeProtocolStack() int { 17 return 4 // sizeof(int) on GOOS=zos GOARCH=s390x 18 } 19 20 func getsockopt(s uintptr, level, name int, b []byte) (int, error) { 21 l := uint32(len(b)) 22 _, _, errno := syscall_syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) 23 return int(l), errnoErr(errno) 24 } 25 26 func setsockopt(s uintptr, level, name int, b []byte) error { 27 _, _, errno := syscall_syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) 28 return errnoErr(errno) 29 } 30 31 func recvmsg(s uintptr, buffers [][]byte, oob []byte, flags int, network string) (n, oobn int, recvflags int, from net.Addr, err error) { 32 var h msghdr 33 vs := make([]iovec, len(buffers)) 34 var sa []byte 35 if network != "tcp" { 36 sa = make([]byte, sizeofSockaddrInet6) 37 } 38 h.pack(vs, buffers, oob, sa) 39 sn, _, errno := syscall_syscall(syscall.SYS___RECVMSG_A, s, uintptr(unsafe.Pointer(&h)), uintptr(flags)) 40 n = int(sn) 41 oobn = h.controllen() 42 recvflags = h.flags() 43 err = errnoErr(errno) 44 if network != "tcp" { 45 var err2 error 46 from, err2 = parseInetAddr(sa, network) 47 if err2 != nil && err == nil { 48 err = err2 49 } 50 } 51 return 52 } 53 54 func sendmsg(s uintptr, buffers [][]byte, oob []byte, to net.Addr, flags int) (int, error) { 55 var h msghdr 56 vs := make([]iovec, len(buffers)) 57 var sa []byte 58 if to != nil { 59 var a [sizeofSockaddrInet6]byte 60 n := marshalInetAddr(to, a[:]) 61 sa = a[:n] 62 } 63 h.pack(vs, buffers, oob, sa) 64 n, _, errno := syscall_syscall(syscall.SYS___SENDMSG_A, s, uintptr(unsafe.Pointer(&h)), uintptr(flags)) 65 return int(n), errnoErr(errno) 66 }