abla/sys/linux

Generated from source.

Import with import "abla/sys/linux".

Source: abla/sys/linux/entry.ab

ablaLinuxSyscall (extern)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
noescape extern:"intrinsic" fun ablaLinuxSyscall(
    number: int,
    argument0: int,
    argument1: int,
    argument2: int,
    argument3: int,
    argument4: int,
    argument5: int
): int

Invokes a Linux-numbered system call through the host adapter and returns its kernel result or a negative errno.

linuxSyscall0 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall0(number: int): int

Invokes syscall number without arguments. Returns the kernel result, with negative errno on failure.

linuxSyscall1 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall1(number: int, argument0: int): int

Invokes syscall number with argument0. Returns the kernel result, with negative errno on failure.

linuxHostIsWindows (fun)

trusted fun linuxHostIsWindows(): bool

Reports whether the program runs on Windows, where the hosted runtime translates these Linux calls: found out once, by the Windows runtime's own call 4001 (spawn), which answers a null block with EINVAL where every other target answers ENOSYS. (A compiler intrinsic would say it at compile time; the pinned bootstrap compiler does not know one yet.)

linuxSyscall2 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall2(number: int, argument0: int, argument1: int): int

Invokes syscall number with argument0 through argument1. Returns the kernel result, with negative errno on failure.

linuxSyscall3 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall3(
    number: int,
    argument0: int,
    argument1: int,
    argument2: int
): int

Invokes syscall number with argument0 through argument2. Returns the kernel result, with negative errno on failure.

linuxSyscall4 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall4(
    number: int,
    argument0: int,
    argument1: int,
    argument2: int,
    argument3: int
): int

Invokes syscall number with argument0 through argument3. Returns the kernel result, with negative errno on failure.

linuxSyscall5 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall5(
    number: int,
    argument0: int,
    argument1: int,
    argument2: int,
    argument3: int,
    argument4: int
): int

Invokes syscall number with argument0 through argument4. Returns the kernel result, with negative errno on failure.

linuxSyscall6 (fun)

@__abla_trusted_only("error: call the abla/sys wrapper for this system call, or wrap it in a trusted function that checks its arguments")
trusted fun linuxSyscall6(
    number: int,
    argument0: int,
    argument1: int,
    argument2: int,
    argument3: int,
    argument4: int,
    argument5: int
): int

Invokes syscall number with argument0 through argument5. Returns the kernel result, with negative errno on failure.

LinuxFileDescriptor (class)

class LinuxFileDescriptor(val descriptor: int)

Stores a raw file descriptor or a negative error code. Call close explicitly to release an open descriptor.

linuxWrite (fun)

trusted fun linuxWrite(descriptor: int, text: string): int

Attempts one write of text to descriptor. Returns bytes written, which can be fewer than requested, or negative errno.

linuxWriteStandardOutput (fun)

fun linuxWriteStandardOutput(text: string): int

Writes to standard output and returns the byte count, which may be short, or a negative errno.

linuxWriteStandardError (fun)

fun linuxWriteStandardError(text: string): int

Writes to standard error and returns the byte count, which may be short, or a negative errno.

linuxOpen (fun)

trusted fun linuxOpen(path: string, flags: int = 0, mode: int = 0): LinuxFileDescriptor

Opens path relative to the working directory using kernel flags. mode supplies the creation permissions when requested by the flags. Returns a descriptor or a negative errno in the wrapper.

LinuxFileDescriptor.write (extension fun)

fun LinuxFileDescriptor.write(text: string): int

Attempts one write of text. Returns bytes written or negative errno. A short write does not consume the remaining bytes.

linuxCountPanic (fun)

trusted fun linuxCountPanic(count: int, maximum: int): never

A read's count above the bytes its caller asked for is a runtime or kernel that lies (Windows once answered a failed recv with 4294967295: a 4 GiB string over a small buffer, or a 4 GiB copy off the stack). It ends the process with status 101 and a message, as panic does, and never becomes a string, a copy or an offset: every reader that turns a count into either one calls linuxCheckCount (or linuxExactString, which does).

linuxCheckCount (fun)

fun linuxCheckCount(measured: int, maximum: int): void

Ends the process (status 101, a message on standard error) when measured is larger than the maximum bytes the read asked for.

linuxExactString (fun)

trusted fun linuxExactString(var buffer: NativeByteBuffer, length: int, capacity: int): string

The first length bytes of buffer as a string that holds no more memory than that: the buffer itself when the read filled over half of it, else a copy (adoptString keeps the whole allocation alive for as long as the string lives, so a 9-byte file read with a 4 MB limit held 4 MB).

linuxReadCount (fun)

fun linuxReadCount(maximum: int): int

The count of one read asked for maximum bytes: 0 for none or a negative count, at most 1 GiB (a read may return fewer bytes than asked, so this keeps "up to maximum"). The buffer it sizes is the count + 1, which for the largest int wrapped to a negative size and a 1-byte allocation, while the kernel was asked for 2^63 - 1 bytes.

linuxStreamReadSize (fun)

fun linuxStreamReadSize(count: int): int

How many bytes one read from a stream (a socket, a pipe, a terminal) asks for when the caller allows count (linuxReadCount's): at most 1 MiB. A read may return fewer bytes than asked, so "up to count" holds, and the buffer is not sized by a large maximum: a read allowed 1 GiB allocated 1 GiB before any byte arrived.

linuxReadSize (fun)

trusted fun linuxReadSize(descriptor: int, count: int): int

How many bytes one read from descriptor asks for when the caller allows count (linuxReadCount's), so the buffer is sized by what is there and not by the caller's maximum. For a regular file with a size: what is left of it after the current position, plus one byte so the end shows as a short read, never more than count. For anything else (a socket, a pipe, a terminal, a file whose size reads 0 such as /proc's, or when fstat fails): linuxStreamReadSize.

LinuxFileDescriptor.read (extension fun)

trusted fun LinuxFileDescriptor.read(maximum: int = 65536): string

Attempts one read of up to maximum bytes. Returns the bytes read or an empty string on EOF or error.

LinuxFileDescriptor.close (extension fun)

trusted fun LinuxFileDescriptor.close(): int

Closes the raw descriptor and returns zero or negative errno. The wrapper retains the descriptor number.

linuxProcessId (fun)

trusted fun linuxProcessId(): int

Returns the process ID reported by the kernel.

linuxReadFile (fun)

fun linuxReadFile(path: string, maximum: int = 1048576): string

Opens path, reads up to maximum bytes in one read, and closes it. Returns an empty string on open or read failure or EOF.

Built from Abla v0.2.79 source ba5d6b7d. Examples and generated signatures follow that source revision.