github.com/hxx258456/ccgo@v0.0.5-0.20230213014102-48b35f46f66f/net/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 "syscall" 9 "unsafe" 10 ) 11 12 func syscall_syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) 13 func syscall_syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) 14 15 func probeProtocolStack() int { 16 return 4 // sizeof(int) on GOOS=zos GOARCH=s390x 17 } 18 19 func getsockopt(s uintptr, level, name int, b []byte) (int, error) { 20 l := uint32(len(b)) 21 _, _, errno := syscall_syscall6(syscall.SYS_GETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(unsafe.Pointer(&l)), 0) 22 return int(l), errnoErr(errno) 23 } 24 25 func setsockopt(s uintptr, level, name int, b []byte) error { 26 _, _, errno := syscall_syscall6(syscall.SYS_SETSOCKOPT, s, uintptr(level), uintptr(name), uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), 0) 27 return errnoErr(errno) 28 } 29 30 func recvmsg(s uintptr, h *msghdr, flags int) (int, error) { 31 n, _, errno := syscall_syscall(syscall.SYS___RECVMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) 32 return int(n), errnoErr(errno) 33 } 34 35 func sendmsg(s uintptr, h *msghdr, flags int) (int, error) { 36 n, _, errno := syscall_syscall(syscall.SYS___SENDMSG_A, s, uintptr(unsafe.Pointer(h)), uintptr(flags)) 37 return int(n), errnoErr(errno) 38 }