Browse Source
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.0.0-20190626221950-04f50cda93cb to 0.1.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](https://github.com/golang/sys/commits/v0.1.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production ... Signed-off-by: dependabot[bot] <support@github.com>dependabot/go_modules/golang.org/x/sys-0.1.0
dependabot[bot]
1 year ago
committed by
GitHub
362 changed files with 83360 additions and 111944 deletions
@ -1,3 +0,0 @@ |
|||
# This source code refers to The Go Authors for copyright purposes. |
|||
# The master list of authors is in the main Go distribution, |
|||
# visible at http://tip.golang.org/AUTHORS. |
@ -1,3 +0,0 @@ |
|||
# This source code was written by the Go contributors. |
|||
# The master list of contributors is in the main Go distribution, |
|||
# visible at http://tip.golang.org/CONTRIBUTORS. |
@ -0,0 +1,30 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// Package unsafeheader contains header declarations for the Go runtime's
|
|||
// slice and string implementations.
|
|||
//
|
|||
// This package allows x/sys to use types equivalent to
|
|||
// reflect.SliceHeader and reflect.StringHeader without introducing
|
|||
// a dependency on the (relatively heavy) "reflect" package.
|
|||
package unsafeheader |
|||
|
|||
import ( |
|||
"unsafe" |
|||
) |
|||
|
|||
// Slice is the runtime representation of a slice.
|
|||
// It cannot be used safely or portably and its representation may change in a later release.
|
|||
type Slice struct { |
|||
Data unsafe.Pointer |
|||
Len int |
|||
Cap int |
|||
} |
|||
|
|||
// String is the runtime representation of a string.
|
|||
// It cannot be used safely or portably and its representation may change in a later release.
|
|||
type String struct { |
|||
Data unsafe.Pointer |
|||
Len int |
|||
} |
@ -0,0 +1,29 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
//go:build (darwin || dragonfly || freebsd || netbsd || openbsd) && gc |
|||
// +build darwin dragonfly freebsd netbsd openbsd |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// System call support for AMD64 BSD |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,15 +1,14 @@ |
|||
// Copyright 2015 The Go Authors. All rights reserved. |
|||
// Copyright 2021 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
// +build arm,darwin |
|||
//go:build (freebsd || netbsd || openbsd) && gc |
|||
// +build freebsd netbsd openbsd |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM, Darwin |
|||
// |
|||
// System call support for ARM BSD |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
@ -1,14 +1,14 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Copyright 2021 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
//go:build (darwin || freebsd || netbsd || openbsd) && gc |
|||
// +build darwin freebsd netbsd openbsd |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, OpenBSD |
|||
// |
|||
// System call support for ARM64 BSD |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
@ -1,13 +1,15 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Copyright 2022 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
//go:build (darwin || freebsd || netbsd || openbsd) && gc |
|||
// +build darwin freebsd netbsd openbsd |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, NetBSD |
|||
// System call support for ppc64, BSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
@ -1,14 +1,14 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Copyright 2021 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
//go:build (darwin || freebsd || netbsd || openbsd) && gc |
|||
// +build darwin freebsd netbsd openbsd |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, Darwin |
|||
// |
|||
// System call support for RISCV64 BSD |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
@ -1,29 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for 386, Darwin |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,30 +0,0 @@ |
|||
// Copyright 2015 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
// +build arm64,darwin |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, Darwin |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
B syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
B syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
B syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
B syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
B syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, DragonFly |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for 386, FreeBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for AMD64, FreeBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2012 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM, FreeBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
B syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
B syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
B syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2018 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM64, FreeBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·RawSyscall6(SB) |
@ -0,0 +1,54 @@ |
|||
// Copyright 2022 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
//go:build linux && loong64 && gc |
|||
// +build linux |
|||
// +build loong64 |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·SyscallNoError(SB),NOSPLIT,$0-48 |
|||
JAL runtime·entersyscall(SB) |
|||
MOVV a1+8(FP), R4 |
|||
MOVV a2+16(FP), R5 |
|||
MOVV a3+24(FP), R6 |
|||
MOVV R0, R7 |
|||
MOVV R0, R8 |
|||
MOVV R0, R9 |
|||
MOVV trap+0(FP), R11 // syscall entry |
|||
SYSCALL |
|||
MOVV R4, r1+32(FP) |
|||
MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 |
|||
JAL runtime·exitsyscall(SB) |
|||
RET |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
JMP syscall·RawSyscall6(SB) |
|||
|
|||
TEXT ·RawSyscallNoError(SB),NOSPLIT,$0-48 |
|||
MOVV a1+8(FP), R4 |
|||
MOVV a2+16(FP), R5 |
|||
MOVV a3+24(FP), R6 |
|||
MOVV R0, R7 |
|||
MOVV R0, R8 |
|||
MOVV R0, R9 |
|||
MOVV trap+0(FP), R11 // syscall entry |
|||
SYSCALL |
|||
MOVV R4, r1+32(FP) |
|||
MOVV R0, r2+40(FP) // r2 is not used. Always set to 0 |
|||
RET |
@ -1,29 +0,0 @@ |
|||
// Copyright 2013 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM, NetBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
B syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
B syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
B syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2019 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM64, NetBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-56 |
|||
B syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-80 |
|||
B syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-104 |
|||
B syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-56 |
|||
B syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 |
|||
B syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for 386, OpenBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
JMP syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
JMP syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
JMP syscall·RawSyscall6(SB) |
@ -1,29 +0,0 @@ |
|||
// Copyright 2017 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
// +build !gccgo |
|||
|
|||
#include "textflag.h" |
|||
|
|||
// |
|||
// System call support for ARM, OpenBSD |
|||
// |
|||
|
|||
// Just jump to package syscall's implementation for all these functions. |
|||
// The runtime may know about them. |
|||
|
|||
TEXT ·Syscall(SB),NOSPLIT,$0-28 |
|||
B syscall·Syscall(SB) |
|||
|
|||
TEXT ·Syscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·Syscall6(SB) |
|||
|
|||
TEXT ·Syscall9(SB),NOSPLIT,$0-52 |
|||
B syscall·Syscall9(SB) |
|||
|
|||
TEXT ·RawSyscall(SB),NOSPLIT,$0-28 |
|||
B syscall·RawSyscall(SB) |
|||
|
|||
TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 |
|||
B syscall·RawSyscall6(SB) |
@ -0,0 +1,426 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved. |
|||
// Use of this source code is governed by a BSD-style |
|||
// license that can be found in the LICENSE file. |
|||
|
|||
//go:build zos && s390x && gc |
|||
// +build zos |
|||
// +build s390x |
|||
// +build gc |
|||
|
|||
#include "textflag.h" |
|||
|
|||
#define PSALAA 1208(R0) |
|||
#define GTAB64(x) 80(x) |
|||
#define LCA64(x) 88(x) |
|||
#define CAA(x) 8(x) |
|||
#define EDCHPXV(x) 1016(x) // in the CAA |
|||
#define SAVSTACK_ASYNC(x) 336(x) // in the LCA |
|||
|
|||
// SS_*, where x=SAVSTACK_ASYNC |
|||
#define SS_LE(x) 0(x) |
|||
#define SS_GO(x) 8(x) |
|||
#define SS_ERRNO(x) 16(x) |
|||
#define SS_ERRNOJR(x) 20(x) |
|||
|
|||
#define LE_CALL BYTE $0x0D; BYTE $0x76; // BL R7, R6 |
|||
|
|||
TEXT ·clearErrno(SB),NOSPLIT,$0-0 |
|||
BL addrerrno<>(SB) |
|||
MOVD $0, 0(R3) |
|||
RET |
|||
|
|||
// Returns the address of errno in R3. |
|||
TEXT addrerrno<>(SB),NOSPLIT|NOFRAME,$0-0 |
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get __errno FuncDesc. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
ADD $(0x156*16), R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Switch to saved LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Call __errno function. |
|||
LE_CALL |
|||
NOPH |
|||
|
|||
// Switch back to Go stack. |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
RET |
|||
|
|||
TEXT ·syscall_syscall(SB),NOSPLIT,$0-56 |
|||
BL runtime·entersyscall(SB) |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+32(FP) |
|||
MOVD R0, r2+40(FP) |
|||
MOVD R0, err+48(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL addrerrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+48(FP) |
|||
done: |
|||
BL runtime·exitsyscall(SB) |
|||
RET |
|||
|
|||
TEXT ·syscall_rawsyscall(SB),NOSPLIT,$0-56 |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+32(FP) |
|||
MOVD R0, r2+40(FP) |
|||
MOVD R0, err+48(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL addrerrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+48(FP) |
|||
done: |
|||
RET |
|||
|
|||
TEXT ·syscall_syscall6(SB),NOSPLIT,$0-80 |
|||
BL runtime·entersyscall(SB) |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Fill in parameter list. |
|||
MOVD a4+32(FP), R12 |
|||
MOVD R12, (2176+24)(R4) |
|||
MOVD a5+40(FP), R12 |
|||
MOVD R12, (2176+32)(R4) |
|||
MOVD a6+48(FP), R12 |
|||
MOVD R12, (2176+40)(R4) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+56(FP) |
|||
MOVD R0, r2+64(FP) |
|||
MOVD R0, err+72(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL addrerrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+72(FP) |
|||
done: |
|||
BL runtime·exitsyscall(SB) |
|||
RET |
|||
|
|||
TEXT ·syscall_rawsyscall6(SB),NOSPLIT,$0-80 |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Fill in parameter list. |
|||
MOVD a4+32(FP), R12 |
|||
MOVD R12, (2176+24)(R4) |
|||
MOVD a5+40(FP), R12 |
|||
MOVD R12, (2176+32)(R4) |
|||
MOVD a6+48(FP), R12 |
|||
MOVD R12, (2176+40)(R4) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+56(FP) |
|||
MOVD R0, r2+64(FP) |
|||
MOVD R0, err+72(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL ·rrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+72(FP) |
|||
done: |
|||
RET |
|||
|
|||
TEXT ·syscall_syscall9(SB),NOSPLIT,$0 |
|||
BL runtime·entersyscall(SB) |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Fill in parameter list. |
|||
MOVD a4+32(FP), R12 |
|||
MOVD R12, (2176+24)(R4) |
|||
MOVD a5+40(FP), R12 |
|||
MOVD R12, (2176+32)(R4) |
|||
MOVD a6+48(FP), R12 |
|||
MOVD R12, (2176+40)(R4) |
|||
MOVD a7+56(FP), R12 |
|||
MOVD R12, (2176+48)(R4) |
|||
MOVD a8+64(FP), R12 |
|||
MOVD R12, (2176+56)(R4) |
|||
MOVD a9+72(FP), R12 |
|||
MOVD R12, (2176+64)(R4) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+80(FP) |
|||
MOVD R0, r2+88(FP) |
|||
MOVD R0, err+96(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL addrerrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+96(FP) |
|||
done: |
|||
BL runtime·exitsyscall(SB) |
|||
RET |
|||
|
|||
TEXT ·syscall_rawsyscall9(SB),NOSPLIT,$0 |
|||
MOVD a1+8(FP), R1 |
|||
MOVD a2+16(FP), R2 |
|||
MOVD a3+24(FP), R3 |
|||
|
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get function. |
|||
MOVD CAA(R8), R9 |
|||
MOVD EDCHPXV(R9), R9 |
|||
MOVD trap+0(FP), R5 |
|||
SLD $4, R5 |
|||
ADD R5, R9 |
|||
LMG 0(R9), R5, R6 |
|||
|
|||
// Restore LE stack. |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R4 |
|||
MOVD $0, 0(R9) |
|||
|
|||
// Fill in parameter list. |
|||
MOVD a4+32(FP), R12 |
|||
MOVD R12, (2176+24)(R4) |
|||
MOVD a5+40(FP), R12 |
|||
MOVD R12, (2176+32)(R4) |
|||
MOVD a6+48(FP), R12 |
|||
MOVD R12, (2176+40)(R4) |
|||
MOVD a7+56(FP), R12 |
|||
MOVD R12, (2176+48)(R4) |
|||
MOVD a8+64(FP), R12 |
|||
MOVD R12, (2176+56)(R4) |
|||
MOVD a9+72(FP), R12 |
|||
MOVD R12, (2176+64)(R4) |
|||
|
|||
// Call function. |
|||
LE_CALL |
|||
NOPH |
|||
XOR R0, R0 // Restore R0 to $0. |
|||
MOVD R4, 0(R9) // Save stack pointer. |
|||
|
|||
MOVD R3, r1+80(FP) |
|||
MOVD R0, r2+88(FP) |
|||
MOVD R0, err+96(FP) |
|||
MOVW R3, R4 |
|||
CMP R4, $-1 |
|||
BNE done |
|||
BL addrerrno<>(SB) |
|||
MOVWZ 0(R3), R3 |
|||
MOVD R3, err+96(FP) |
|||
done: |
|||
RET |
|||
|
|||
// func svcCall(fnptr unsafe.Pointer, argv *unsafe.Pointer, dsa *uint64) |
|||
TEXT ·svcCall(SB),NOSPLIT,$0 |
|||
BL runtime·save_g(SB) // Save g and stack pointer |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD R15, 0(R9) |
|||
|
|||
MOVD argv+8(FP), R1 // Move function arguments into registers |
|||
MOVD dsa+16(FP), g |
|||
MOVD fnptr+0(FP), R15 |
|||
|
|||
BYTE $0x0D // Branch to function |
|||
BYTE $0xEF |
|||
|
|||
BL runtime·load_g(SB) // Restore g and stack pointer |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
MOVD SAVSTACK_ASYNC(R8), R9 |
|||
MOVD 0(R9), R15 |
|||
|
|||
RET |
|||
|
|||
// func svcLoad(name *byte) unsafe.Pointer |
|||
TEXT ·svcLoad(SB),NOSPLIT,$0 |
|||
MOVD R15, R2 // Save go stack pointer |
|||
MOVD name+0(FP), R0 // Move SVC args into registers |
|||
MOVD $0x80000000, R1 |
|||
MOVD $0, R15 |
|||
BYTE $0x0A // SVC 08 LOAD |
|||
BYTE $0x08 |
|||
MOVW R15, R3 // Save return code from SVC |
|||
MOVD R2, R15 // Restore go stack pointer |
|||
CMP R3, $0 // Check SVC return code |
|||
BNE error |
|||
|
|||
MOVD $-2, R3 // Reset last bit of entry point to zero |
|||
AND R0, R3 |
|||
MOVD R3, addr+8(FP) // Return entry point returned by SVC |
|||
CMP R0, R3 // Check if last bit of entry point was set |
|||
BNE done |
|||
|
|||
MOVD R15, R2 // Save go stack pointer |
|||
MOVD $0, R15 // Move SVC args into registers (entry point still in r0 from SVC 08) |
|||
BYTE $0x0A // SVC 09 DELETE |
|||
BYTE $0x09 |
|||
MOVD R2, R15 // Restore go stack pointer |
|||
|
|||
error: |
|||
MOVD $0, addr+8(FP) // Return 0 on failure |
|||
done: |
|||
XOR R0, R0 // Reset r0 to 0 |
|||
RET |
|||
|
|||
// func svcUnload(name *byte, fnptr unsafe.Pointer) int64 |
|||
TEXT ·svcUnload(SB),NOSPLIT,$0 |
|||
MOVD R15, R2 // Save go stack pointer |
|||
MOVD name+0(FP), R0 // Move SVC args into registers |
|||
MOVD addr+8(FP), R15 |
|||
BYTE $0x0A // SVC 09 |
|||
BYTE $0x09 |
|||
XOR R0, R0 // Reset r0 to 0 |
|||
MOVD R15, R1 // Save SVC return code |
|||
MOVD R2, R15 // Restore go stack pointer |
|||
MOVD R1, rc+0(FP) // Return SVC return code |
|||
RET |
|||
|
|||
// func gettid() uint64 |
|||
TEXT ·gettid(SB), NOSPLIT, $0 |
|||
// Get library control area (LCA). |
|||
MOVW PSALAA, R8 |
|||
MOVD LCA64(R8), R8 |
|||
|
|||
// Get CEECAATHDID |
|||
MOVD CAA(R8), R9 |
|||
MOVD 0x3D0(R9), R9 |
|||
MOVD R9, ret+0(FP) |
|||
|
|||
RET |
@ -0,0 +1,29 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build zos && s390x
|
|||
// +build zos,s390x
|
|||
|
|||
// Functions to access/create device major and minor numbers matching the
|
|||
// encoding used by z/OS.
|
|||
//
|
|||
// The information below is extracted and adapted from <sys/stat.h> macros.
|
|||
|
|||
package unix |
|||
|
|||
// Major returns the major component of a z/OS device number.
|
|||
func Major(dev uint64) uint32 { |
|||
return uint32((dev >> 16) & 0x0000FFFF) |
|||
} |
|||
|
|||
// Minor returns the minor component of a z/OS device number.
|
|||
func Minor(dev uint64) uint32 { |
|||
return uint32(dev & 0x0000FFFF) |
|||
} |
|||
|
|||
// Mkdev returns a z/OS device number generated from the given major and minor
|
|||
// components.
|
|||
func Mkdev(major, minor uint32) uint64 { |
|||
return (uint64(major) << 16) | uint64(minor) |
|||
} |
@ -0,0 +1,221 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build zos && s390x
|
|||
// +build zos,s390x
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"sync" |
|||
) |
|||
|
|||
// This file simulates epoll on z/OS using poll.
|
|||
|
|||
// Analogous to epoll_event on Linux.
|
|||
// TODO(neeilan): Pad is because the Linux kernel expects a 96-bit struct. We never pass this to the kernel; remove?
|
|||
type EpollEvent struct { |
|||
Events uint32 |
|||
Fd int32 |
|||
Pad int32 |
|||
} |
|||
|
|||
const ( |
|||
EPOLLERR = 0x8 |
|||
EPOLLHUP = 0x10 |
|||
EPOLLIN = 0x1 |
|||
EPOLLMSG = 0x400 |
|||
EPOLLOUT = 0x4 |
|||
EPOLLPRI = 0x2 |
|||
EPOLLRDBAND = 0x80 |
|||
EPOLLRDNORM = 0x40 |
|||
EPOLLWRBAND = 0x200 |
|||
EPOLLWRNORM = 0x100 |
|||
EPOLL_CTL_ADD = 0x1 |
|||
EPOLL_CTL_DEL = 0x2 |
|||
EPOLL_CTL_MOD = 0x3 |
|||
// The following constants are part of the epoll API, but represent
|
|||
// currently unsupported functionality on z/OS.
|
|||
// EPOLL_CLOEXEC = 0x80000
|
|||
// EPOLLET = 0x80000000
|
|||
// EPOLLONESHOT = 0x40000000
|
|||
// EPOLLRDHUP = 0x2000 // Typically used with edge-triggered notis
|
|||
// EPOLLEXCLUSIVE = 0x10000000 // Exclusive wake-up mode
|
|||
// EPOLLWAKEUP = 0x20000000 // Relies on Linux's BLOCK_SUSPEND capability
|
|||
) |
|||
|
|||
// TODO(neeilan): We can eliminate these epToPoll / pToEpoll calls by using identical mask values for POLL/EPOLL
|
|||
// constants where possible The lower 16 bits of epoll events (uint32) can fit any system poll event (int16).
|
|||
|
|||
// epToPollEvt converts epoll event field to poll equivalent.
|
|||
// In epoll, Events is a 32-bit field, while poll uses 16 bits.
|
|||
func epToPollEvt(events uint32) int16 { |
|||
var ep2p = map[uint32]int16{ |
|||
EPOLLIN: POLLIN, |
|||
EPOLLOUT: POLLOUT, |
|||
EPOLLHUP: POLLHUP, |
|||
EPOLLPRI: POLLPRI, |
|||
EPOLLERR: POLLERR, |
|||
} |
|||
|
|||
var pollEvts int16 = 0 |
|||
for epEvt, pEvt := range ep2p { |
|||
if (events & epEvt) != 0 { |
|||
pollEvts |= pEvt |
|||
} |
|||
} |
|||
|
|||
return pollEvts |
|||
} |
|||
|
|||
// pToEpollEvt converts 16 bit poll event bitfields to 32-bit epoll event fields.
|
|||
func pToEpollEvt(revents int16) uint32 { |
|||
var p2ep = map[int16]uint32{ |
|||
POLLIN: EPOLLIN, |
|||
POLLOUT: EPOLLOUT, |
|||
POLLHUP: EPOLLHUP, |
|||
POLLPRI: EPOLLPRI, |
|||
POLLERR: EPOLLERR, |
|||
} |
|||
|
|||
var epollEvts uint32 = 0 |
|||
for pEvt, epEvt := range p2ep { |
|||
if (revents & pEvt) != 0 { |
|||
epollEvts |= epEvt |
|||
} |
|||
} |
|||
|
|||
return epollEvts |
|||
} |
|||
|
|||
// Per-process epoll implementation.
|
|||
type epollImpl struct { |
|||
mu sync.Mutex |
|||
epfd2ep map[int]*eventPoll |
|||
nextEpfd int |
|||
} |
|||
|
|||
// eventPoll holds a set of file descriptors being watched by the process. A process can have multiple epoll instances.
|
|||
// On Linux, this is an in-kernel data structure accessed through a fd.
|
|||
type eventPoll struct { |
|||
mu sync.Mutex |
|||
fds map[int]*EpollEvent |
|||
} |
|||
|
|||
// epoll impl for this process.
|
|||
var impl epollImpl = epollImpl{ |
|||
epfd2ep: make(map[int]*eventPoll), |
|||
nextEpfd: 0, |
|||
} |
|||
|
|||
func (e *epollImpl) epollcreate(size int) (epfd int, err error) { |
|||
e.mu.Lock() |
|||
defer e.mu.Unlock() |
|||
epfd = e.nextEpfd |
|||
e.nextEpfd++ |
|||
|
|||
e.epfd2ep[epfd] = &eventPoll{ |
|||
fds: make(map[int]*EpollEvent), |
|||
} |
|||
return epfd, nil |
|||
} |
|||
|
|||
func (e *epollImpl) epollcreate1(flag int) (fd int, err error) { |
|||
return e.epollcreate(4) |
|||
} |
|||
|
|||
func (e *epollImpl) epollctl(epfd int, op int, fd int, event *EpollEvent) (err error) { |
|||
e.mu.Lock() |
|||
defer e.mu.Unlock() |
|||
|
|||
ep, ok := e.epfd2ep[epfd] |
|||
if !ok { |
|||
|
|||
return EBADF |
|||
} |
|||
|
|||
switch op { |
|||
case EPOLL_CTL_ADD: |
|||
// TODO(neeilan): When we make epfds and fds disjoint, detect epoll
|
|||
// loops here (instances watching each other) and return ELOOP.
|
|||
if _, ok := ep.fds[fd]; ok { |
|||
return EEXIST |
|||
} |
|||
ep.fds[fd] = event |
|||
case EPOLL_CTL_MOD: |
|||
if _, ok := ep.fds[fd]; !ok { |
|||
return ENOENT |
|||
} |
|||
ep.fds[fd] = event |
|||
case EPOLL_CTL_DEL: |
|||
if _, ok := ep.fds[fd]; !ok { |
|||
return ENOENT |
|||
} |
|||
delete(ep.fds, fd) |
|||
|
|||
} |
|||
return nil |
|||
} |
|||
|
|||
// Must be called while holding ep.mu
|
|||
func (ep *eventPoll) getFds() []int { |
|||
fds := make([]int, len(ep.fds)) |
|||
for fd := range ep.fds { |
|||
fds = append(fds, fd) |
|||
} |
|||
return fds |
|||
} |
|||
|
|||
func (e *epollImpl) epollwait(epfd int, events []EpollEvent, msec int) (n int, err error) { |
|||
e.mu.Lock() // in [rare] case of concurrent epollcreate + epollwait
|
|||
ep, ok := e.epfd2ep[epfd] |
|||
|
|||
if !ok { |
|||
e.mu.Unlock() |
|||
return 0, EBADF |
|||
} |
|||
|
|||
pollfds := make([]PollFd, 4) |
|||
for fd, epollevt := range ep.fds { |
|||
pollfds = append(pollfds, PollFd{Fd: int32(fd), Events: epToPollEvt(epollevt.Events)}) |
|||
} |
|||
e.mu.Unlock() |
|||
|
|||
n, err = Poll(pollfds, msec) |
|||
if err != nil { |
|||
return n, err |
|||
} |
|||
|
|||
i := 0 |
|||
for _, pFd := range pollfds { |
|||
if pFd.Revents != 0 { |
|||
events[i] = EpollEvent{Fd: pFd.Fd, Events: pToEpollEvt(pFd.Revents)} |
|||
i++ |
|||
} |
|||
|
|||
if i == n { |
|||
break |
|||
} |
|||
} |
|||
|
|||
return n, nil |
|||
} |
|||
|
|||
func EpollCreate(size int) (fd int, err error) { |
|||
return impl.epollcreate(size) |
|||
} |
|||
|
|||
func EpollCreate1(flag int) (fd int, err error) { |
|||
return impl.epollcreate1(flag) |
|||
} |
|||
|
|||
func EpollCtl(epfd int, op int, fd int, event *EpollEvent) (err error) { |
|||
return impl.epollctl(epfd, op, fd, event) |
|||
} |
|||
|
|||
// Because EpollWait mutates events, the caller is expected to coordinate
|
|||
// concurrent access if calling with the same epfd from multiple goroutines.
|
|||
func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) { |
|||
return impl.epollwait(epfd, events, msec) |
|||
} |
@ -1,227 +0,0 @@ |
|||
// Copyright 2017 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
|||
// them here for backwards compatibility.
|
|||
|
|||
package unix |
|||
|
|||
const ( |
|||
IFF_SMART = 0x20 |
|||
IFT_1822 = 0x2 |
|||
IFT_A12MPPSWITCH = 0x82 |
|||
IFT_AAL2 = 0xbb |
|||
IFT_AAL5 = 0x31 |
|||
IFT_ADSL = 0x5e |
|||
IFT_AFLANE8023 = 0x3b |
|||
IFT_AFLANE8025 = 0x3c |
|||
IFT_ARAP = 0x58 |
|||
IFT_ARCNET = 0x23 |
|||
IFT_ARCNETPLUS = 0x24 |
|||
IFT_ASYNC = 0x54 |
|||
IFT_ATM = 0x25 |
|||
IFT_ATMDXI = 0x69 |
|||
IFT_ATMFUNI = 0x6a |
|||
IFT_ATMIMA = 0x6b |
|||
IFT_ATMLOGICAL = 0x50 |
|||
IFT_ATMRADIO = 0xbd |
|||
IFT_ATMSUBINTERFACE = 0x86 |
|||
IFT_ATMVCIENDPT = 0xc2 |
|||
IFT_ATMVIRTUAL = 0x95 |
|||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
|||
IFT_BSC = 0x53 |
|||
IFT_CCTEMUL = 0x3d |
|||
IFT_CEPT = 0x13 |
|||
IFT_CES = 0x85 |
|||
IFT_CHANNEL = 0x46 |
|||
IFT_CNR = 0x55 |
|||
IFT_COFFEE = 0x84 |
|||
IFT_COMPOSITELINK = 0x9b |
|||
IFT_DCN = 0x8d |
|||
IFT_DIGITALPOWERLINE = 0x8a |
|||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
|||
IFT_DLSW = 0x4a |
|||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
|||
IFT_DOCSCABLEMACLAYER = 0x7f |
|||
IFT_DOCSCABLEUPSTREAM = 0x81 |
|||
IFT_DS0 = 0x51 |
|||
IFT_DS0BUNDLE = 0x52 |
|||
IFT_DS1FDL = 0xaa |
|||
IFT_DS3 = 0x1e |
|||
IFT_DTM = 0x8c |
|||
IFT_DVBASILN = 0xac |
|||
IFT_DVBASIOUT = 0xad |
|||
IFT_DVBRCCDOWNSTREAM = 0x93 |
|||
IFT_DVBRCCMACLAYER = 0x92 |
|||
IFT_DVBRCCUPSTREAM = 0x94 |
|||
IFT_ENC = 0xf4 |
|||
IFT_EON = 0x19 |
|||
IFT_EPLRS = 0x57 |
|||
IFT_ESCON = 0x49 |
|||
IFT_ETHER = 0x6 |
|||
IFT_FAITH = 0xf2 |
|||
IFT_FAST = 0x7d |
|||
IFT_FASTETHER = 0x3e |
|||
IFT_FASTETHERFX = 0x45 |
|||
IFT_FDDI = 0xf |
|||
IFT_FIBRECHANNEL = 0x38 |
|||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
|||
IFT_FRAMERELAYMPI = 0x5c |
|||
IFT_FRDLCIENDPT = 0xc1 |
|||
IFT_FRELAY = 0x20 |
|||
IFT_FRELAYDCE = 0x2c |
|||
IFT_FRF16MFRBUNDLE = 0xa3 |
|||
IFT_FRFORWARD = 0x9e |
|||
IFT_G703AT2MB = 0x43 |
|||
IFT_G703AT64K = 0x42 |
|||
IFT_GIF = 0xf0 |
|||
IFT_GIGABITETHERNET = 0x75 |
|||
IFT_GR303IDT = 0xb2 |
|||
IFT_GR303RDT = 0xb1 |
|||
IFT_H323GATEKEEPER = 0xa4 |
|||
IFT_H323PROXY = 0xa5 |
|||
IFT_HDH1822 = 0x3 |
|||
IFT_HDLC = 0x76 |
|||
IFT_HDSL2 = 0xa8 |
|||
IFT_HIPERLAN2 = 0xb7 |
|||
IFT_HIPPI = 0x2f |
|||
IFT_HIPPIINTERFACE = 0x39 |
|||
IFT_HOSTPAD = 0x5a |
|||
IFT_HSSI = 0x2e |
|||
IFT_HY = 0xe |
|||
IFT_IBM370PARCHAN = 0x48 |
|||
IFT_IDSL = 0x9a |
|||
IFT_IEEE80211 = 0x47 |
|||
IFT_IEEE80212 = 0x37 |
|||
IFT_IEEE8023ADLAG = 0xa1 |
|||
IFT_IFGSN = 0x91 |
|||
IFT_IMT = 0xbe |
|||
IFT_INTERLEAVE = 0x7c |
|||
IFT_IP = 0x7e |
|||
IFT_IPFORWARD = 0x8e |
|||
IFT_IPOVERATM = 0x72 |
|||
IFT_IPOVERCDLC = 0x6d |
|||
IFT_IPOVERCLAW = 0x6e |
|||
IFT_IPSWITCH = 0x4e |
|||
IFT_IPXIP = 0xf9 |
|||
IFT_ISDN = 0x3f |
|||
IFT_ISDNBASIC = 0x14 |
|||
IFT_ISDNPRIMARY = 0x15 |
|||
IFT_ISDNS = 0x4b |
|||
IFT_ISDNU = 0x4c |
|||
IFT_ISO88022LLC = 0x29 |
|||
IFT_ISO88023 = 0x7 |
|||
IFT_ISO88024 = 0x8 |
|||
IFT_ISO88025 = 0x9 |
|||
IFT_ISO88025CRFPINT = 0x62 |
|||
IFT_ISO88025DTR = 0x56 |
|||
IFT_ISO88025FIBER = 0x73 |
|||
IFT_ISO88026 = 0xa |
|||
IFT_ISUP = 0xb3 |
|||
IFT_L3IPXVLAN = 0x89 |
|||
IFT_LAPB = 0x10 |
|||
IFT_LAPD = 0x4d |
|||
IFT_LAPF = 0x77 |
|||
IFT_LOCALTALK = 0x2a |
|||
IFT_LOOP = 0x18 |
|||
IFT_MEDIAMAILOVERIP = 0x8b |
|||
IFT_MFSIGLINK = 0xa7 |
|||
IFT_MIOX25 = 0x26 |
|||
IFT_MODEM = 0x30 |
|||
IFT_MPC = 0x71 |
|||
IFT_MPLS = 0xa6 |
|||
IFT_MPLSTUNNEL = 0x96 |
|||
IFT_MSDSL = 0x8f |
|||
IFT_MVL = 0xbf |
|||
IFT_MYRINET = 0x63 |
|||
IFT_NFAS = 0xaf |
|||
IFT_NSIP = 0x1b |
|||
IFT_OPTICALCHANNEL = 0xc3 |
|||
IFT_OPTICALTRANSPORT = 0xc4 |
|||
IFT_OTHER = 0x1 |
|||
IFT_P10 = 0xc |
|||
IFT_P80 = 0xd |
|||
IFT_PARA = 0x22 |
|||
IFT_PFLOG = 0xf6 |
|||
IFT_PFSYNC = 0xf7 |
|||
IFT_PLC = 0xae |
|||
IFT_POS = 0xab |
|||
IFT_PPPMULTILINKBUNDLE = 0x6c |
|||
IFT_PROPBWAP2MP = 0xb8 |
|||
IFT_PROPCNLS = 0x59 |
|||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
|||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
|||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
|||
IFT_PROPMUX = 0x36 |
|||
IFT_PROPWIRELESSP2P = 0x9d |
|||
IFT_PTPSERIAL = 0x16 |
|||
IFT_PVC = 0xf1 |
|||
IFT_QLLC = 0x44 |
|||
IFT_RADIOMAC = 0xbc |
|||
IFT_RADSL = 0x5f |
|||
IFT_REACHDSL = 0xc0 |
|||
IFT_RFC1483 = 0x9f |
|||
IFT_RS232 = 0x21 |
|||
IFT_RSRB = 0x4f |
|||
IFT_SDLC = 0x11 |
|||
IFT_SDSL = 0x60 |
|||
IFT_SHDSL = 0xa9 |
|||
IFT_SIP = 0x1f |
|||
IFT_SLIP = 0x1c |
|||
IFT_SMDSDXI = 0x2b |
|||
IFT_SMDSICIP = 0x34 |
|||
IFT_SONET = 0x27 |
|||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
|||
IFT_SONETPATH = 0x32 |
|||
IFT_SONETVT = 0x33 |
|||
IFT_SRP = 0x97 |
|||
IFT_SS7SIGLINK = 0x9c |
|||
IFT_STACKTOSTACK = 0x6f |
|||
IFT_STARLAN = 0xb |
|||
IFT_STF = 0xd7 |
|||
IFT_T1 = 0x12 |
|||
IFT_TDLC = 0x74 |
|||
IFT_TERMPAD = 0x5b |
|||
IFT_TR008 = 0xb0 |
|||
IFT_TRANSPHDLC = 0x7b |
|||
IFT_TUNNEL = 0x83 |
|||
IFT_ULTRA = 0x1d |
|||
IFT_USB = 0xa0 |
|||
IFT_V11 = 0x40 |
|||
IFT_V35 = 0x2d |
|||
IFT_V36 = 0x41 |
|||
IFT_V37 = 0x78 |
|||
IFT_VDSL = 0x61 |
|||
IFT_VIRTUALIPADDRESS = 0x70 |
|||
IFT_VOICEEM = 0x64 |
|||
IFT_VOICEENCAP = 0x67 |
|||
IFT_VOICEFXO = 0x65 |
|||
IFT_VOICEFXS = 0x66 |
|||
IFT_VOICEOVERATM = 0x98 |
|||
IFT_VOICEOVERFRAMERELAY = 0x99 |
|||
IFT_VOICEOVERIP = 0x68 |
|||
IFT_X213 = 0x5d |
|||
IFT_X25 = 0x5 |
|||
IFT_X25DDN = 0x4 |
|||
IFT_X25HUNTGROUP = 0x7a |
|||
IFT_X25MLP = 0x79 |
|||
IFT_X25PLE = 0x28 |
|||
IFT_XETHER = 0x1a |
|||
IPPROTO_MAXID = 0x34 |
|||
IPV6_FAITH = 0x1d |
|||
IP_FAITH = 0x16 |
|||
MAP_NORESERVE = 0x40 |
|||
MAP_RENAME = 0x20 |
|||
NET_RT_MAXID = 0x6 |
|||
RTF_PRCLONING = 0x10000 |
|||
RTM_OLDADD = 0x9 |
|||
RTM_OLDDEL = 0xa |
|||
SIOCADDRT = 0x8030720a |
|||
SIOCALIFADDR = 0x8118691b |
|||
SIOCDELRT = 0x8030720b |
|||
SIOCDLIFADDR = 0x8118691d |
|||
SIOCGLIFADDR = 0xc118691c |
|||
SIOCGLIFPHYADDR = 0xc118694b |
|||
SIOCSLIFPHYADDR = 0x8118694a |
|||
) |
@ -1,227 +0,0 @@ |
|||
// Copyright 2017 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// Constants that were deprecated or moved to enums in the FreeBSD headers. Keep
|
|||
// them here for backwards compatibility.
|
|||
|
|||
package unix |
|||
|
|||
const ( |
|||
IFF_SMART = 0x20 |
|||
IFT_1822 = 0x2 |
|||
IFT_A12MPPSWITCH = 0x82 |
|||
IFT_AAL2 = 0xbb |
|||
IFT_AAL5 = 0x31 |
|||
IFT_ADSL = 0x5e |
|||
IFT_AFLANE8023 = 0x3b |
|||
IFT_AFLANE8025 = 0x3c |
|||
IFT_ARAP = 0x58 |
|||
IFT_ARCNET = 0x23 |
|||
IFT_ARCNETPLUS = 0x24 |
|||
IFT_ASYNC = 0x54 |
|||
IFT_ATM = 0x25 |
|||
IFT_ATMDXI = 0x69 |
|||
IFT_ATMFUNI = 0x6a |
|||
IFT_ATMIMA = 0x6b |
|||
IFT_ATMLOGICAL = 0x50 |
|||
IFT_ATMRADIO = 0xbd |
|||
IFT_ATMSUBINTERFACE = 0x86 |
|||
IFT_ATMVCIENDPT = 0xc2 |
|||
IFT_ATMVIRTUAL = 0x95 |
|||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
|||
IFT_BSC = 0x53 |
|||
IFT_CCTEMUL = 0x3d |
|||
IFT_CEPT = 0x13 |
|||
IFT_CES = 0x85 |
|||
IFT_CHANNEL = 0x46 |
|||
IFT_CNR = 0x55 |
|||
IFT_COFFEE = 0x84 |
|||
IFT_COMPOSITELINK = 0x9b |
|||
IFT_DCN = 0x8d |
|||
IFT_DIGITALPOWERLINE = 0x8a |
|||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
|||
IFT_DLSW = 0x4a |
|||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
|||
IFT_DOCSCABLEMACLAYER = 0x7f |
|||
IFT_DOCSCABLEUPSTREAM = 0x81 |
|||
IFT_DS0 = 0x51 |
|||
IFT_DS0BUNDLE = 0x52 |
|||
IFT_DS1FDL = 0xaa |
|||
IFT_DS3 = 0x1e |
|||
IFT_DTM = 0x8c |
|||
IFT_DVBASILN = 0xac |
|||
IFT_DVBASIOUT = 0xad |
|||
IFT_DVBRCCDOWNSTREAM = 0x93 |
|||
IFT_DVBRCCMACLAYER = 0x92 |
|||
IFT_DVBRCCUPSTREAM = 0x94 |
|||
IFT_ENC = 0xf4 |
|||
IFT_EON = 0x19 |
|||
IFT_EPLRS = 0x57 |
|||
IFT_ESCON = 0x49 |
|||
IFT_ETHER = 0x6 |
|||
IFT_FAITH = 0xf2 |
|||
IFT_FAST = 0x7d |
|||
IFT_FASTETHER = 0x3e |
|||
IFT_FASTETHERFX = 0x45 |
|||
IFT_FDDI = 0xf |
|||
IFT_FIBRECHANNEL = 0x38 |
|||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
|||
IFT_FRAMERELAYMPI = 0x5c |
|||
IFT_FRDLCIENDPT = 0xc1 |
|||
IFT_FRELAY = 0x20 |
|||
IFT_FRELAYDCE = 0x2c |
|||
IFT_FRF16MFRBUNDLE = 0xa3 |
|||
IFT_FRFORWARD = 0x9e |
|||
IFT_G703AT2MB = 0x43 |
|||
IFT_G703AT64K = 0x42 |
|||
IFT_GIF = 0xf0 |
|||
IFT_GIGABITETHERNET = 0x75 |
|||
IFT_GR303IDT = 0xb2 |
|||
IFT_GR303RDT = 0xb1 |
|||
IFT_H323GATEKEEPER = 0xa4 |
|||
IFT_H323PROXY = 0xa5 |
|||
IFT_HDH1822 = 0x3 |
|||
IFT_HDLC = 0x76 |
|||
IFT_HDSL2 = 0xa8 |
|||
IFT_HIPERLAN2 = 0xb7 |
|||
IFT_HIPPI = 0x2f |
|||
IFT_HIPPIINTERFACE = 0x39 |
|||
IFT_HOSTPAD = 0x5a |
|||
IFT_HSSI = 0x2e |
|||
IFT_HY = 0xe |
|||
IFT_IBM370PARCHAN = 0x48 |
|||
IFT_IDSL = 0x9a |
|||
IFT_IEEE80211 = 0x47 |
|||
IFT_IEEE80212 = 0x37 |
|||
IFT_IEEE8023ADLAG = 0xa1 |
|||
IFT_IFGSN = 0x91 |
|||
IFT_IMT = 0xbe |
|||
IFT_INTERLEAVE = 0x7c |
|||
IFT_IP = 0x7e |
|||
IFT_IPFORWARD = 0x8e |
|||
IFT_IPOVERATM = 0x72 |
|||
IFT_IPOVERCDLC = 0x6d |
|||
IFT_IPOVERCLAW = 0x6e |
|||
IFT_IPSWITCH = 0x4e |
|||
IFT_IPXIP = 0xf9 |
|||
IFT_ISDN = 0x3f |
|||
IFT_ISDNBASIC = 0x14 |
|||
IFT_ISDNPRIMARY = 0x15 |
|||
IFT_ISDNS = 0x4b |
|||
IFT_ISDNU = 0x4c |
|||
IFT_ISO88022LLC = 0x29 |
|||
IFT_ISO88023 = 0x7 |
|||
IFT_ISO88024 = 0x8 |
|||
IFT_ISO88025 = 0x9 |
|||
IFT_ISO88025CRFPINT = 0x62 |
|||
IFT_ISO88025DTR = 0x56 |
|||
IFT_ISO88025FIBER = 0x73 |
|||
IFT_ISO88026 = 0xa |
|||
IFT_ISUP = 0xb3 |
|||
IFT_L3IPXVLAN = 0x89 |
|||
IFT_LAPB = 0x10 |
|||
IFT_LAPD = 0x4d |
|||
IFT_LAPF = 0x77 |
|||
IFT_LOCALTALK = 0x2a |
|||
IFT_LOOP = 0x18 |
|||
IFT_MEDIAMAILOVERIP = 0x8b |
|||
IFT_MFSIGLINK = 0xa7 |
|||
IFT_MIOX25 = 0x26 |
|||
IFT_MODEM = 0x30 |
|||
IFT_MPC = 0x71 |
|||
IFT_MPLS = 0xa6 |
|||
IFT_MPLSTUNNEL = 0x96 |
|||
IFT_MSDSL = 0x8f |
|||
IFT_MVL = 0xbf |
|||
IFT_MYRINET = 0x63 |
|||
IFT_NFAS = 0xaf |
|||
IFT_NSIP = 0x1b |
|||
IFT_OPTICALCHANNEL = 0xc3 |
|||
IFT_OPTICALTRANSPORT = 0xc4 |
|||
IFT_OTHER = 0x1 |
|||
IFT_P10 = 0xc |
|||
IFT_P80 = 0xd |
|||
IFT_PARA = 0x22 |
|||
IFT_PFLOG = 0xf6 |
|||
IFT_PFSYNC = 0xf7 |
|||
IFT_PLC = 0xae |
|||
IFT_POS = 0xab |
|||
IFT_PPPMULTILINKBUNDLE = 0x6c |
|||
IFT_PROPBWAP2MP = 0xb8 |
|||
IFT_PROPCNLS = 0x59 |
|||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
|||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
|||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
|||
IFT_PROPMUX = 0x36 |
|||
IFT_PROPWIRELESSP2P = 0x9d |
|||
IFT_PTPSERIAL = 0x16 |
|||
IFT_PVC = 0xf1 |
|||
IFT_QLLC = 0x44 |
|||
IFT_RADIOMAC = 0xbc |
|||
IFT_RADSL = 0x5f |
|||
IFT_REACHDSL = 0xc0 |
|||
IFT_RFC1483 = 0x9f |
|||
IFT_RS232 = 0x21 |
|||
IFT_RSRB = 0x4f |
|||
IFT_SDLC = 0x11 |
|||
IFT_SDSL = 0x60 |
|||
IFT_SHDSL = 0xa9 |
|||
IFT_SIP = 0x1f |
|||
IFT_SLIP = 0x1c |
|||
IFT_SMDSDXI = 0x2b |
|||
IFT_SMDSICIP = 0x34 |
|||
IFT_SONET = 0x27 |
|||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
|||
IFT_SONETPATH = 0x32 |
|||
IFT_SONETVT = 0x33 |
|||
IFT_SRP = 0x97 |
|||
IFT_SS7SIGLINK = 0x9c |
|||
IFT_STACKTOSTACK = 0x6f |
|||
IFT_STARLAN = 0xb |
|||
IFT_STF = 0xd7 |
|||
IFT_T1 = 0x12 |
|||
IFT_TDLC = 0x74 |
|||
IFT_TERMPAD = 0x5b |
|||
IFT_TR008 = 0xb0 |
|||
IFT_TRANSPHDLC = 0x7b |
|||
IFT_TUNNEL = 0x83 |
|||
IFT_ULTRA = 0x1d |
|||
IFT_USB = 0xa0 |
|||
IFT_V11 = 0x40 |
|||
IFT_V35 = 0x2d |
|||
IFT_V36 = 0x41 |
|||
IFT_V37 = 0x78 |
|||
IFT_VDSL = 0x61 |
|||
IFT_VIRTUALIPADDRESS = 0x70 |
|||
IFT_VOICEEM = 0x64 |
|||
IFT_VOICEENCAP = 0x67 |
|||
IFT_VOICEFXO = 0x65 |
|||
IFT_VOICEFXS = 0x66 |
|||
IFT_VOICEOVERATM = 0x98 |
|||
IFT_VOICEOVERFRAMERELAY = 0x99 |
|||
IFT_VOICEOVERIP = 0x68 |
|||
IFT_X213 = 0x5d |
|||
IFT_X25 = 0x5 |
|||
IFT_X25DDN = 0x4 |
|||
IFT_X25HUNTGROUP = 0x7a |
|||
IFT_X25MLP = 0x79 |
|||
IFT_X25PLE = 0x28 |
|||
IFT_XETHER = 0x1a |
|||
IPPROTO_MAXID = 0x34 |
|||
IPV6_FAITH = 0x1d |
|||
IP_FAITH = 0x16 |
|||
MAP_NORESERVE = 0x40 |
|||
MAP_RENAME = 0x20 |
|||
NET_RT_MAXID = 0x6 |
|||
RTF_PRCLONING = 0x10000 |
|||
RTM_OLDADD = 0x9 |
|||
RTM_OLDDEL = 0xa |
|||
SIOCADDRT = 0x8040720a |
|||
SIOCALIFADDR = 0x8118691b |
|||
SIOCDELRT = 0x8040720b |
|||
SIOCDLIFADDR = 0x8118691d |
|||
SIOCGLIFADDR = 0xc118691c |
|||
SIOCGLIFPHYADDR = 0xc118694b |
|||
SIOCSLIFPHYADDR = 0x8118694a |
|||
) |
@ -1,226 +0,0 @@ |
|||
// Copyright 2017 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
package unix |
|||
|
|||
const ( |
|||
IFT_1822 = 0x2 |
|||
IFT_A12MPPSWITCH = 0x82 |
|||
IFT_AAL2 = 0xbb |
|||
IFT_AAL5 = 0x31 |
|||
IFT_ADSL = 0x5e |
|||
IFT_AFLANE8023 = 0x3b |
|||
IFT_AFLANE8025 = 0x3c |
|||
IFT_ARAP = 0x58 |
|||
IFT_ARCNET = 0x23 |
|||
IFT_ARCNETPLUS = 0x24 |
|||
IFT_ASYNC = 0x54 |
|||
IFT_ATM = 0x25 |
|||
IFT_ATMDXI = 0x69 |
|||
IFT_ATMFUNI = 0x6a |
|||
IFT_ATMIMA = 0x6b |
|||
IFT_ATMLOGICAL = 0x50 |
|||
IFT_ATMRADIO = 0xbd |
|||
IFT_ATMSUBINTERFACE = 0x86 |
|||
IFT_ATMVCIENDPT = 0xc2 |
|||
IFT_ATMVIRTUAL = 0x95 |
|||
IFT_BGPPOLICYACCOUNTING = 0xa2 |
|||
IFT_BSC = 0x53 |
|||
IFT_CCTEMUL = 0x3d |
|||
IFT_CEPT = 0x13 |
|||
IFT_CES = 0x85 |
|||
IFT_CHANNEL = 0x46 |
|||
IFT_CNR = 0x55 |
|||
IFT_COFFEE = 0x84 |
|||
IFT_COMPOSITELINK = 0x9b |
|||
IFT_DCN = 0x8d |
|||
IFT_DIGITALPOWERLINE = 0x8a |
|||
IFT_DIGITALWRAPPEROVERHEADCHANNEL = 0xba |
|||
IFT_DLSW = 0x4a |
|||
IFT_DOCSCABLEDOWNSTREAM = 0x80 |
|||
IFT_DOCSCABLEMACLAYER = 0x7f |
|||
IFT_DOCSCABLEUPSTREAM = 0x81 |
|||
IFT_DS0 = 0x51 |
|||
IFT_DS0BUNDLE = 0x52 |
|||
IFT_DS1FDL = 0xaa |
|||
IFT_DS3 = 0x1e |
|||
IFT_DTM = 0x8c |
|||
IFT_DVBASILN = 0xac |
|||
IFT_DVBASIOUT = 0xad |
|||
IFT_DVBRCCDOWNSTREAM = 0x93 |
|||
IFT_DVBRCCMACLAYER = 0x92 |
|||
IFT_DVBRCCUPSTREAM = 0x94 |
|||
IFT_ENC = 0xf4 |
|||
IFT_EON = 0x19 |
|||
IFT_EPLRS = 0x57 |
|||
IFT_ESCON = 0x49 |
|||
IFT_ETHER = 0x6 |
|||
IFT_FAST = 0x7d |
|||
IFT_FASTETHER = 0x3e |
|||
IFT_FASTETHERFX = 0x45 |
|||
IFT_FDDI = 0xf |
|||
IFT_FIBRECHANNEL = 0x38 |
|||
IFT_FRAMERELAYINTERCONNECT = 0x3a |
|||
IFT_FRAMERELAYMPI = 0x5c |
|||
IFT_FRDLCIENDPT = 0xc1 |
|||
IFT_FRELAY = 0x20 |
|||
IFT_FRELAYDCE = 0x2c |
|||
IFT_FRF16MFRBUNDLE = 0xa3 |
|||
IFT_FRFORWARD = 0x9e |
|||
IFT_G703AT2MB = 0x43 |
|||
IFT_G703AT64K = 0x42 |
|||
IFT_GIF = 0xf0 |
|||
IFT_GIGABITETHERNET = 0x75 |
|||
IFT_GR303IDT = 0xb2 |
|||
IFT_GR303RDT = 0xb1 |
|||
IFT_H323GATEKEEPER = 0xa4 |
|||
IFT_H323PROXY = 0xa5 |
|||
IFT_HDH1822 = 0x3 |
|||
IFT_HDLC = 0x76 |
|||
IFT_HDSL2 = 0xa8 |
|||
IFT_HIPERLAN2 = 0xb7 |
|||
IFT_HIPPI = 0x2f |
|||
IFT_HIPPIINTERFACE = 0x39 |
|||
IFT_HOSTPAD = 0x5a |
|||
IFT_HSSI = 0x2e |
|||
IFT_HY = 0xe |
|||
IFT_IBM370PARCHAN = 0x48 |
|||
IFT_IDSL = 0x9a |
|||
IFT_IEEE80211 = 0x47 |
|||
IFT_IEEE80212 = 0x37 |
|||
IFT_IEEE8023ADLAG = 0xa1 |
|||
IFT_IFGSN = 0x91 |
|||
IFT_IMT = 0xbe |
|||
IFT_INTERLEAVE = 0x7c |
|||
IFT_IP = 0x7e |
|||
IFT_IPFORWARD = 0x8e |
|||
IFT_IPOVERATM = 0x72 |
|||
IFT_IPOVERCDLC = 0x6d |
|||
IFT_IPOVERCLAW = 0x6e |
|||
IFT_IPSWITCH = 0x4e |
|||
IFT_ISDN = 0x3f |
|||
IFT_ISDNBASIC = 0x14 |
|||
IFT_ISDNPRIMARY = 0x15 |
|||
IFT_ISDNS = 0x4b |
|||
IFT_ISDNU = 0x4c |
|||
IFT_ISO88022LLC = 0x29 |
|||
IFT_ISO88023 = 0x7 |
|||
IFT_ISO88024 = 0x8 |
|||
IFT_ISO88025 = 0x9 |
|||
IFT_ISO88025CRFPINT = 0x62 |
|||
IFT_ISO88025DTR = 0x56 |
|||
IFT_ISO88025FIBER = 0x73 |
|||
IFT_ISO88026 = 0xa |
|||
IFT_ISUP = 0xb3 |
|||
IFT_L3IPXVLAN = 0x89 |
|||
IFT_LAPB = 0x10 |
|||
IFT_LAPD = 0x4d |
|||
IFT_LAPF = 0x77 |
|||
IFT_LOCALTALK = 0x2a |
|||
IFT_LOOP = 0x18 |
|||
IFT_MEDIAMAILOVERIP = 0x8b |
|||
IFT_MFSIGLINK = 0xa7 |
|||
IFT_MIOX25 = 0x26 |
|||
IFT_MODEM = 0x30 |
|||
IFT_MPC = 0x71 |
|||
IFT_MPLS = 0xa6 |
|||
IFT_MPLSTUNNEL = 0x96 |
|||
IFT_MSDSL = 0x8f |
|||
IFT_MVL = 0xbf |
|||
IFT_MYRINET = 0x63 |
|||
IFT_NFAS = 0xaf |
|||
IFT_NSIP = 0x1b |
|||
IFT_OPTICALCHANNEL = 0xc3 |
|||
IFT_OPTICALTRANSPORT = 0xc4 |
|||
IFT_OTHER = 0x1 |
|||
IFT_P10 = 0xc |
|||
IFT_P80 = 0xd |
|||
IFT_PARA = 0x22 |
|||
IFT_PFLOG = 0xf6 |
|||
IFT_PFSYNC = 0xf7 |
|||
IFT_PLC = 0xae |
|||
IFT_POS = 0xab |
|||
IFT_PPPMULTILINKBUNDLE = 0x6c |
|||
IFT_PROPBWAP2MP = 0xb8 |
|||
IFT_PROPCNLS = 0x59 |
|||
IFT_PROPDOCSWIRELESSDOWNSTREAM = 0xb5 |
|||
IFT_PROPDOCSWIRELESSMACLAYER = 0xb4 |
|||
IFT_PROPDOCSWIRELESSUPSTREAM = 0xb6 |
|||
IFT_PROPMUX = 0x36 |
|||
IFT_PROPWIRELESSP2P = 0x9d |
|||
IFT_PTPSERIAL = 0x16 |
|||
IFT_PVC = 0xf1 |
|||
IFT_QLLC = 0x44 |
|||
IFT_RADIOMAC = 0xbc |
|||
IFT_RADSL = 0x5f |
|||
IFT_REACHDSL = 0xc0 |
|||
IFT_RFC1483 = 0x9f |
|||
IFT_RS232 = 0x21 |
|||
IFT_RSRB = 0x4f |
|||
IFT_SDLC = 0x11 |
|||
IFT_SDSL = 0x60 |
|||
IFT_SHDSL = 0xa9 |
|||
IFT_SIP = 0x1f |
|||
IFT_SLIP = 0x1c |
|||
IFT_SMDSDXI = 0x2b |
|||
IFT_SMDSICIP = 0x34 |
|||
IFT_SONET = 0x27 |
|||
IFT_SONETOVERHEADCHANNEL = 0xb9 |
|||
IFT_SONETPATH = 0x32 |
|||
IFT_SONETVT = 0x33 |
|||
IFT_SRP = 0x97 |
|||
IFT_SS7SIGLINK = 0x9c |
|||
IFT_STACKTOSTACK = 0x6f |
|||
IFT_STARLAN = 0xb |
|||
IFT_STF = 0xd7 |
|||
IFT_T1 = 0x12 |
|||
IFT_TDLC = 0x74 |
|||
IFT_TERMPAD = 0x5b |
|||
IFT_TR008 = 0xb0 |
|||
IFT_TRANSPHDLC = 0x7b |
|||
IFT_TUNNEL = 0x83 |
|||
IFT_ULTRA = 0x1d |
|||
IFT_USB = 0xa0 |
|||
IFT_V11 = 0x40 |
|||
IFT_V35 = 0x2d |
|||
IFT_V36 = 0x41 |
|||
IFT_V37 = 0x78 |
|||
IFT_VDSL = 0x61 |
|||
IFT_VIRTUALIPADDRESS = 0x70 |
|||
IFT_VOICEEM = 0x64 |
|||
IFT_VOICEENCAP = 0x67 |
|||
IFT_VOICEFXO = 0x65 |
|||
IFT_VOICEFXS = 0x66 |
|||
IFT_VOICEOVERATM = 0x98 |
|||
IFT_VOICEOVERFRAMERELAY = 0x99 |
|||
IFT_VOICEOVERIP = 0x68 |
|||
IFT_X213 = 0x5d |
|||
IFT_X25 = 0x5 |
|||
IFT_X25DDN = 0x4 |
|||
IFT_X25HUNTGROUP = 0x7a |
|||
IFT_X25MLP = 0x79 |
|||
IFT_X25PLE = 0x28 |
|||
IFT_XETHER = 0x1a |
|||
|
|||
// missing constants on FreeBSD-11.1-RELEASE, copied from old values in ztypes_freebsd_arm.go
|
|||
IFF_SMART = 0x20 |
|||
IFT_FAITH = 0xf2 |
|||
IFT_IPXIP = 0xf9 |
|||
IPPROTO_MAXID = 0x34 |
|||
IPV6_FAITH = 0x1d |
|||
IP_FAITH = 0x16 |
|||
MAP_NORESERVE = 0x40 |
|||
MAP_RENAME = 0x20 |
|||
NET_RT_MAXID = 0x6 |
|||
RTF_PRCLONING = 0x10000 |
|||
RTM_OLDADD = 0x9 |
|||
RTM_OLDDEL = 0xa |
|||
SIOCADDRT = 0x8030720a |
|||
SIOCALIFADDR = 0x8118691b |
|||
SIOCDELRT = 0x8030720b |
|||
SIOCDLIFADDR = 0x8118691d |
|||
SIOCGLIFADDR = 0xc118691c |
|||
SIOCGLIFPHYADDR = 0xc118694b |
|||
SIOCSLIFPHYADDR = 0x8118694a |
|||
) |
@ -0,0 +1,30 @@ |
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || zos
|
|||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris zos
|
|||
|
|||
package unix |
|||
|
|||
// Set adds fd to the set fds.
|
|||
func (fds *FdSet) Set(fd int) { |
|||
fds.Bits[fd/NFDBITS] |= (1 << (uintptr(fd) % NFDBITS)) |
|||
} |
|||
|
|||
// Clear removes fd from the set fds.
|
|||
func (fds *FdSet) Clear(fd int) { |
|||
fds.Bits[fd/NFDBITS] &^= (1 << (uintptr(fd) % NFDBITS)) |
|||
} |
|||
|
|||
// IsSet returns whether fd is in the set fds.
|
|||
func (fds *FdSet) IsSet(fd int) bool { |
|||
return fds.Bits[fd/NFDBITS]&(1<<(uintptr(fd)%NFDBITS)) != 0 |
|||
} |
|||
|
|||
// Zero clears the set fds.
|
|||
func (fds *FdSet) Zero() { |
|||
for i := range fds.Bits { |
|||
fds.Bits[i] = 0 |
|||
} |
|||
} |
@ -0,0 +1,164 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build zos && s390x
|
|||
// +build zos,s390x
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"unsafe" |
|||
) |
|||
|
|||
// This file simulates fstatfs on z/OS using fstatvfs and w_getmntent.
|
|||
|
|||
func Fstatfs(fd int, stat *Statfs_t) (err error) { |
|||
var stat_v Statvfs_t |
|||
err = Fstatvfs(fd, &stat_v) |
|||
if err == nil { |
|||
// populate stat
|
|||
stat.Type = 0 |
|||
stat.Bsize = stat_v.Bsize |
|||
stat.Blocks = stat_v.Blocks |
|||
stat.Bfree = stat_v.Bfree |
|||
stat.Bavail = stat_v.Bavail |
|||
stat.Files = stat_v.Files |
|||
stat.Ffree = stat_v.Ffree |
|||
stat.Fsid = stat_v.Fsid |
|||
stat.Namelen = stat_v.Namemax |
|||
stat.Frsize = stat_v.Frsize |
|||
stat.Flags = stat_v.Flag |
|||
for passn := 0; passn < 5; passn++ { |
|||
switch passn { |
|||
case 0: |
|||
err = tryGetmntent64(stat) |
|||
break |
|||
case 1: |
|||
err = tryGetmntent128(stat) |
|||
break |
|||
case 2: |
|||
err = tryGetmntent256(stat) |
|||
break |
|||
case 3: |
|||
err = tryGetmntent512(stat) |
|||
break |
|||
case 4: |
|||
err = tryGetmntent1024(stat) |
|||
break |
|||
default: |
|||
break |
|||
} |
|||
//proceed to return if: err is nil (found), err is nonnil but not ERANGE (another error occurred)
|
|||
if err == nil || err != nil && err != ERANGE { |
|||
break |
|||
} |
|||
} |
|||
} |
|||
return err |
|||
} |
|||
|
|||
func tryGetmntent64(stat *Statfs_t) (err error) { |
|||
var mnt_ent_buffer struct { |
|||
header W_Mnth |
|||
filesys_info [64]W_Mntent |
|||
} |
|||
var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) |
|||
fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = ERANGE //return ERANGE if no match is found in this batch
|
|||
for i := 0; i < fs_count; i++ { |
|||
if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { |
|||
stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) |
|||
err = nil |
|||
break |
|||
} |
|||
} |
|||
return err |
|||
} |
|||
|
|||
func tryGetmntent128(stat *Statfs_t) (err error) { |
|||
var mnt_ent_buffer struct { |
|||
header W_Mnth |
|||
filesys_info [128]W_Mntent |
|||
} |
|||
var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) |
|||
fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = ERANGE //return ERANGE if no match is found in this batch
|
|||
for i := 0; i < fs_count; i++ { |
|||
if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { |
|||
stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) |
|||
err = nil |
|||
break |
|||
} |
|||
} |
|||
return err |
|||
} |
|||
|
|||
func tryGetmntent256(stat *Statfs_t) (err error) { |
|||
var mnt_ent_buffer struct { |
|||
header W_Mnth |
|||
filesys_info [256]W_Mntent |
|||
} |
|||
var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) |
|||
fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = ERANGE //return ERANGE if no match is found in this batch
|
|||
for i := 0; i < fs_count; i++ { |
|||
if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { |
|||
stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) |
|||
err = nil |
|||
break |
|||
} |
|||
} |
|||
return err |
|||
} |
|||
|
|||
func tryGetmntent512(stat *Statfs_t) (err error) { |
|||
var mnt_ent_buffer struct { |
|||
header W_Mnth |
|||
filesys_info [512]W_Mntent |
|||
} |
|||
var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) |
|||
fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = ERANGE //return ERANGE if no match is found in this batch
|
|||
for i := 0; i < fs_count; i++ { |
|||
if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { |
|||
stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) |
|||
err = nil |
|||
break |
|||
} |
|||
} |
|||
return err |
|||
} |
|||
|
|||
func tryGetmntent1024(stat *Statfs_t) (err error) { |
|||
var mnt_ent_buffer struct { |
|||
header W_Mnth |
|||
filesys_info [1024]W_Mntent |
|||
} |
|||
var buffer_size int = int(unsafe.Sizeof(mnt_ent_buffer)) |
|||
fs_count, err := W_Getmntent((*byte)(unsafe.Pointer(&mnt_ent_buffer)), buffer_size) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = ERANGE //return ERANGE if no match is found in this batch
|
|||
for i := 0; i < fs_count; i++ { |
|||
if stat.Fsid == uint64(mnt_ent_buffer.filesys_info[i].Dev) { |
|||
stat.Type = uint32(mnt_ent_buffer.filesys_info[i].Fstname[0]) |
|||
err = nil |
|||
break |
|||
} |
|||
} |
|||
return err |
|||
} |
@ -0,0 +1,142 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build linux
|
|||
// +build linux
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"unsafe" |
|||
) |
|||
|
|||
// Helpers for dealing with ifreq since it contains a union and thus requires a
|
|||
// lot of unsafe.Pointer casts to use properly.
|
|||
|
|||
// An Ifreq is a type-safe wrapper around the raw ifreq struct. An Ifreq
|
|||
// contains an interface name and a union of arbitrary data which can be
|
|||
// accessed using the Ifreq's methods. To create an Ifreq, use the NewIfreq
|
|||
// function.
|
|||
//
|
|||
// Use the Name method to access the stored interface name. The union data
|
|||
// fields can be get and set using the following methods:
|
|||
// - Uint16/SetUint16: flags
|
|||
// - Uint32/SetUint32: ifindex, metric, mtu
|
|||
type Ifreq struct{ raw ifreq } |
|||
|
|||
// NewIfreq creates an Ifreq with the input network interface name after
|
|||
// validating the name does not exceed IFNAMSIZ-1 (trailing NULL required)
|
|||
// bytes.
|
|||
func NewIfreq(name string) (*Ifreq, error) { |
|||
// Leave room for terminating NULL byte.
|
|||
if len(name) >= IFNAMSIZ { |
|||
return nil, EINVAL |
|||
} |
|||
|
|||
var ifr ifreq |
|||
copy(ifr.Ifrn[:], name) |
|||
|
|||
return &Ifreq{raw: ifr}, nil |
|||
} |
|||
|
|||
// TODO(mdlayher): get/set methods for hardware address sockaddr, char array, etc.
|
|||
|
|||
// Name returns the interface name associated with the Ifreq.
|
|||
func (ifr *Ifreq) Name() string { |
|||
return ByteSliceToString(ifr.raw.Ifrn[:]) |
|||
} |
|||
|
|||
// According to netdevice(7), only AF_INET addresses are returned for numerous
|
|||
// sockaddr ioctls. For convenience, we expose these as Inet4Addr since the Port
|
|||
// field and other data is always empty.
|
|||
|
|||
// Inet4Addr returns the Ifreq union data from an embedded sockaddr as a C
|
|||
// in_addr/Go []byte (4-byte IPv4 address) value. If the sockaddr family is not
|
|||
// AF_INET, an error is returned.
|
|||
func (ifr *Ifreq) Inet4Addr() ([]byte, error) { |
|||
raw := *(*RawSockaddrInet4)(unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0])) |
|||
if raw.Family != AF_INET { |
|||
// Cannot safely interpret raw.Addr bytes as an IPv4 address.
|
|||
return nil, EINVAL |
|||
} |
|||
|
|||
return raw.Addr[:], nil |
|||
} |
|||
|
|||
// SetInet4Addr sets a C in_addr/Go []byte (4-byte IPv4 address) value in an
|
|||
// embedded sockaddr within the Ifreq's union data. v must be 4 bytes in length
|
|||
// or an error will be returned.
|
|||
func (ifr *Ifreq) SetInet4Addr(v []byte) error { |
|||
if len(v) != 4 { |
|||
return EINVAL |
|||
} |
|||
|
|||
var addr [4]byte |
|||
copy(addr[:], v) |
|||
|
|||
ifr.clear() |
|||
*(*RawSockaddrInet4)( |
|||
unsafe.Pointer(&ifr.raw.Ifru[:SizeofSockaddrInet4][0]), |
|||
) = RawSockaddrInet4{ |
|||
// Always set IP family as ioctls would require it anyway.
|
|||
Family: AF_INET, |
|||
Addr: addr, |
|||
} |
|||
|
|||
return nil |
|||
} |
|||
|
|||
// Uint16 returns the Ifreq union data as a C short/Go uint16 value.
|
|||
func (ifr *Ifreq) Uint16() uint16 { |
|||
return *(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) |
|||
} |
|||
|
|||
// SetUint16 sets a C short/Go uint16 value as the Ifreq's union data.
|
|||
func (ifr *Ifreq) SetUint16(v uint16) { |
|||
ifr.clear() |
|||
*(*uint16)(unsafe.Pointer(&ifr.raw.Ifru[:2][0])) = v |
|||
} |
|||
|
|||
// Uint32 returns the Ifreq union data as a C int/Go uint32 value.
|
|||
func (ifr *Ifreq) Uint32() uint32 { |
|||
return *(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) |
|||
} |
|||
|
|||
// SetUint32 sets a C int/Go uint32 value as the Ifreq's union data.
|
|||
func (ifr *Ifreq) SetUint32(v uint32) { |
|||
ifr.clear() |
|||
*(*uint32)(unsafe.Pointer(&ifr.raw.Ifru[:4][0])) = v |
|||
} |
|||
|
|||
// clear zeroes the ifreq's union field to prevent trailing garbage data from
|
|||
// being sent to the kernel if an ifreq is reused.
|
|||
func (ifr *Ifreq) clear() { |
|||
for i := range ifr.raw.Ifru { |
|||
ifr.raw.Ifru[i] = 0 |
|||
} |
|||
} |
|||
|
|||
// TODO(mdlayher): export as IfreqData? For now we can provide helpers such as
|
|||
// IoctlGetEthtoolDrvinfo which use these APIs under the hood.
|
|||
|
|||
// An ifreqData is an Ifreq which carries pointer data. To produce an ifreqData,
|
|||
// use the Ifreq.withData method.
|
|||
type ifreqData struct { |
|||
name [IFNAMSIZ]byte |
|||
// A type separate from ifreq is required in order to comply with the
|
|||
// unsafe.Pointer rules since the "pointer-ness" of data would not be
|
|||
// preserved if it were cast into the byte array of a raw ifreq.
|
|||
data unsafe.Pointer |
|||
// Pad to the same size as ifreq.
|
|||
_ [len(ifreq{}.Ifru) - SizeofPtr]byte |
|||
} |
|||
|
|||
// withData produces an ifreqData with the pointer p set for ioctls which require
|
|||
// arbitrary pointer data.
|
|||
func (ifr Ifreq) withData(p unsafe.Pointer) ifreqData { |
|||
return ifreqData{ |
|||
name: ifr.raw.Ifrn, |
|||
data: p, |
|||
} |
|||
} |
@ -0,0 +1,233 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
package unix |
|||
|
|||
import "unsafe" |
|||
|
|||
// IoctlRetInt performs an ioctl operation specified by req on a device
|
|||
// associated with opened file descriptor fd, and returns a non-negative
|
|||
// integer that is returned by the ioctl syscall.
|
|||
func IoctlRetInt(fd int, req uint) (int, error) { |
|||
ret, _, err := Syscall(SYS_IOCTL, uintptr(fd), uintptr(req), 0) |
|||
if err != 0 { |
|||
return 0, err |
|||
} |
|||
return int(ret), nil |
|||
} |
|||
|
|||
func IoctlGetUint32(fd int, req uint) (uint32, error) { |
|||
var value uint32 |
|||
err := ioctlPtr(fd, req, unsafe.Pointer(&value)) |
|||
return value, err |
|||
} |
|||
|
|||
func IoctlGetRTCTime(fd int) (*RTCTime, error) { |
|||
var value RTCTime |
|||
err := ioctlPtr(fd, RTC_RD_TIME, unsafe.Pointer(&value)) |
|||
return &value, err |
|||
} |
|||
|
|||
func IoctlSetRTCTime(fd int, value *RTCTime) error { |
|||
return ioctlPtr(fd, RTC_SET_TIME, unsafe.Pointer(value)) |
|||
} |
|||
|
|||
func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) { |
|||
var value RTCWkAlrm |
|||
err := ioctlPtr(fd, RTC_WKALM_RD, unsafe.Pointer(&value)) |
|||
return &value, err |
|||
} |
|||
|
|||
func IoctlSetRTCWkAlrm(fd int, value *RTCWkAlrm) error { |
|||
return ioctlPtr(fd, RTC_WKALM_SET, unsafe.Pointer(value)) |
|||
} |
|||
|
|||
// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
|
|||
// device specified by ifname.
|
|||
func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) { |
|||
ifr, err := NewIfreq(ifname) |
|||
if err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
value := EthtoolDrvinfo{Cmd: ETHTOOL_GDRVINFO} |
|||
ifrd := ifr.withData(unsafe.Pointer(&value)) |
|||
|
|||
err = ioctlIfreqData(fd, SIOCETHTOOL, &ifrd) |
|||
return &value, err |
|||
} |
|||
|
|||
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
|
|||
// Linux watchdog API. For more information, see:
|
|||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
|||
func IoctlGetWatchdogInfo(fd int) (*WatchdogInfo, error) { |
|||
var value WatchdogInfo |
|||
err := ioctlPtr(fd, WDIOC_GETSUPPORT, unsafe.Pointer(&value)) |
|||
return &value, err |
|||
} |
|||
|
|||
// IoctlWatchdogKeepalive issues a keepalive ioctl to a watchdog device. For
|
|||
// more information, see:
|
|||
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
|
|||
func IoctlWatchdogKeepalive(fd int) error { |
|||
// arg is ignored and not a pointer, so ioctl is fine instead of ioctlPtr.
|
|||
return ioctl(fd, WDIOC_KEEPALIVE, 0) |
|||
} |
|||
|
|||
// IoctlFileCloneRange performs an FICLONERANGE ioctl operation to clone the
|
|||
// range of data conveyed in value to the file associated with the file
|
|||
// descriptor destFd. See the ioctl_ficlonerange(2) man page for details.
|
|||
func IoctlFileCloneRange(destFd int, value *FileCloneRange) error { |
|||
return ioctlPtr(destFd, FICLONERANGE, unsafe.Pointer(value)) |
|||
} |
|||
|
|||
// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file
|
|||
// associated with the file description srcFd to the file associated with the
|
|||
// file descriptor destFd. See the ioctl_ficlone(2) man page for details.
|
|||
func IoctlFileClone(destFd, srcFd int) error { |
|||
return ioctl(destFd, FICLONE, uintptr(srcFd)) |
|||
} |
|||
|
|||
type FileDedupeRange struct { |
|||
Src_offset uint64 |
|||
Src_length uint64 |
|||
Reserved1 uint16 |
|||
Reserved2 uint32 |
|||
Info []FileDedupeRangeInfo |
|||
} |
|||
|
|||
type FileDedupeRangeInfo struct { |
|||
Dest_fd int64 |
|||
Dest_offset uint64 |
|||
Bytes_deduped uint64 |
|||
Status int32 |
|||
Reserved uint32 |
|||
} |
|||
|
|||
// IoctlFileDedupeRange performs an FIDEDUPERANGE ioctl operation to share the
|
|||
// range of data conveyed in value from the file associated with the file
|
|||
// descriptor srcFd to the value.Info destinations. See the
|
|||
// ioctl_fideduperange(2) man page for details.
|
|||
func IoctlFileDedupeRange(srcFd int, value *FileDedupeRange) error { |
|||
buf := make([]byte, SizeofRawFileDedupeRange+ |
|||
len(value.Info)*SizeofRawFileDedupeRangeInfo) |
|||
rawrange := (*RawFileDedupeRange)(unsafe.Pointer(&buf[0])) |
|||
rawrange.Src_offset = value.Src_offset |
|||
rawrange.Src_length = value.Src_length |
|||
rawrange.Dest_count = uint16(len(value.Info)) |
|||
rawrange.Reserved1 = value.Reserved1 |
|||
rawrange.Reserved2 = value.Reserved2 |
|||
|
|||
for i := range value.Info { |
|||
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer( |
|||
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) + |
|||
uintptr(i*SizeofRawFileDedupeRangeInfo))) |
|||
rawinfo.Dest_fd = value.Info[i].Dest_fd |
|||
rawinfo.Dest_offset = value.Info[i].Dest_offset |
|||
rawinfo.Bytes_deduped = value.Info[i].Bytes_deduped |
|||
rawinfo.Status = value.Info[i].Status |
|||
rawinfo.Reserved = value.Info[i].Reserved |
|||
} |
|||
|
|||
err := ioctlPtr(srcFd, FIDEDUPERANGE, unsafe.Pointer(&buf[0])) |
|||
|
|||
// Output
|
|||
for i := range value.Info { |
|||
rawinfo := (*RawFileDedupeRangeInfo)(unsafe.Pointer( |
|||
uintptr(unsafe.Pointer(&buf[0])) + uintptr(SizeofRawFileDedupeRange) + |
|||
uintptr(i*SizeofRawFileDedupeRangeInfo))) |
|||
value.Info[i].Dest_fd = rawinfo.Dest_fd |
|||
value.Info[i].Dest_offset = rawinfo.Dest_offset |
|||
value.Info[i].Bytes_deduped = rawinfo.Bytes_deduped |
|||
value.Info[i].Status = rawinfo.Status |
|||
value.Info[i].Reserved = rawinfo.Reserved |
|||
} |
|||
|
|||
return err |
|||
} |
|||
|
|||
func IoctlHIDGetDesc(fd int, value *HIDRawReportDescriptor) error { |
|||
return ioctlPtr(fd, HIDIOCGRDESC, unsafe.Pointer(value)) |
|||
} |
|||
|
|||
func IoctlHIDGetRawInfo(fd int) (*HIDRawDevInfo, error) { |
|||
var value HIDRawDevInfo |
|||
err := ioctlPtr(fd, HIDIOCGRAWINFO, unsafe.Pointer(&value)) |
|||
return &value, err |
|||
} |
|||
|
|||
func IoctlHIDGetRawName(fd int) (string, error) { |
|||
var value [_HIDIOCGRAWNAME_LEN]byte |
|||
err := ioctlPtr(fd, _HIDIOCGRAWNAME, unsafe.Pointer(&value[0])) |
|||
return ByteSliceToString(value[:]), err |
|||
} |
|||
|
|||
func IoctlHIDGetRawPhys(fd int) (string, error) { |
|||
var value [_HIDIOCGRAWPHYS_LEN]byte |
|||
err := ioctlPtr(fd, _HIDIOCGRAWPHYS, unsafe.Pointer(&value[0])) |
|||
return ByteSliceToString(value[:]), err |
|||
} |
|||
|
|||
func IoctlHIDGetRawUniq(fd int) (string, error) { |
|||
var value [_HIDIOCGRAWUNIQ_LEN]byte |
|||
err := ioctlPtr(fd, _HIDIOCGRAWUNIQ, unsafe.Pointer(&value[0])) |
|||
return ByteSliceToString(value[:]), err |
|||
} |
|||
|
|||
// IoctlIfreq performs an ioctl using an Ifreq structure for input and/or
|
|||
// output. See the netdevice(7) man page for details.
|
|||
func IoctlIfreq(fd int, req uint, value *Ifreq) error { |
|||
// It is possible we will add more fields to *Ifreq itself later to prevent
|
|||
// misuse, so pass the raw *ifreq directly.
|
|||
return ioctlPtr(fd, req, unsafe.Pointer(&value.raw)) |
|||
} |
|||
|
|||
// TODO(mdlayher): export if and when IfreqData is exported.
|
|||
|
|||
// ioctlIfreqData performs an ioctl using an ifreqData structure for input
|
|||
// and/or output. See the netdevice(7) man page for details.
|
|||
func ioctlIfreqData(fd int, req uint, value *ifreqData) error { |
|||
// The memory layout of IfreqData (type-safe) and ifreq (not type-safe) are
|
|||
// identical so pass *IfreqData directly.
|
|||
return ioctlPtr(fd, req, unsafe.Pointer(value)) |
|||
} |
|||
|
|||
// IoctlKCMClone attaches a new file descriptor to a multiplexor by cloning an
|
|||
// existing KCM socket, returning a structure containing the file descriptor of
|
|||
// the new socket.
|
|||
func IoctlKCMClone(fd int) (*KCMClone, error) { |
|||
var info KCMClone |
|||
if err := ioctlPtr(fd, SIOCKCMCLONE, unsafe.Pointer(&info)); err != nil { |
|||
return nil, err |
|||
} |
|||
|
|||
return &info, nil |
|||
} |
|||
|
|||
// IoctlKCMAttach attaches a TCP socket and associated BPF program file
|
|||
// descriptor to a multiplexor.
|
|||
func IoctlKCMAttach(fd int, info KCMAttach) error { |
|||
return ioctlPtr(fd, SIOCKCMATTACH, unsafe.Pointer(&info)) |
|||
} |
|||
|
|||
// IoctlKCMUnattach unattaches a TCP socket file descriptor from a multiplexor.
|
|||
func IoctlKCMUnattach(fd int, info KCMUnattach) error { |
|||
return ioctlPtr(fd, SIOCKCMUNATTACH, unsafe.Pointer(&info)) |
|||
} |
|||
|
|||
// IoctlLoopGetStatus64 gets the status of the loop device associated with the
|
|||
// file descriptor fd using the LOOP_GET_STATUS64 operation.
|
|||
func IoctlLoopGetStatus64(fd int) (*LoopInfo64, error) { |
|||
var value LoopInfo64 |
|||
if err := ioctlPtr(fd, LOOP_GET_STATUS64, unsafe.Pointer(&value)); err != nil { |
|||
return nil, err |
|||
} |
|||
return &value, nil |
|||
} |
|||
|
|||
// IoctlLoopSetStatus64 sets the status of the loop device associated with the
|
|||
// file descriptor fd using the LOOP_SET_STATUS64 operation.
|
|||
func IoctlLoopSetStatus64(fd int, value *LoopInfo64) error { |
|||
return ioctlPtr(fd, LOOP_SET_STATUS64, unsafe.Pointer(value)) |
|||
} |
@ -0,0 +1,74 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build zos && s390x
|
|||
// +build zos,s390x
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"runtime" |
|||
"unsafe" |
|||
) |
|||
|
|||
// ioctl itself should not be exposed directly, but additional get/set
|
|||
// functions for specific types are permissible.
|
|||
|
|||
// IoctlSetInt performs an ioctl operation which sets an integer value
|
|||
// on fd, using the specified request number.
|
|||
func IoctlSetInt(fd int, req uint, value int) error { |
|||
return ioctl(fd, req, uintptr(value)) |
|||
} |
|||
|
|||
// IoctlSetWinsize performs an ioctl on fd with a *Winsize argument.
|
|||
//
|
|||
// To change fd's window size, the req argument should be TIOCSWINSZ.
|
|||
func IoctlSetWinsize(fd int, req uint, value *Winsize) error { |
|||
// TODO: if we get the chance, remove the req parameter and
|
|||
// hardcode TIOCSWINSZ.
|
|||
err := ioctl(fd, req, uintptr(unsafe.Pointer(value))) |
|||
runtime.KeepAlive(value) |
|||
return err |
|||
} |
|||
|
|||
// IoctlSetTermios performs an ioctl on fd with a *Termios.
|
|||
//
|
|||
// The req value is expected to be TCSETS, TCSETSW, or TCSETSF
|
|||
func IoctlSetTermios(fd int, req uint, value *Termios) error { |
|||
if (req != TCSETS) && (req != TCSETSW) && (req != TCSETSF) { |
|||
return ENOSYS |
|||
} |
|||
err := Tcsetattr(fd, int(req), value) |
|||
runtime.KeepAlive(value) |
|||
return err |
|||
} |
|||
|
|||
// IoctlGetInt performs an ioctl operation which gets an integer value
|
|||
// from fd, using the specified request number.
|
|||
//
|
|||
// A few ioctl requests use the return value as an output parameter;
|
|||
// for those, IoctlRetInt should be used instead of this function.
|
|||
func IoctlGetInt(fd int, req uint) (int, error) { |
|||
var value int |
|||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
|||
return value, err |
|||
} |
|||
|
|||
func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { |
|||
var value Winsize |
|||
err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
|||
return &value, err |
|||
} |
|||
|
|||
// IoctlGetTermios performs an ioctl on fd with a *Termios.
|
|||
//
|
|||
// The req value is expected to be TCGETS
|
|||
func IoctlGetTermios(fd int, req uint) (*Termios, error) { |
|||
var value Termios |
|||
if req != TCGETS { |
|||
return &value, ENOSYS |
|||
} |
|||
err := Tcgetattr(fd, &value) |
|||
return &value, err |
|||
} |
@ -0,0 +1,12 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build darwin && !ios
|
|||
// +build darwin,!ios
|
|||
|
|||
package unix |
|||
|
|||
func ptrace(request int, pid int, addr uintptr, data uintptr) error { |
|||
return ptrace1(request, pid, addr, data) |
|||
} |
@ -0,0 +1,12 @@ |
|||
// Copyright 2020 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build ios
|
|||
// +build ios
|
|||
|
|||
package unix |
|||
|
|||
func ptrace(request int, pid int, addr uintptr, data uintptr) (err error) { |
|||
return ENOTSUP |
|||
} |
@ -0,0 +1,16 @@ |
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
package unix |
|||
|
|||
// Round the length of a raw sockaddr up to align it properly.
|
|||
func cmsgAlignOf(salen int) int { |
|||
salign := SizeofPtr |
|||
if SizeofPtr == 8 && !supportsABI(_dragonflyABIChangeVersion) { |
|||
// 64-bit Dragonfly before the September 2019 ABI changes still requires
|
|||
// 32-bit aligned access to network subsystem.
|
|||
salign = 4 |
|||
} |
|||
return (salen + salign - 1) & ^(salign - 1) |
|||
} |
@ -0,0 +1,47 @@ |
|||
// Copyright 2019 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build aix || darwin || freebsd || linux || netbsd || openbsd || solaris || zos
|
|||
// +build aix darwin freebsd linux netbsd openbsd solaris zos
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"runtime" |
|||
) |
|||
|
|||
// Round the length of a raw sockaddr up to align it properly.
|
|||
func cmsgAlignOf(salen int) int { |
|||
salign := SizeofPtr |
|||
|
|||
// dragonfly needs to check ABI version at runtime, see cmsgAlignOf in
|
|||
// sockcmsg_dragonfly.go
|
|||
switch runtime.GOOS { |
|||
case "aix": |
|||
// There is no alignment on AIX.
|
|||
salign = 1 |
|||
case "darwin", "ios", "illumos", "solaris": |
|||
// NOTE: It seems like 64-bit Darwin, Illumos and Solaris
|
|||
// kernels still require 32-bit aligned access to network
|
|||
// subsystem.
|
|||
if SizeofPtr == 8 { |
|||
salign = 4 |
|||
} |
|||
case "netbsd", "openbsd": |
|||
// NetBSD and OpenBSD armv7 require 64-bit alignment.
|
|||
if runtime.GOARCH == "arm" { |
|||
salign = 8 |
|||
} |
|||
// NetBSD aarch64 requires 128-bit alignment.
|
|||
if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { |
|||
salign = 16 |
|||
} |
|||
case "zos": |
|||
// z/OS socket macros use [32-bit] sizeof(int) alignment,
|
|||
// not pointer width.
|
|||
salign = SizeofInt |
|||
} |
|||
|
|||
return (salen + salign - 1) & ^(salign - 1) |
|||
} |
@ -1,26 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// +build aix darwin dragonfly freebsd linux netbsd openbsd solaris
|
|||
|
|||
package unix |
|||
|
|||
func itoa(val int) string { // do it here rather than with fmt to avoid dependency
|
|||
if val < 0 { |
|||
return "-" + uitoa(uint(-val)) |
|||
} |
|||
return uitoa(uint(val)) |
|||
} |
|||
|
|||
func uitoa(val uint) string { |
|||
var buf [32]byte // big enough for int64
|
|||
i := len(buf) - 1 |
|||
for val >= 10 { |
|||
buf[i] = byte(val%10 + '0') |
|||
i-- |
|||
val /= 10 |
|||
} |
|||
buf[i] = byte(val + '0') |
|||
return string(buf[i:]) |
|||
} |
@ -1,63 +0,0 @@ |
|||
// Copyright 2009 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// +build 386,darwin
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"syscall" |
|||
) |
|||
|
|||
func setTimespec(sec, nsec int64) Timespec { |
|||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)} |
|||
} |
|||
|
|||
func setTimeval(sec, usec int64) Timeval { |
|||
return Timeval{Sec: int32(sec), Usec: int32(usec)} |
|||
} |
|||
|
|||
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
|||
func Gettimeofday(tv *Timeval) (err error) { |
|||
// The tv passed to gettimeofday must be non-nil
|
|||
// but is otherwise unused. The answers come back
|
|||
// in the two registers.
|
|||
sec, usec, err := gettimeofday(tv) |
|||
tv.Sec = int32(sec) |
|||
tv.Usec = int32(usec) |
|||
return err |
|||
} |
|||
|
|||
func SetKevent(k *Kevent_t, fd, mode, flags int) { |
|||
k.Ident = uint32(fd) |
|||
k.Filter = int16(mode) |
|||
k.Flags = uint16(flags) |
|||
} |
|||
|
|||
func (iov *Iovec) SetLen(length int) { |
|||
iov.Len = uint32(length) |
|||
} |
|||
|
|||
func (msghdr *Msghdr) SetControllen(length int) { |
|||
msghdr.Controllen = uint32(length) |
|||
} |
|||
|
|||
func (cmsg *Cmsghdr) SetLen(length int) { |
|||
cmsg.Len = uint32(length) |
|||
} |
|||
|
|||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
|||
|
|||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
|||
// of darwin/386 the syscall is called sysctl instead of __sysctl.
|
|||
const SYS___SYSCTL = SYS_SYSCTL |
|||
|
|||
//sys Fstat(fd int, stat *Stat_t) (err error) = SYS_FSTAT64
|
|||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_FSTATAT64
|
|||
//sys Fstatfs(fd int, stat *Statfs_t) (err error) = SYS_FSTATFS64
|
|||
//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) = SYS_GETDIRENTRIES64
|
|||
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT64
|
|||
//sys Lstat(path string, stat *Stat_t) (err error) = SYS_LSTAT64
|
|||
//sys Stat(path string, stat *Stat_t) (err error) = SYS_STAT64
|
|||
//sys Statfs(path string, stat *Statfs_t) (err error) = SYS_STATFS64
|
@ -1,64 +0,0 @@ |
|||
// Copyright 2015 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"syscall" |
|||
) |
|||
|
|||
func setTimespec(sec, nsec int64) Timespec { |
|||
return Timespec{Sec: int32(sec), Nsec: int32(nsec)} |
|||
} |
|||
|
|||
func setTimeval(sec, usec int64) Timeval { |
|||
return Timeval{Sec: int32(sec), Usec: int32(usec)} |
|||
} |
|||
|
|||
//sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error)
|
|||
func Gettimeofday(tv *Timeval) (err error) { |
|||
// The tv passed to gettimeofday must be non-nil
|
|||
// but is otherwise unused. The answers come back
|
|||
// in the two registers.
|
|||
sec, usec, err := gettimeofday(tv) |
|||
tv.Sec = int32(sec) |
|||
tv.Usec = int32(usec) |
|||
return err |
|||
} |
|||
|
|||
func SetKevent(k *Kevent_t, fd, mode, flags int) { |
|||
k.Ident = uint32(fd) |
|||
k.Filter = int16(mode) |
|||
k.Flags = uint16(flags) |
|||
} |
|||
|
|||
func (iov *Iovec) SetLen(length int) { |
|||
iov.Len = uint32(length) |
|||
} |
|||
|
|||
func (msghdr *Msghdr) SetControllen(length int) { |
|||
msghdr.Controllen = uint32(length) |
|||
} |
|||
|
|||
func (cmsg *Cmsghdr) SetLen(length int) { |
|||
cmsg.Len = uint32(length) |
|||
} |
|||
|
|||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic
|
|||
|
|||
// SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions
|
|||
// of darwin/arm the syscall is called sysctl instead of __sysctl.
|
|||
const SYS___SYSCTL = SYS_SYSCTL |
|||
|
|||
//sys Fstat(fd int, stat *Stat_t) (err error)
|
|||
//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
|
|||
//sys Fstatfs(fd int, stat *Statfs_t) (err error)
|
|||
//sys getfsstat(buf unsafe.Pointer, size uintptr, flags int) (n int, err error) = SYS_GETFSSTAT
|
|||
//sys Lstat(path string, stat *Stat_t) (err error)
|
|||
//sys Stat(path string, stat *Stat_t) (err error)
|
|||
//sys Statfs(path string, stat *Statfs_t) (err error)
|
|||
|
|||
func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { |
|||
return 0, ENOSYS |
|||
} |
@ -0,0 +1,63 @@ |
|||
// Copyright 2022 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
//go:build riscv64 && freebsd
|
|||
// +build riscv64,freebsd
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"syscall" |
|||
"unsafe" |
|||
) |
|||
|
|||
func setTimespec(sec, nsec int64) Timespec { |
|||
return Timespec{Sec: sec, Nsec: nsec} |
|||
} |
|||
|
|||
func setTimeval(sec, usec int64) Timeval { |
|||
return Timeval{Sec: sec, Usec: usec} |
|||
} |
|||
|
|||
func SetKevent(k *Kevent_t, fd, mode, flags int) { |
|||
k.Ident = uint64(fd) |
|||
k.Filter = int16(mode) |
|||
k.Flags = uint16(flags) |
|||
} |
|||
|
|||
func (iov *Iovec) SetLen(length int) { |
|||
iov.Len = uint64(length) |
|||
} |
|||
|
|||
func (msghdr *Msghdr) SetControllen(length int) { |
|||
msghdr.Controllen = uint32(length) |
|||
} |
|||
|
|||
func (msghdr *Msghdr) SetIovlen(length int) { |
|||
msghdr.Iovlen = int32(length) |
|||
} |
|||
|
|||
func (cmsg *Cmsghdr) SetLen(length int) { |
|||
cmsg.Len = uint32(length) |
|||
} |
|||
|
|||
func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
|||
var writtenOut uint64 = 0 |
|||
_, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) |
|||
|
|||
written = int(writtenOut) |
|||
|
|||
if e1 != 0 { |
|||
err = e1 |
|||
} |
|||
return |
|||
} |
|||
|
|||
func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) |
|||
|
|||
func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { |
|||
ioDesc := PtraceIoDesc{Op: int32(req), Offs: uintptr(unsafe.Pointer(addr)), Addr: uintptr(unsafe.Pointer(&out[0])), Len: uint64(countin)} |
|||
err = ptrace(PT_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) |
|||
return int(ioDesc.Len), err |
|||
} |
@ -0,0 +1,79 @@ |
|||
// Copyright 2021 The Go Authors. All rights reserved.
|
|||
// Use of this source code is governed by a BSD-style
|
|||
// license that can be found in the LICENSE file.
|
|||
|
|||
// illumos system calls not present on Solaris.
|
|||
|
|||
//go:build amd64 && illumos
|
|||
// +build amd64,illumos
|
|||
|
|||
package unix |
|||
|
|||
import ( |
|||
"unsafe" |
|||
) |
|||
|
|||
func bytes2iovec(bs [][]byte) []Iovec { |
|||
iovecs := make([]Iovec, len(bs)) |
|||
for i, b := range bs { |
|||
iovecs[i].SetLen(len(b)) |
|||
if len(b) > 0 { |
|||
iovecs[i].Base = &b[0] |
|||
} else { |
|||
iovecs[i].Base = (*byte)(unsafe.Pointer(&_zero)) |
|||
} |
|||
} |
|||
return iovecs |
|||
} |
|||
|
|||
//sys readv(fd int, iovs []Iovec) (n int, err error)
|
|||
|
|||
func Readv(fd int, iovs [][]byte) (n int, err error) { |
|||
iovecs := bytes2iovec(iovs) |
|||
n, err = readv(fd, iovecs) |
|||
return n, err |
|||
} |
|||
|
|||
//sys preadv(fd int, iovs []Iovec, off int64) (n int, err error)
|
|||
|
|||
func Preadv(fd int, iovs [][]byte, off int64) (n int, err error) { |
|||
iovecs := bytes2iovec(iovs) |
|||
n, err = preadv(fd, iovecs, off) |
|||
return n, err |
|||
} |
|||
|
|||
//sys writev(fd int, iovs []Iovec) (n int, err error)
|
|||
|
|||
func Writev(fd int, iovs [][]byte) (n int, err error) { |
|||
iovecs := bytes2iovec(iovs) |
|||
n, err = writev(fd, iovecs) |
|||
return n, err |
|||
} |
|||
|
|||
//sys pwritev(fd int, iovs []Iovec, off int64) (n int, err error)
|
|||
|
|||
func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { |
|||
iovecs := bytes2iovec(iovs) |
|||
n, err = pwritev(fd, iovecs, off) |
|||
return n, err |
|||
} |
|||
|
|||
//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4
|
|||
|
|||
func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { |
|||
var rsa RawSockaddrAny |
|||
var len _Socklen = SizeofSockaddrAny |
|||
nfd, err = accept4(fd, &rsa, &len, flags) |
|||
if err != nil { |
|||
return |
|||
} |
|||
if len > SizeofSockaddrAny { |
|||
panic("RawSockaddrAny too small") |
|||
} |
|||
sa, err = anyToSockaddr(fd, &rsa) |
|||
if err != nil { |
|||
Close(nfd) |
|||
nfd = 0 |
|||
} |
|||
return |
|||
} |
File diff suppressed because it is too large
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue