sys

package module
v0.0.0-...-9fa3b98 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package sys provides the low-level system call.

Index

Constants

View Source
const (
	Sizeof_C_short    = unsafe.Sizeof(new(c_short))
	Sizeof_C_int      = unsafe.Sizeof(new(c_int))
	Sizeof_C_int8     = unsafe.Sizeof(new(c_int8))
	Sizeof_C_int16    = unsafe.Sizeof(new(c_int16))
	Sizeof_C_int32    = unsafe.Sizeof(new(c_int32))
	Sizeof_C_int64    = unsafe.Sizeof(new(c_int64))
	Sizeof_C_long     = unsafe.Sizeof(new(c_long))
	Sizeof_C_longLong = unsafe.Sizeof(new(c_longLong))
	Sizeof_C_uint     = unsafe.Sizeof(new(c_uint))
	Sizeof_C_uint8    = unsafe.Sizeof(new(c_uint8))
	Sizeof_C_uint16   = unsafe.Sizeof(new(c_uint16))
	Sizeof_C_uint32   = unsafe.Sizeof(new(c_uint32))
	Sizeof_C_uint64   = unsafe.Sizeof(new(c_uint64))
	Sizeof_C_char     = unsafe.Sizeof(new(c_char))
	Sizeof_C_float    = unsafe.Sizeof(new(c_float))
	Sizeof_C_double   = unsafe.Sizeof(new(c_double))
)

list of common C types size.

View Source
const (
	KernMemoryError kernReturn = 0xa
)
View Source
const TmpStringBufSize = 32

TmpStringBufSize constant is known to the compiler. There is no fundamental theory behind this number.

Variables

This section is empty.

Functions

func BytePtrFromString

func BytePtrFromString(s string) *byte

BytePtrFromString returns a pointer to a NUL-terminated array of bytes containing the text of s.

func BytePtrToString

func BytePtrToString(p *byte) string

BytePtrToString takes a pointer to a sequence of text and returns the corresponding string. If the pointer is nil, it returns the empty string. It assumes that the text sequence is terminated at a zero byte; if the zero byte is not present, the program may crash.

func ByteSliceFromString

func ByteSliceFromString(s string) []byte

ByteSliceFromString returns a NUL-terminated slice of bytes containing the text of s.

func ByteSliceToString

func ByteSliceToString(s []byte) string

ByteSliceToString returns a string form of the text represented by the slice s, with a terminating NUL and any bytes after the NUL removed.

func CgoCall

func CgoCall(fn unsafe.Pointer, arg uintptr) int32

CgoCall calls cgo fn function.

func Concatstring2

func Concatstring2(buf *TmpBuf, a0, a1 string) string

Concatstring2 concats two strings.

func Concatstring3

func Concatstring3(buf *TmpBuf, a0, a1, a2 string) string

Concatstring3 concats three strings.

func Concatstring4

func Concatstring4(buf *TmpBuf, a0, a1, a2, a3 string) string

Concatstring4 concats four strings.

func Concatstring5

func Concatstring5(buf *TmpBuf, a0, a1, a2, a3, a4 string) string

Concatstring5 concats five strings.

func Concatstrings

func Concatstrings(buf *TmpBuf, a []string) string

Concatstrings implements a Go string concatenation x+y+z+...

The operands are passed in the slice a. If buf != nil, the compiler has determined that the result does not escape the calling function, so the string data can be stored in buf if small enough.

func CrossCall2

func CrossCall2(fn, a unsafe.Pointer, n int32, ctxt uintptr)

CrossCall2 called by C code generated by cmd/cgo. Saves C callee-saved registers and calls cgocallback with three arguments. fn is the PC of a func(a unsafe.Pointer) function.

func FindNull

func FindNull(s *byte) int

FindNull finds NULL in *byte type s.

func FindNullW

func FindNullW(s *uint16) int

FindNullW finds NULL in *uint16 type s.

func FuncPC

func FuncPC(f interface{}) uintptr

FuncPC returns the entry PC of the function f. It assumes that f is a func value. Otherwise the behavior is undefined.

CAREFUL: In programs with plugins, funcPC can return different values for the same function (because there are actually multiple copies of the same function in the address space). To be safe, don't use the results of this function in any == expression. It is only safe to use the result as an address at which to start executing code.

func FuncPCABI0

func FuncPCABI0(f interface{}) uintptr

FuncPCABI0 returns the entry PC of the function f, which must be a direct reference of a function defined as ABI0. Otherwise it is a compile-time error.

Implemented as a compile intrinsic.

func FuncPCABIInternal

func FuncPCABIInternal(f interface{}) uintptr

FuncPCABIInternal returns the entry PC of the function f. If f is a direct reference of a function, it must be defined as ABIInternal. Otherwise it is a compile-time error. If f is not a direct reference of a defined function, it assumes that f is a func value. Otherwise the behavior is undefined.

Implemented as a compile intrinsic.

func GoBytes

func GoBytes(p *byte, n int) (b []byte)

GoBytes converts a n length C pointer to Go byte slice. This function used by C.GoBytes.

func GoString

func GoString(p *byte) string

GoString converts a byte pointer to a string. This function **NOT** used by C.GoString. GostringNoCopy does.

func GoStringW

func GoStringW(strw *uint16) string

GoStringW converts a uint16 pointer to a string.

func GostringN

func GostringN(p *byte, l int) string

GostringN converts a l length C string to Go string. This function used by C.GostringN.

func GostringNoCopy

func GostringNoCopy(str *byte) string

GostringNoCopy converts a C string to a Go string. This function used by C.GoString.

func IntString

func IntString(buf *[4]byte, v int64) (s string)

IntString converts a int64 v to string.

func KernErrno

func KernErrno(e KernReturn) error

KernErrno returns common boxed Errno values, to prevent allocations at runtime.

func LibcCall

func LibcCall(fn, arg unsafe.Pointer) int32

LibcCall call fn with arg as its argument. Return what fn returns. fn is the raw pc value of the entry point of the desired function. Switches to the system stack, if not already there. Preserves the calling point as the location where a profiler traceback will begin.

func Noescape

func Noescape(p unsafe.Pointer) unsafe.Pointer

Noescape hides a pointer from escape analysis.

Noescape is the identity function but escape analysis doesn't think the output depends on the input.

Noescape is inlined and currently compiles down to zero instructions.

func RawByteSlice

func RawByteSlice(size int) (b []byte)

RawByteSlice allocates a new byte slice. The byte slice is not zeroed.

func RawRuneSlice

func RawRuneSlice(size int) (b []rune)

RawRuneSlice allocates a new rune slice. The rune slice is not zeroed.

func RawString

func RawString(size int) (s string, b []byte)

RawString allocates storage for a new string. The returned string and byte slice both refer to the same storage. The storage is not zeroed. Callers should use b to set the string contents and then drop b.

func RawStringTmp

func RawStringTmp(buf *TmpBuf, l int) (s string, b []byte)

RawStringTmp returns a "string" referring to the actual []byte bytes.

func RawSyscall

func RawSyscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err unix.Errno)

RawSyscall calls a function in libc on behalf of the syscall package.

func RawSyscall6

func RawSyscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err unix.Errno)

RawSyscall6 calls a function in libc on behalf of the syscall package.

func RawSyscall9

func RawSyscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err unix.Errno)

RawSyscall9 calls a function in libc on behalf of the syscall package.

func SliceByteToString

func SliceByteToString(buf *TmpBuf, ptr *byte, n int) (str string)

SliceByteToString converts a byte slice to a string.

It is inserted by the compiler into generated code. ptr is a pointer to the first element of the slice; n is the length of the slice.

Buf is a fixed-size buffer for the result, it is not nil if the result does not escape.

func SliceByteToStringTmp

func SliceByteToStringTmp(ptr *byte, n int) (str string)

SliceByteToStringTmp returns a "string" referring to the actual []byte bytes.

Callers need to ensure that the returned string will not be used after the calling goroutine modifies the original slice or synchronizes with another goroutine.

The function is only called when instrumenting and otherwise intrinsified by the compiler.

Some internal compiler optimizations use this function.

  • Used for m[T1{... Tn{..., string(k), ...} ...}] and m[string(k)] where k is []byte, T1 to Tn is a nesting of struct and array literals.
  • Used for "<"+string(b)+">" concatenation where b is []byte.
  • Used for string(b)=="foo" comparison where b is []byte.

func SliceRuneToString

func SliceRuneToString(buf *TmpBuf, a []rune) string

SliceRuneToString converts a rune slice to a string.

func StringDataOnStack

func StringDataOnStack(s string) bool

StringDataOnStack reports whether the string's data is stored on the current goroutine's stack.

func StringToSliceByte

func StringToSliceByte(buf *TmpBuf, s string) []byte

StringToSliceByte converts a string to a byte slice.

func StringToSliceRune

func StringToSliceRune(buf *[TmpStringBufSize]rune, s string) []rune

StringToSliceRune converts a string to a rune slice.

func Syscall

func Syscall(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err unix.Errno)

Syscall calls a function in libc on behalf of the syscall package.

syscall takes a pointer to a struct like:

struct {
 fn    uintptr
 a1    uintptr
 a2    uintptr
 a3    uintptr
 r1    uintptr
 r2    uintptr
 err   uintptr
}

Syscall must be called on the g0 stack with the C calling convention (use libcCall).

Syscall expects a 32-bit result and tests for 32-bit -1 to decide there was an error.

func Syscall6

func Syscall6(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err unix.Errno)

Syscall6 calls a function in libc on behalf of the syscall package.

Syscall6 takes a pointer to a struct like:

struct {
 fn    uintptr
 a1    uintptr
 a2    uintptr
 a3    uintptr
 a4    uintptr
 a5    uintptr
 a6    uintptr
 r1    uintptr
 r2    uintptr
 err   uintptr
}

Syscall6 must be called on the g0 stack with the C calling convention (use libcCall).

Syscall6 expects a 32-bit result and tests for 32-bit -1 to decide there was an error.

func Syscall6X

func Syscall6X(fn, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err unix.Errno)

Syscall6X calls a function in libc on behalf of the syscall package.

Syscall6X takes a pointer to a struct like:

struct {
 fn    uintptr
 a1    uintptr
 a2    uintptr
 a3    uintptr
 a4    uintptr
 a5    uintptr
 a6    uintptr
 r1    uintptr
 r2    uintptr
 err   uintptr
}

Syscall6X must be called on the g0 stack with the C calling convention (use libcCall).

Syscall6X is like syscall6 but expects a 64-bit result and tests for 64-bit -1 to decide there was an error.

func Syscall9

func Syscall9(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err unix.Errno)

Syscall9 calls a function in libc on behalf of the syscall package.

Syscall9 takes a pointer to a struct like:

struct {
 fn    uintptr
 a1    uintptr
 a2    uintptr
 a3    uintptr
 a4    uintptr
 a5    uintptr
 a6    uintptr
 a7    uintptr
 a8    uintptr
 a9    uintptr
 r1    uintptr
 r2    uintptr
 err   uintptr
}

Syscall9 must be called on the g0 stack with the C calling convention (use libcCall).

Syscall9 expects a 32-bit result and tests for 32-bit -1 to decide there was an error.

func SyscallPtr

func SyscallPtr(fn, a1, a2, a3 uintptr) (r1, r2 uintptr, err unix.Errno)

SyscallPtr is like syscallX except that the libc function reports an error by returning NULL and setting errno.

Types

type C_char

type C_char = c_char

list of common C types.

type C_double

type C_double = c_double

list of common C types.

type C_float

type C_float = c_float

list of common C types.

type C_int

type C_int = c_int

list of common C types.

type C_int16

type C_int16 = c_int16

list of common C types.

type C_int32

type C_int32 = c_int32

list of common C types.

type C_int64

type C_int64 = c_int64

list of common C types.

type C_int8

type C_int8 = c_int8

list of common C types.

type C_long

type C_long = c_long

list of common C types.

type C_longLong

type C_longLong = c_longLong

list of common C types.

type C_short

type C_short = c_short

list of common C types.

type C_size_t

type C_size_t = c_size_t

list of common C types.

type C_uint

type C_uint = c_uint

list of common C types.

type C_uint16

type C_uint16 = c_uint16

list of common C types.

type C_uint32

type C_uint32 = c_uint32

list of common C types.

type C_uint64

type C_uint64 = c_uint64

list of common C types.

type C_uint8

type C_uint8 = c_uint8

list of common C types.

type KernReturn

type KernReturn = kernReturn

KernReturn represents a kern_return_t.

const (
	KernSuccess KernReturn = kernSuccess

	// KernInvalidAddress specified address is not currently valid.
	KernInvalidAddress KernReturn = kernInvalidAddress

	// KernProtectionFailure specified memory is valid, but does not permit therequired forms of access.
	KernProtectionFailure KernReturn = kernProtectionFailure

	// KernNoSpace is the address range specified is already in use, or
	// no address range of the size specified could be
	// found.
	KernNoSpace KernReturn = kernNoSpace

	// KernInvalidArgument is the function requested was not applicable to this
	// type of argument, or an argument is invalid.
	KernInvalidArgument KernReturn = kernInvalidArgument

	// KernFailure is the function could not be performed. A catch-all.
	KernFailure KernReturn = kernFailure

	// KernResourceShortage a system resource could not be allocated to fulfill
	// this request.
	// This failure may not be permanent.
	KernResourceShortage KernReturn = kernResourceShortage

	// KernNoAccess bogus access restriction.
	KernNoAccess KernReturn = kernNoAccess

	// KernNotReceiver is the task in question does not hold receive rights for the port argument.
	KernNotReceiver KernReturn = kernNotReceiver

	// KernMemoryFailure during a page fault, the target address refers to a memory object that has been destroyed.
	// This failure is permanent.
	KernMemoryFailure KernReturn = kernMemoryFailure

	// KernAlreadyInSet is the receive right is already a member of the portset.
	KernAlreadyInSet KernReturn = kernAlreadyInSet

	// KernNotInSet is the receive right is not a member of a port set.
	KernNotInSet KernReturn = kernNotInSet

	// KernNameExists is the name already denotes a right in the task.
	KernNameExists KernReturn = kernNameExists

	// KernAborted is the operation was aborted.
	// Ipc code will catch this and reflect it as a message error.
	KernAborted KernReturn = kernAborted

	// KernInvalidNames is the name doesn't denote a right in the task.
	KernInvalidName KernReturn = kernInvalidName

	// KernInvalidTask target task isn't an active task.
	KernInvalidTask KernReturn = kernInvalidTask

	// kernInvalidRight is the name denotes a right, but not an appropriate right.
	KernInvalidRight KernReturn = kernInvalidRight

	// KernInvalidValue a blatant range error.
	KernInvalidValue KernReturn = kernInvalidValue

	// KernUrefsOverflow operation would overflow limit on user-references.
	KernUrefsOverflow KernReturn = kernUrefsOverflow

	// KernInvalidCapability is the supplied (port) capability is improper.
	KernInvalidCapability KernReturn = kernInvalidCapability

	// KernRightExists is the task already has send or receive rights for the port under another name.
	KernRightExists KernReturn = kernRightExists

	// KernInvalidHost target host isn't actually a host.
	KernInvalidHost KernReturn = kernInvalidHost

	// KernMemoryPresent an attempt was made to supply "precious" data
	// for memory that is already present in a
	// memory object.
	KernMemoryPresent KernReturn = kernMemoryPresent

	// KernMemoryDataMoved a page was requested of a memory manager via
	// memory_object_data_request for an object using
	// a MEMORY_OBJECT_COPY_CALL strategy, with the
	// VM_PROT_WANTS_COPY flag being used to specify
	// that the page desired is for a copy of the
	// object, and the memory manager has detected
	// the page was pushed into a copy of the object
	// while the kernel was walking the shadow chain
	// from the copy to the object. This error code
	// is delivered via memory_object_data_error
	// and is handled by the kernel (it forces the
	// kernel to restart the fault). It will not be
	// seen by users.
	KernMemoryDataMoved KernReturn = kernMemoryDataMoved

	// KernMemoryRestartCopy a strategic copy was attempted of an object
	// upon which a quicker copy is now possible.
	// The caller should retry the copy using
	// vm_object_copy_quickly.
	//
	// This error code is seen only by the kernel.
	KernMemoryRestartCopy KernReturn = kernMemoryRestartCopy

	// KernInvalidProcessorSet an argument applied to assert processor set privilege
	// was not a processor set control port.
	KernInvalidProcessorSet KernReturn = kernInvalidProcessorSet

	// KernPolicyLimit is the specified scheduling attributes exceed the thread's
	// limits.
	KernPolicyLimit KernReturn = kernPolicyLimit

	// KernInvalidPolicy is the specified scheduling policy is not currently
	// enabled for the processor set.
	KernInvalidPolicy KernReturn = kernInvalidPolicy

	// KernInvalidObject is the external memory manager failed to initialize the
	// memory object.
	KernInvalidObject KernReturn = kernInvalidObject

	// KernAlreadyWaiting a thread is attempting to wait for an event for which
	// there is already a waiting thread.
	KernAlreadyWaiting KernReturn = kernAlreadyWaiting

	// KernDefaultSet an attempt was made to destroy the default processor
	// set.
	KernDefaultSet KernReturn = kernDefaultSet

	// KernExceptionProtected an attempt was made to fetch an exception port that is
	// protected, or to abort a thread while processing a
	// protected exception.
	KernExceptionProtected KernReturn = kernExceptionProtected

	// KernInvalidLedger a ledger was required but not supplied.
	KernInvalidLedger KernReturn = kernInvalidLedger

	// KernInvalidMemoryControl is the port was not a memory cache control port.
	KernInvalidMemoryControl KernReturn = kernInvalidMemoryControl

	// KernInvalidSecurity an argument supplied to assert security privilege
	// was not a host security port.
	KernInvalidSecurity KernReturn = kernInvalidSecurity

	// KernNotDepressed thread_depress_abort was called on a thread which
	// was not currently depressed.
	KernNotDepressed KernReturn = kernNotDepressed

	// KernTerminated object has been terminated and is no longer available.
	KernTerminated KernReturn = kernTerminated

	// KernLockSetDestroyed lock set has been destroyed and is no longer available.
	KernLockSetDestroyed KernReturn = kernLockSetDestroyed

	// KernLockUnstable is the thread holding the lock terminated before releasing
	// the lock.
	KernLockUnstable KernReturn = kernLockUnstable

	// KernLockOwned is the lock is already owned by another thread.
	KernLockOwned KernReturn = kernLockUnstable

	// KernLockOwnedSelf is the lock is already owned by the calling thread.
	KernLockOwnedSelf KernReturn = kernLockOwnedSelf

	// KernSemaphoreDestroyed semaphore has been destroyed and is no longer available.
	KernSemaphoreDestroyed KernReturn = kernSemaphoreDestroyed

	// KernRPCServerTerminated return from RPC indicating the target server was
	// terminated before it successfully replied.
	KernRPCServerTerminated KernReturn = kernRPCServerTerminated

	// KernRPCTerminateOrphan terminate an orphaned activation.
	KernRPCTerminateOrphan KernReturn = kernRPCTerminateOrphan

	// KernRPCContinueOrphan allow an orphaned activation to continue executing.
	KernRPCContinueOrphan KernReturn = kernRPCContinueOrphan

	// KernNotSupported empty thread activation (No thread linked to it).
	KernNotSupported KernReturn = kernRPCContinueOrphan

	// KernNodeDown remote node down or inaccessible.
	KernNodeDown KernReturn = kernNodeDown

	// KernNotWaiting a signalled thread was not actually waiting.
	KernNotWaiting KernReturn = kernNotWaiting

	// KernOperationTimedOut some thread-oriented operation (semaphore_wait) timed out.
	KernOperationTimedOut KernReturn = kernOperationTimedOut

	// KernCodesignError during a page fault, indicates that the page was rejected
	// as a result of a signature check.
	KernCodesignError KernReturn = kernCodesignError

	// KernPolicyStatic is the requested property cannot be changed at this time.
	KernPolicyStatic KernReturn = kernPolicyStatic

	// KernInsufficientBufferSize is the provided buffer is of insufficient size for the requested data.
	KernInsufficientBufferSize KernReturn = kernInsufficientBufferSize

	// KernDenied denied by security policy.
	KernDenied KernReturn = kernDenied

	// KernMissingKC is the KC on which the function is operating is missing.
	KernMissingKC KernReturn = kernMissingKC

	// KernInvalidKC is the KC on which the function is operating is invalid.
	KernInvalidKC KernReturn = kernInvalidKC

	// KernReturnMax maximum return value allowable.
	KernReturnMax KernReturn = kernReturnMax
)

list of KernReturn errors.

func (KernReturn) Error

func (e KernReturn) Error() string

Error returns a string representation of the KernReturn.

type StringStruct

type StringStruct struct {
	// contains filtered or unexported fields
}

StringStruct actual string type struct.

func StringStructOf

func StringStructOf(sp *string) *StringStruct

StringStructOf converts a sp to StringStruct.

type StringStructDWARF

type StringStructDWARF struct {
	// contains filtered or unexported fields
}

StringStructDWARF variant with *byte pointer type for DWARF debugging.

type TmpBuf

type TmpBuf [TmpStringBufSize]byte

TmpBuf is a temporary byte array.

Directories

Path Synopsis
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.
Package unsafeheader contains header declarations for the Go runtime's slice and string implementations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL