Platform-specific accessors for the C runtime error-number storage used by system and runtime wrappers. Import paths: linux/errno, macos/errno, and windows/errno.
Platform Code bindings
__errno_location
(-- errnoRef) Linux Code binding that calls the C runtime accessor and returns an Int32 Ref to the calling thread's errno storage.Read timing and overwrite
- The current value is most meaningful immediately after the relevant failing call.
- Later library or platform calls in the same thread may overwrite the stored value before it is read.
- Snapshot an error immediately with
saved: errno new;before intervening calls. This retains the previous numeric value independently of later overwrites. saved: errno;saves a reference instead, so later writes remain visible throughsaved.- The accessor neither clears the stored error nor converts it into a success or failure result.
Thread-local behavior
- Linux
errnoreturns a borrowed mutableInt32reference acquired at run time. Calls in different threads obtain their respective locations. - A saved reference stays bound to the location acquired; it is not retargeted when another thread dereferences it.
- Do not free the reference or use it after its owning thread exits.
Examples
Linux runtime example
"String" use
"control" use
"linux/errno" use
{} Int32 {} [
123 errno set
errno new toString print
LF print
0
] "main" exportFunction
Expected Output
123
See also
- file: File I/O helpers for byte arrays and String values.
- linux/socket · macos/socket: Linux and macOS socket declarations, constants, address schemas, and imported functions.
- linux/posix · macos/posix: POSIX process, timing, descriptor, and context declarations.
- linux/Process · macos/Process · windows/Process: Cross-platform process wrapper with explicit creation, waiting, and termination helpers.
- windows/kernel32: Kernel32 declarations for synchronization, process, thread, file, and timing helpers.
- windows/ws2_32: Winsock2 declarations for sockets, overlapped I/O, and address-resolution helpers.