github.com/go-darwin/sys@v0.0.0-20220510002607-68fd01f054ca/kern_return.go (about)

     1  // Copyright 2021 The Go Darwin Authors
     2  // SPDX-License-Identifier: BSD-3-Clause
     3  
     4  //go:build darwin
     5  // +build darwin
     6  
     7  package sys
     8  
     9  // KernErrno returns common boxed Errno values, to prevent
    10  // allocations at runtime.
    11  func KernErrno(e KernReturn) error {
    12  	switch e {
    13  	case 0:
    14  		return KernSuccess
    15  	default:
    16  		return KernReturn(e)
    17  	}
    18  }
    19  
    20  // Error returns a string representation of the KernReturn.
    21  func (e KernReturn) Error() string {
    22  	if 0 <= int(e) && int(e) < len(errors) {
    23  		s := errors[e]
    24  		if s != "" {
    25  			return s
    26  		}
    27  	}
    28  
    29  	return "errno " + itoa(int(e))
    30  }
    31  
    32  // KernReturn Error table.
    33  var errors = [...]string{
    34  	0x1:   "specified address is not currently valid",
    35  	0x2:   "specified memory is valid, but does not permit therequired forms of access",
    36  	0x3:   "address range specified is already in use, or no address range of the size specified could be found",
    37  	0x4:   "function requested was not applicable to this type of argument, or an argument is invalid",
    38  	0x5:   "function could not be performed. A catch-all",
    39  	0x6:   "system resource could not be allocated to fulfill this request",
    40  	0x7:   "bogus access restriction",
    41  	0x8:   "task in question does not hold receive rights for the port argument",
    42  	0x9:   "during a page fault, the target address refers to a memory object that has been destroyed",
    43  	0xa:   "during a page fault, the memory object indicated that the data could not be returned",
    44  	0xb:   "receive right is already a member of the portset",
    45  	0xc:   "receive right is not a member of a port set",
    46  	0xd:   "name already denotes a right in the task",
    47  	0xe:   "operation was aborted",
    48  	0xf:   "name doesn't denote a right in the task",
    49  	0x10:  "target task isn't an active task",
    50  	0x11:  "name denotes a right, but not an appropriate right",
    51  	0x12:  "blatant range error",
    52  	0x13:  "operation would overflow limit on user-references",
    53  	0x14:  "supplied (port) capability is improper",
    54  	0x15:  "task already has send or receive rights for the port under another name",
    55  	0x16:  "target host isn't actually a host",
    56  	0x18:  "attempt was made to supply precious data for memory that is already present in a memory object",
    57  	0x19:  "page was requested of a memory manager via memory_object_data_request for an object using a MEMORY_OBJECT_COPY_CALL strategy",
    58  	0x1a:  "strategic copy was attempted of an object upon which a quicker copy is now possible",
    59  	0x1b:  "argument applied to assert processor set privilege was not a processor set control port",
    60  	0x1c:  "specified scheduling attributes exceed the thread's limits",
    61  	0x1d:  "specified scheduling policy is not currently enabled for the processor set",
    62  	0x1e:  "external memory manager failed to initialize the memory object",
    63  	0x1f:  "thread is attempting to wait for an event for which there is already a waiting thread",
    64  	0x20:  "attempt was made to destroy the default processor set",
    65  	0x21:  "attempt was made to fetch an exception port that is protected, or to abort a thread while processing a protected exception",
    66  	0x22:  "ledger was required but not supplied",
    67  	0x23:  "port was not a memory cache control port",
    68  	0x24:  "argument supplied to assert security privilege was not a host security port",
    69  	0x25:  "thread_depress_abort was called on a thread which was not currently depressed",
    70  	0x26:  "object has been terminated and is no longer available",
    71  	0x27:  "lock set has been destroyed and is no longer available",
    72  	0x28:  "thread holding the lock terminated before releasing the lock",
    73  	0x29:  "lock is already owned by another thread",
    74  	0x2a:  "lock is already owned by the calling thread",
    75  	0x2b:  "semaphore has been destroyed and is no longer available",
    76  	0x2c:  "return from RPC indicating the target server was terminated before it successfully replied",
    77  	0x2d:  "terminate an orphaned activation",
    78  	0x2e:  "allow an orphaned activation to continue executing",
    79  	0x2f:  "empty thread activation (No thread linked to it)",
    80  	0x30:  "remote node down or inaccessible",
    81  	0x31:  "signalled thread was not actually waiting",
    82  	0x32:  "some thread-oriented operation (semaphore_wait) timed out",
    83  	0x33:  "during a page fault, indicates that the page was rejected as a result of a signature check",
    84  	0x34:  "requested property cannot be changed at this time",
    85  	0x35:  "provided buffer is of insufficient size for the requested data",
    86  	0x36:  "KC on which the function is operating is missing",
    87  	0x37:  "KC on which the function is operating is invalid",
    88  	0x100: "maximum return value allowable",
    89  }