Raw bindings for most `POSIX` APIs. Targets glibc and musl compatibility. APIs that have been left out are due to not being useful, being fully replaced (and better) by other Odin packages, or when one of the targets hasn't implemented the API or option. The struct fields that are cross-platform are documented with `[PSX]`. Accessing these fields on one target should be the same on others. Other fields are implementation specific. The parts of POSIX that Windows implements are also supported here, but other symbols are undefined on Windows targets. Most macros have been reimplemented in Odin with inlined functions. Unimplemented headers: - aio.h - complex.h | See `core:c/libc` and our own complex types - cpio.h - ctype.h | See `core:c/libc` for most of it - ndbm.h - fenv.h - float.h - fmtmsg.h - ftw.h - semaphore.h | See `core:sync` - inttypes.h | See `core:c` - iso646.h | Impossible - math.h | See `core:c/libc` - mqueue.h | Targets don't seem to have implemented it - regex.h | See `core:text/regex` - search.h | Not useful in Odin - spawn.h | Use `fork`, `execve`, etc. - stdarg.h | See `core:c/libc` - stdint.h | See `core:c` - stropts.h - syslog.h - pthread.h | Only the actual threads API is bound, see `core:sync` for synchronization primitives - string.h | Most of this is not useful in Odin, only a select few symbols are bound - tar.h - tgmath.h - trace.h - wchar.h - wctype.h

Platform-specific package target: darwin_arm64

Collection Info

View Source
Collection
core
Path
sys/posix
Entries
1271

Source Files

Constants

639

ARG_MAX #

Source
ARG_MAX :: 1024 * 1024

AIO_LISTIO_MAX :: sysconf(._AIO_LISTIO_MAX) AIO_MAX :: sysconf(._AIO_MAX) AIO_PRIO_DELTA_MAX :: sysconf(._AIO_PRIO_DELTA_MAX)

BSDLY #

Source
BSDLY :: transmute(COutput_Flags)tcflag_t(_BSDLY)

\b delay mask

CHILD_MAX #

Source
CHILD_MAX :: 266

ATEXIT_MAX :: sysconf(._ATEXIT_MAX)

CRDLY #

Source
CRDLY :: transmute(COutput_Flags)tcflag_t(_CRDLY)

\r delay mask

CSIZE #

Source
CSIZE :: transmute(CControl_Flags)tcflag_t(_CSIZE)

character size mask

FD_SETSIZE #

Source
FD_SETSIZE :: #config(POSIX_FD_SETSIZE, 256 when ODIN_OS == .NetBSD else 1024)

Maximum number of file descriptors in the fd_set structure.

FFDLY #

Source
FFDLY :: transmute(COutput_Flags)tcflag_t(_FFDLY)

form feed delay mask

IOV_MAX #

Source
IOV_MAX :: 1024

DELAYTIMER_MAX :: sysconf(._DELAYTIMER_MAX) HOST_NAME_MAX :: sysconf(._HOST_NAME_MAX)

IPPORT_RESERVED #

Source
IPPORT_RESERVED :: 1024

The highest reserved port number.

LINK_MAX #

Source
LINK_MAX :: 32767

FILESIZEBITS :: pathconf(".", ._FILESIZEBITS)

MAP_ANONYMOUS #

Source
MAP_ANONYMOUS :: 0x0020 when ODIN_OS == .Linux else 0x1000

MS_SYNC #

Source
MS_SYNC :: Sync_Flags{Sync_Flags_Bits(log2(_MS_SYNC))}

NLDLY #

Source
NLDLY :: transmute(COutput_Flags)tcflag_t(_NLDLY)

\n delay mask

PAGESIZE #

Source
PAGESIZE :: PAGE_SIZE

LOGIN_NAME_MAX :: sysconf(._LOGIN_NAME_MAX) MQ_OPEN_MAX :: sysconf(._MQ_OPEN_MAX) MQ_PRIO_MAX :: sysconf(._MQ_PRIO_MAX)

PTHREAD_CANCEL_ASYNCHRONOUS #

Source
PTHREAD_CANCEL_ASYNCHRONOUS :: 0x00

PTHREAD_DESTRUCTOR_ITERATIONS #

Source
PTHREAD_DESTRUCTOR_ITERATIONS :: 4

PTHREAD_STACK_MIN #

Source
PTHREAD_STACK_MIN :: 16384 when ODIN_ARCH == .arm64 else 8192

RLIMIT_NOFILE #

Source
RLIMIT_NOFILE :: 7 when ODIN_OS == .Linux else 8

RTLD_LOCAL #

Source
RTLD_LOCAL :: RTLD_Flags{RTLD_Flag_Bits(log2(_RTLD_LOCAL))}

S_IRWXG #

Source
S_IRWXG :: mode_t{.IRGRP, .IWGRP, .IXGRP}

Read, write, execute group.

S_IRWXO #

Source
S_IRWXO :: mode_t{.IROTH, .IWOTH, .IXOTH}

Read, write, execute other.

S_IRWXU #

Source
S_IRWXU :: mode_t{.IRUSR, .IWUSR, .IXUSR}

Read, write, execute user.

SCHED_OTHER #

Source
SCHED_OTHER :: 1

SCHED_SPORADIC :: 3 NOTE: not a thing on freebsd, netbsd and probably others, leaving it out

SHMLBA #

Source
SHMLBA :: 16 * 1024 when ODIN_ARCH == .arm64 else 4096

SIG_DFL #

Source
SIG_DFL :: libc.SIG_DFL

Request for default signal handling.

SIG_ERR #

Source
SIG_ERR :: libc.SIG_ERR

Return value from signal() in case of error.

SIG_HOLD #

Source
SIG_HOLD :: rawptr(uintptr(5))

Request that signal be held

SIG_IGN #

Source
SIG_IGN :: libc.SIG_IGN

Request that signal be ignored.

TABDLY #

Source
TABDLY :: transmute(COutput_Flags)tcflag_t(_TABDLY)

horizontal tab delay mask

VTDLY #

Source
VTDLY :: transmute(COutput_Flags)tcflag_t(_VTDLY)

vertical tab delay mask

Config Values

1

FD_SETSIZE #

Source
FD_SETSIZE :: #config(POSIX_FD_SETSIZE, 256 when ODIN_OS == .NetBSD else 1024)

Maximum number of file descriptors in the fd_set structure.

Types

200

D_Type #

Source
D_Type :: D_Type

NOTE: `d_type` is not a POSIX standard field, but all targets we support add it.

nl_item_t #

Source
nl_item_t :: distinct nl_item_t

NOTE: declared with `_t` so we can enumerate the real `nl_info`.

Procedures

416

a64l #

Source
a64l :: proc "c" (s: cstring) -> i64 ---

Takes a pointer to a radix-64 representation, in which the first digit is the least significant, and return the corresponding long value. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/a64l.html ]]

accept #

Source
accept :: proc "c" (socket: FD, address: ^sockaddr, address_len: ^socklen_t) -> FD ---

Extracts the first connection on the queue of pending connections. Blocks (if not O_NONBLOCK) if there is no pending connection. Returns: -1 (setting errno) on failure, file descriptor of accepted socket otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/accept.html ]]

access #

Source
@(link_name=LACCESS)
access :: proc "c" (path: cstring, amode: bit_set[Mode_Flag_Bits] = F_OK) -> result ---

Checks the file named by the pathname pointed to by the path argument for accessibility according to the bit pattern contained in amode. Example: if (posix.access("/tmp/myfile", posix.F_OK) != .OK) { fmt.printfln("/tmp/myfile access check failed: %v", posix.strerror(posix.errno())) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html ]]

alarm #

Source
alarm :: proc "c" (seconds: u32) -> u32 ---

The alarm() function shall cause the system to generate a SIGALRM signal for the process after the number of realtime seconds specified by seconds have elapsed. Processor scheduling delays may prevent the process from handling the signal as soon as it is generated. If seconds is 0, a pending alarm request, if any, is canceled. Returns: the time left on the previous alarm() or 0 [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/alarm.html ]]

alphasort #

Source
@(link_name=LALPHASORT)
alphasort :: proc "c" ([^]^dirent, [^]^dirent) -> i32 ---

can be used as the comparison function for the scandir() function to sort the directory entries, d1 and d2, into alphabetical order. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html ]]

asctime_r #

Source
asctime_r :: proc "c" (tm: ^tm, buf: [^]u8) -> cstring ---

Convert the broken down time in the structure to a string form: Sun Sep 16 01:03:52 1973. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/asctime_r.html ]]

basename #

Source
@(link_name=LBASENAME)
basename :: proc "c" (path: cstring) -> cstring ---

Takes the pathname pointed to by path and return a pointer to the final component of the pathname, deleting any trailing '/' characters. NOTE: may modify input, so don't give it string literals. Returns: a string that might be a modification of the input string or a static string overwritten by subsequent calls Example: tests := []string{ "usr", "usr/", "", "/", "//", "///", "/usr/", "/usr/lib", "//usr//lib//", "/home//dwc//test", } tbl: table.Table table.init(&tbl) table.header(&tbl, "input", "dirname", "basename") for test in tests { din := strings.clone_to_cstring(test); defer delete(din) dir := strings.clone_from_cstring(posix.dirname(din)) bin := strings.clone_to_cstring(test); defer delete(bin) base := strings.clone_from_cstring(posix.basename(bin)) table.row(&tbl, test, dir, base) } table.write_plain_table(os.stream_from_handle(os.stdout), &tbl) Output: +----------------+----------+--------+ |input |dirname |basename| +----------------+----------+--------+ |usr |. |usr | |usr/ |. |usr | | |. |. | |/ |/ |/ | |// |/ |/ | |/// |/ |/ | |/usr/ |/ |usr | |/usr/lib |/usr |lib | |//usr//lib// |//usr |lib | |/home//dwc//test|/home//dwc|test | +----------------+----------+--------+ [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/basename.html ]]

bind #

Source
bind :: proc "c" (socket: FD, address: ^sockaddr, address_len: socklen_t) -> result ---

Assigns a local socket address to the socket. Example: sfd := posix.socket(.UNIX, .STREAM) if sfd == -1 { /* Handle error */ } addr: posix.sockaddr_un addr.sun_family = .UNIX copy(addr.sun_path[:], "/somepath\x00") /* unlink the socket before binding in case of previous runs not cleaning up the socket */ posix.unlink("/somepath") if posix.bind(sfd, (^posix.sockaddr)(&addr), size_of(addr)) != .OK { /* Handle error */ } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/bind.html ]]

cfgetispeed #

Source
cfgetispeed :: proc "c" (termios_p: ^termios) -> speed_t ---

Get the input baud rate. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetispeed.html ]]

cfgetospeed #

Source
cfgetospeed :: proc "c" (termios_p: ^termios) -> speed_t ---

Get the output baud rate. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/cfgetospeed.html ]]

cfsetispeed #

Source
cfsetispeed :: proc "c" (termios_p: ^termios, rate: speed_t) -> result ---

Set the input baud rate. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetispeed.html ]]

cfsetospeed #

Source
cfsetospeed :: proc "c" (termios_p: ^termios, rate: speed_t) -> result ---

Set the output baud rate. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/cfsetospeed.html ]]

chdir #

Source
@(link_name=LCHDIR)
chdir :: proc "c" (path: cstring) -> result ---

Causes the directory named by path to become the current working directory. Example: if (posix.chdir("/tmp") == .OK) { fmt.println("changed current directory to /tmp") } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/chdir.html ]]

chmod #

Source
chmod :: proc "c" (path: cstring, mode: bit_set[Mode_Bits]) -> result ---

Change the mode of a file. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html ]]

chown #

Source
@(link_name=LCHOWN)
chown :: proc "c" (path: cstring, owner: uid_t, group: gid_t) -> result ---

Changes the user and group ownership of a file. If owner or group is specified as (uid_t)-1 or (gid_t)-1, respectively, the corresponding ID of the file shall not be changed. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html ]]

clock_getres #

Source
@(link_name=LCLOCKGETRES)
clock_getres :: proc "c" (clock_id: Clock, res: ^timespec) -> result ---

Returns the resolution of any clock. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html ]]

clock_gettime #

Source
@(link_name=LCLOCKGETTIME)
clock_gettime :: proc "c" (clock_id: Clock, tp: ^timespec) -> result ---

Returns the current value tp for the specified clock, clock_id. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html ]]

clock_settime #

Source
@(link_name=LCLOCKSETTIME)
clock_settime :: proc "c" (clock_id: Clock, tp: ^timespec) -> result ---

Sets the specified clock's time. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html ]]

close #

Source
close :: proc "c" (fildes: FD) -> result ---

Deallocates the file descriptor indicated by fildes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/close.html ]]

closedir #

Source
closedir :: proc "c" (dirp: DIR) -> result ---

Close the directory stream referred to by the argument dirp. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/closedir.html ]]

CMSG_DATA #

Source
CMSG_DATA :: proc "contextless" (cmsg: ^cmsghdr) -> [^]u8 {…}

Returns a pointer to the data array.

CMSG_FIRSTHDR #

Source
CMSG_FIRSTHDR :: proc "contextless" (mhdr: ^msghdr) -> ^cmsghdr {…}

Returns a pointer to the first cmsghdr or nil.

confstr #

Source
confstr :: proc "c" (name: CS, buf: [^]u8, len: uint) -> uint ---

Return configuration-defined string values. Its use and purpose are similar to sysconf(), but it is used where string values rather than numeric values are returned. Returns: 0 (setting errno) if `name` is invalid, need `buf` of `len` bytes if `buf` is `nil`, amount of bytes added to buf otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/confstr.html ]]

connect #

Source
connect :: proc "c" (socket: FD, address: ^sockaddr, address_len: socklen_t) -> result ---

Attempt to make a connection. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/connect.html ]]

creat #

Source
creat :: proc "c" (path: cstring, mode: bit_set[Mode_Bits]) -> FD ---

Implemented as `return open(path, O_WRONLY|O_CREAT|O_TRUNC, mode);` [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/creat.html ]]

crypt #

Source
crypt :: proc "c" (key: cstring, salt: cstring) -> cstring ---

A string encoding function. The algorithm is implementation-defined. The use of crypt() for anything other than password hashing is not recommended. Returns: a static string overwritten by subsequent calls, `nil` (setting errno) on failure

ctermid #

Source
ctermid :: proc "c" (s: [^]u8) -> cstring ---

Generates a string that, when used as a pathname, refers to the current controlling terminal for the current process. If s is nil, the returned string might be static and overwritten by subsequent calls or other factors. If s is not nil, s is assumed len(s) >= L_ctermid. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctermid.html ]]

ctime_r #

Source
@(link_name=LCTIMER)
ctime_r :: proc "c" (clock: ^time_t, buf: [^]u8) -> cstring ---

Convert a time value to a date and time string in the same format as asctime(). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ctime_r.html ]]

dirfd #

Source
dirfd :: proc "c" (dirp: DIR) -> FD ---

Return a file descriptor referring to the same directory as the dirp argument. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirfd.html ]]

dirname #

Source
dirname :: proc "c" (path: cstring) -> cstring ---

Takes a string that contains a pathname, and returns a string that is a pathname of the parent directory of that file. NOTE: may modify input, so don't give it string literals. Returns: a string that might be a modification of the input string or a static string overwritten by subsequent calls See example for basename(). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dirname.html ]]

dlclose #

Source
dlclose :: proc "c" (handle: Symbol_Table) -> i32 ---

inform the system that the object referenced by a handle returned from a previous dlopen() invocation is no longer needed by the application. Returns: 0 on success, non-zero on failure (use dlerror() for more information) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlclose.html ]]

dlerror #

Source
dlerror :: proc "c" () -> cstring ---

return a null-terminated character string (with no trailing <newline>) that describes the last error that occurred during dynamic linking processing. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlerror.html ]]

dlopen #

Source
dlopen :: proc "c" (file: cstring, mode: bit_set[RTLD_Flag_Bits]) -> Symbol_Table ---

Make the symbols (function identifiers and data object identifiers) in the executable object file specified by file available to the calling program. Returns: a reference to the symbol table on success, nil on failure (use dlerror() for more information) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlopen.html ]]

dlsym #

Source
dlsym :: proc "c" (handle: Symbol_Table, name: cstring) -> rawptr ---

Obtain the address of a symbol (a function identifier or a data object identifier) defined in the symbol table identified by the handle argument. Returns: the address of the matched symbol on success, nil on failure (use dlerror() for more information) Example: handle := posix.dlopen("/usr/home/me/libfoo.so", posix.RTLD_LOCAL + { .RTLD_LAZY }) defer posix.dlclose(handle) if handle == nil { panic(string(posix.dlerror())) } foo: proc(a, b: int) -> int foo = auto_cast posix.dlsym(handle, "foo") if foo == nil { panic(string(posix.dlerror())) } fmt.printfln("foo(%v, %v) == %v", 1, 2, foo(1, 2)) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html ]]

dprintf #

Source
dprintf :: proc "c" (fildse: FD, format: cstring, args: ..any) -> i32 ---

Equivalent to fprintf but output is written to the file descriptor. Return: number of bytes written, negative (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dprintf.html ]]

drand48 #

Source
drand48 :: proc "c" () -> f64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: non-negative, double-precision, floating-point values, uniformly distributed over the interval [0.0,1.0) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

dup #

Source
dup :: proc "c" (fildes: FD) -> FD ---

Returns a new file descriptor referring to the one given, sharing locks, clearing CLOEXEC. Returns: -1 (setting errno) on failure, the new file descriptor on success Example: // Redirecting stdout to a file: file := posix.open("/tmp/out", { .RDWR }) posix.close(1) posix.dup(file) posix.close(file) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html ]]

dup2 #

Source
dup2 :: proc "c" (fildes, fildes2: FD) -> FD ---

Causes the file descriptor fildes2 to refer to the same open file description as the file descriptor fildes and to share any locks, and shall return fildes2. Returns: -1 (setting errno) on failure, fildes2 on success Example: // Redirecting stderr to stdout: posix.dup2(1, 2) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dup.html ]]

encrypt #

Source
encrypt :: proc "c" (block: [^]u8, decode: b32) ---

An implementation-defined encoding algorithm. The key generated by setkey() is used to encrypt the string block with encrypt(). block must be 64 bytes. decode controls if the block is encoded or decoded. May set errno to ENOSYS if the functionality is not supported. Example: block: [64]byte copy(block[:], "Hello, World!") posix.set_errno(.NONE) posix.encrypt(raw_data(block[:]), decode=false) assert(posix.errno() == .NONE, "encrypt not supported") [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/encrypt.html ]]

endgrent #

Source
endgrent :: proc "c" () -> ! ---

Closes the group database. Checking status would be done by setting errno to 0, calling this, and checking errno. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/endgrent.html ]]

endhostent #

Source
endhostent :: proc "c" () -> ! ---

Closes the connection to the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sethostent.html ]]

endnetent #

Source
endnetent :: proc "c" () -> ! ---

Closes the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setnetent.html ]]

endprotoent #

Source
endprotoent :: proc "c" () -> ! ---

Closes the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setprotoent.html ]]

endpwent #

Source
endpwent :: proc "c" () -> ! ---

Closes the user database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpwent.html ]]

endservent #

Source
endservent :: proc "c" () -> ! ---

Closes the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setservent.html ]]

erand48 #

Source
erand48 :: proc "c" (xsubi: ^[3]u16) -> f64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: non-negative, double-precision, floating-point values, uniformly distributed over the interval [0.0,1.0) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

execl #

Source
execl :: proc "c" (path: cstring, arg0: cstring, args: ..cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. Takes arguments as varargs and the last of them must be nil. Example: ret := posix.execl("/bin/ls", "ls", "-l", nil) fmt.panicf("could not execute: %v %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

execle #

Source
execle :: proc "c" (path: cstring, arg0: cstring, args: ..any) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. Takes arguments as varargs and the last of them must be nil. After the arguments an array of environment strings (also nil terminated) is expected. Example: env := []cstring{ "HOME=/usr/home", "LOGNAME=home", nil, } ret := posix.execle("/bin/ls", "ls", cstring("-l"), cstring(nil), raw_data(env)) fmt.panicf("could not execute: %v", posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

execlp #

Source
execlp :: proc "c" (file: cstring, arg0: cstring, args: ..cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. If file does not contain a slash the PATH environment variable is searched for a matching file. Takes arguments as varargs and the last of them must be nil. Example: ret := posix.execlp("ls", "-l", cstring(nil)) fmt.panicf("could not execute: %v, %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

execv #

Source
execv :: proc "c" (path: cstring, argv: [^]cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. Takes arguments as an array which should be nil terminated. Example: args := []cstring{ "ls", "-l", nil } ret := posix.execv("/bin/ls", raw_data(args)) fmt.panicf("could not execute: %v, %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

execve #

Source
execve :: proc "c" (path: cstring, argv: [^]cstring, envp: [^]cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. Takes arguments as an array which should be nil terminated. Takes environment variables as an array which should be nil terminated. Example: cmd := []cstring{ "ls", "-l", nil } env := []cstring{ "HOME=/usr/home", "LOGNAME=home", nil } ret := posix.execve("/bin/ls", raw_data(cmd), raw_data(env)) fmt.panicf("could not execute: %v, %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

execvp #

Source
execvp :: proc "c" (file: cstring, argv: [^]cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. If file does not contain a slash the PATH environment variable is searched for a matching file. Takes arguments as an array which should be nil terminated. Example: cmd := []cstring{ "ls", "-l", nil } ret := posix.execvp("ls", raw_data(cmd)) fmt.panicf("could not execute: %v, %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

faccessat #

Source
faccessat :: proc "c" (fd: FD, path: cstring, amode: bit_set[Mode_Flag_Bits], flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to `access` but relative paths are resolved based on `fd`. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/access.html ]]

fchdir #

Source
fchdir :: proc "c" (fildes: FD) -> result ---

Equivalent to chdir but instead of a path the fildes is resolved to a directory. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchdir.html ]]

fchmod #

Source
fchmod :: proc "c" (fd: FD, mode: bit_set[Mode_Bits]) -> result ---

Equivalent to chmod but takes an open file descriptor. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchmod.html ]]

fchmodat #

Source
fchmodat :: proc "c" (fd: FD, path: cstring, mode: bit_set[Mode_Bits], flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to chmod but follows (or doesn't) symlinks based on the flag and resolves relative paths from the given fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html ]]

fchown #

Source
@(link_name=LFCHOWN)
fchown :: proc "c" (fildes: FD, owner: uid_t, mode: gid_t) -> result ---

Equivalent to chown expect that it takes a file descriptor. Example: fildes := posix.open("/home/cnd/mod1", {.RDWR}) pwd := posix.getpwnam("jones") grp := posix.getgrnam("cnd") posix.fchown(fildes, pwd.pw_uid, grp.gr_gid) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fchown.html ]]

fchownat #

Source
fchownat :: proc "c" (fildes: FD, path: cstring, owner: uid_t, group: gid_t, flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to fchown except that relative paths are based on the given fildes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/chown.html ]]

fcntl #

Source
fcntl :: proc "c" (fd: FD, cmd: FCNTL_Cmd, args: ..any) -> i32 ---

Perform the operations on open files. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html ]]

fdatasync #

Source
fdatasync :: proc "c" (fd: FD) -> result ---

Forcec all currently queued I/O operations associated with the file indicated by file descriptor fildes to the synchronized I/O completion state. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdatasync.html ]]

fdopen #

Source
fdopen :: proc "c" (fildes: FD, mode: cstring) -> ^FILE ---

Associate a stream with a file descriptor. Returns: nil (setting errno) on failure, the stream on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdopen.html ]]

fdopendir #

Source
@(link_name="fdopendir" + INODE_SUFFIX)
fdopendir :: proc "c" (dirp: FD) -> DIR ---

Equivalent to the opendir() function except that the directory is specified by a file descriptor rather than by a name. The file offset associated with the file descriptor at the time of the call determines which entries are returned. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdopendir.html ]]

fexecve #

Source
fexecve :: proc "c" (fd: FD, argv: [^]cstring, envp: [^]cstring) -> i32 ---

The exec family of functions shall replace the current process image with a new process image. The new image shall be constructed from a regular, executable file called the new process image file. There shall be no return from a successful exec, because the calling process image is overlaid by the new process image. Equivalent to execve but takes a file descriptor instead of a path. Example: ls := posix.open("/bin/ls", { .EXEC }) cmd := []cstring{ "ls", "-l", nil } env := []cstring{ "HOME=/usr/home", "LOGNAME=home", nil } ret := posix.fexecve(ls, raw_data(cmd), raw_data(env)) fmt.panicf("could not execute: %v, %v", ret, posix.strerror(posix.errno())) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

fileno #

Source
fileno :: proc "c" (stream: ^FILE) -> FD ---

Map a stream pointer to a file descriptor. Returns: the file descriptor or -1 (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fileno.html ]]

flockfile #

Source
flockfile :: proc "c" (file: ^FILE) ---

Locks a file. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html ]]

fmemopen #

Source
fmemopen :: proc "c" (buf: [^]u8, size: uint, mode: cstring) -> ^FILE ---

Open a memory buffer stream. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html ]]

fnmatch #

Source
fnmatch :: proc "c" (pattern: cstring, string: cstring, flags: bit_set[FNM_Flag_Bits]) -> i32 ---

Match patterns as described in XCU [[ Patterns Matching a Single Character; https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_01 ]] // and [[ Patterns Matching Multiple Characters; https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_02 ]]. It checks the string specified by the string argument to see if it matches the pattern specified by the pattern argument. Returns: 0 when matched. if there is no match, fnmatch() shall return FNM_NOMATCH. Non-zero on other errors. Example: assert(posix.fnmatch("*.odin", "foo.odin", {}) == 0) assert(posix.fnmatch("*.txt", "foo.odin", {}) == posix.FNM_NOMATCH) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html ]]

fork #

Source
fork :: proc "c" () -> pid_t ---

The fork() function shall create a new process. The new process (child process) shall be an exact copy of the calling process (parent process). With some exceptions outlined below. Result: -1 (setting errno) on failure, otherwise 0 to the child process and the child process id to the parent process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html ]]

fpathconf #

Source
fpathconf :: proc "c" (fildes: FD, name: PC) -> i64 ---

Equivalent to pathconf but takes a file descriptor instead of a path. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html ]]

freeaddrinfo #

Source
freeaddrinfo :: proc "c" (ai: ^addrinfo) ---

Frees the given address info linked list. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html ]]

fseeko #

Source
fseeko :: proc "c" (stream: ^FILE, offset: off_t, whence: Whence) -> result ---

Reposition a file-position indicator in a stream. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fseeko.html ]]

fstat #

Source
@(link_name=LFSTAT)
fstat :: proc "c" (fildes: FD, buf: ^stat_t) -> result ---

Obtain information about an open file. Follows symbol links. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html ]]

fstatat #

Source
@(link_name="fstatat" + INODE_SUFFIX)
fstatat :: proc "c" (fd: FD, path: cstring, buf: ^stat_t, flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to either stat or lstat (based on the SYMLINK_NOFOLLOW bit in flags) but resolves relative paths based on the given fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html ]]

fstatvfs #

Source
@(link_name=LFSTATVFS)
fstatvfs :: proc "c" (fildes: FD, buf: ^statvfs_t) -> result ---

Obtains information about the file system containing the fildes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html ]]

fsync #

Source
fsync :: proc "c" (fildes: FD) -> result ---

Requests that all data for the open file descriptor named by fildes is to be transferred to the storage device associated with the file described by fildes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fsync.html ]]

ftello #

Source
ftello :: proc "c" (^FILE) -> off_t ---

Return the file offset in a stream. Returns: the current file offset, -1 (setting errno) on error [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftello.html ]]

ftok #

Source
ftok :: proc "c" (path: cstring, id: i32) -> key_t ---

Generate an IPC key. Returns: -1 (setting errno) on failure, the key otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftok.html ]]

ftruncate #

Source
ftruncate :: proc "c" (fildes: FD, length: off_t) -> result ---

Truncates a file to the specified length. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ftruncate.html ]]

ftrylockfile #

Source
ftrylockfile :: proc "c" (file: ^FILE) -> i32 ---

Tries to lock a file. Returns: 0 if it could be locked, non-zero if it couldn't [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html ]]

funlockfile #

Source
funlockfile :: proc "c" (file: ^FILE) ---

Unlocks a file. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html ]]

futimens #

Source
futimens :: proc "c" (fd: FD, times: ^[2]timespec) -> result ---

Sets the file access and modification time of the given file descriptor. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html ]]

gai_strerror #

Source
gai_strerror :: proc "c" (ecode: Info_Errno) -> cstring ---

Get a textual description for the address info errors. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gai_strerror.html ]]

getaddrinfo #

Source
getaddrinfo :: proc "c" (nodename: cstring, servname: cstring, hints: ^addrinfo, res: ^^addrinfo) -> Info_Errno ---

Translate node/serv name and return a set of socket addresses and associated information to be used in creating a socket with which to address the specified service. Example: // The following (incomplete) program demonstrates the use of getaddrinfo() to obtain the // socket address structure(s) for the service named in the program's command-line argument. // The program then loops through each of the address structures attempting to create and bind // a socket to the address, until it performs a successful bind(). args := runtime.args__ if len(args) != 2 { fmt.eprintfln("Usage: %s port", args[0]) posix.exit(1) } hints: posix.addrinfo hints.ai_socktype = .DGRAM hints.ai_flags = { .PASSIVE } result: ^posix.addrinfo s := posix.getaddrinfo(nil, args[1], &hints, &result) if s != .NONE { fmt.eprintfln("getaddrinfo: %s", posix.gai_strerror(s)) posix.exit(1) } defer posix.freeaddrinfo(result) // Try each address until a successful bind(). rp: ^posix.addrinfo for rp = result; rp != nil; rp = rp.ai_next { sfd := posix.socket(rp.ai_family, rp.ai_socktype, rp.ai_protocol) if sfd == -1 { continue } if posix.bind(sfd, rp.ai_addr, rp.ai_addrlen) == 0 { // Success. break } posix.close(sfd) } if rp == nil { fmt.eprintln("Could not bind") posix.exit(1) } // Use the socket... [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html ]]

getc_unlocked #

Source
@(link_name=LGETC_UNLOCKED)
getc_unlocked :: proc "c" (stream: ^FILE) -> i32 ---

Equivalent to getc but unaffected by locks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getc_unlocked.html ]]

getchar_unlocked #

Source
@(link_name=LGETCHAR_UNLOCKED)
getchar_unlocked :: proc "c" () -> i32 ---

Equivalent to getchar but unaffected by locks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getc_unlocked.html ]]

getcwd #

Source
@(link_name=LGETCWD)
getcwd :: proc "c" (buf: [^]u8, size: uint) -> cstring ---

Places an absolute pathname of the current working directory into buf. Returns: buf as a cstring on success, nil (setting errno) on failure Example: size: int path_max := posix.pathconf(".", ._PATH_MAX) if path_max == -1 { size = 1024 } else if path_max > 10240 { size = 10240 } else { size = int(path_max) } buf: [dynamic]byte cwd: cstring for ; cwd == nil; size *= 2 { if err := resize(&buf, size); err != nil { fmt.panicf("allocation failure: %v", err) } cwd = posix.getcwd(raw_data(buf), len(buf)) if cwd == nil { errno := posix.errno() if errno != .ERANGE { fmt.panicf("getcwd failure: %v", posix.strerror(errno)) } } } fmt.println(path_max, cwd) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html ]]

getdate #

Source
getdate :: proc "c" (string: cstring) -> ^tm ---

Converts a string representation of a date or time into a broken-down time. Returns: nil (setting getdate_err) on failure, the broken-down time otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdate.html ]]

getdelim #

Source
getdelim :: proc "c" (lineptr: ^cstring, n: ^uint, delimiter: i32, stream: ^FILE) -> int ---

Read a delimited record from the stream. Returns: the number of bytes written or -1 on failure/EOF [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html ]]

getegid #

Source
getegid :: proc "c" () -> gid_t ---

Returns the effective group ID of the calling process. Returns: the ID, no failure is defined [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getegid.html ]]

geteuid #

Source
geteuid :: proc "c" () -> uid_t ---

Returns the effective user ID of the calling process. Returns: the ID, no failure is defined [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/geteuid.html ]]

getgid #

Source
getgid :: proc "c" () -> gid_t ---

Returns the real group ID of the calling process. Returns: the ID, no failure is defined [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgid.html ]]

getgrent #

Source
getgrent :: proc "c" () -> ^group ---

Returns a pointer to an entry of the group database. Opens the group database if it isn't. Returns: nil on failure (setting errno) or EOF (not setting errno), the entry otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/endgrent.html ]]

getgrgid #

Source
getgrgid :: proc "c" (gid: gid_t) -> ^group ---

Searches for an entry with a matching gid in the group database. Returns: nil (setting errno) on failure, a pointer to the entry on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrgid.html ]]

getgrgid_r #

Source
getgrgid_r :: proc "c" (gid: gid_t, grp: ^group, buffer: [^]u8, bufsize: uint, result: ^^group) -> Errno ---

Searches for an entry with a matching gid in the group database. Updates grp with the matching entry and stores it (or a nil pointer (setting errno)) into result. Strings are allocated into the given buffer, you can call `sysconf(._GETGR_R_SIZE_MAX)` for an appropriate size. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrgid.html ]]

getgrnam #

Source
getgrnam :: proc "c" (name: cstring) -> ^group ---

Searches for an entry with a matching gid in the group database. Returns: nil (setting errno) on failure, a pointer to the entry on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrnam.html ]]

getgrnam_r #

Source
getgrnam_r :: proc "c" (name: cstring, grp: ^group, buffer: [^]u8, bufsize: uint, result: ^^group) -> Errno ---

Searches for an entry with a matching gid in the group database. Updates grp with the matching entry and stores it (or a nil pointer (setting errno)) into result. Strings are allocated into the given buffer, you can call `sysconf(._GETGR_R_SIZE_MAX)` for an appropriate size. Example: length := posix.sysconf(._GETGR_R_SIZE_MAX) if length == -1 { length = 1024 } result: posix.group resultp: ^posix.group e: posix.Errno buffer: [dynamic]byte defer delete(buffer) for { mem_err := resize(&buffer, length) assert(mem_err == nil) e = posix.getgrnam_r("nobody", &result, raw_data(buffer), len(buffer), &resultp) if e != .ERANGE { break } length *= 2 assert(length > 0) } if e != .NONE { panic(string(posix.strerror(e))) } fmt.println(result) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgrnam.html ]]

getgroups #

Source
getgroups :: proc "c" (gidsetsize: i32, grouplist: [^]gid_t) -> i32 ---

Fills the grouplist array with the current supplementary group IDs of the calling process. Returns: -1 (setting errno) on failure, desired grouplist length if gidsetsize is 0, amount of IDs added otherwise Example: length := posix.getgroups(0, nil) if length == -1 { fmt.panicf("getgroups failure: %v", posix.strerror(posix.errno())) } groups := make([]posix.gid_t, length) or_else panic("allocation failure") if posix.getgroups(length, raw_data(groups)) != length { fmt.panicf("getgroups failure: %v", posix.strerror(posix.errno())) } fmt.println(groups) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getgroups.html ]]

gethostent #

Source
gethostent :: proc "c" () -> ^hostent ---

Reads the next entry in the database, opening and closing a connection as necessary. This reads /etc/hosts on most systems. Example: posix.sethostent(true) defer posix.endhostent() for ent := posix.gethostent(); ent != nil; ent = posix.gethostent() { fmt.println(ent) fmt.println(ent.h_addr_list[0][:ent.h_length]) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sethostent.html ]]

gethostid #

Source
gethostid :: proc "c" () -> i64 ---

Retrieves a 32-bit identifier for the current host. Returns: the ID, no failure is defined [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostid.html ]]

gethostname #

Source
gethostname :: proc "c" (name: [^]u8, namelen: uint) -> result ---

Returns the standard host name for the current machine. Host names are limited to HOST_NAME_MAX bytes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gethostname.html ]]

getitimer #

Source
@(link_name=LGETITIMER)
getitimer :: proc "c" (which: ITimer, value: ^itimerval) -> result ---

Store the current value of timer into value. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getitimer.html ]]

getline #

Source
getline :: proc "c" (lineptr: ^cstring, n: ^uint, stream: ^FILE) -> int ---

Read a line delimited record from the stream. Returns: the number of bytes written or -1 on failure/EOF Example: fp := posix.fopen(#file, "r") if fp == nil { posix.exit(1) } line: cstring length: uint for { read := posix.getline(&line, &length, fp) if read == -1 do break posix.printf("Retrieved line of length %zu :\n", read) posix.printf("%s", line) } if posix.ferror(fp) != 0 { /* handle error */ } posix.free(rawptr(line)) posix.fclose(fp) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html ]]

getlogin #

Source
getlogin :: proc "c" () -> cstring ---

Returns a string containing the user name associated by the login activity. Returns: nil (setting errno) on failure, the login name otherwise in a potentially static buffer overwritten by subsequent calls [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html ]]

getlogin_r #

Source
getlogin_r :: proc "c" (name: [^]u8, namelen: uint) -> Errno ---

Equivalent to getlogin but puts the name in the name buffer given. The name is limited to LOGIN_NAME_MAX bytes. Example: max := posix.sysconf(posix._SC_LOGIN_NAME_MAX)+1 buf := make([]byte, max) posix.getlogin_r(raw_data(buf), uint(len(max))) fmt.printfln("login: %v", cstring(buf)) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getlogin.html ]]

getnetbyaddr #

Source
getnetbyaddr :: proc "c" (net: u32, type: AF) -> ^netent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setnetent.html ]]

getnetbyname #

Source
getnetbyname :: proc "c" (name: cstring) -> ^netent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setnetent.html ]]

getnetent #

Source
getnetent :: proc "c" () -> ^netent ---

Reads the next entry of the database. Example: posix.setnetent(true) defer posix.endnetent() for ent := posix.getnetent(); ent != nil; ent = posix.getnetent() { fmt.println(ent) fmt.println(transmute([4]byte)ent.n_net) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setnetent.html ]]

getopt #

Source
getopt :: proc "c" (argc: i32, argv: [^]cstring, optstring: cstring) -> i32 ---

A command-line parser, see linked docs. Example: // The following code fragment shows how you might process the arguments for a utility that // can take the mutually-exclusive options a and b and the options f and o, both of which // require arguments. bflg, aflg, errflg: bool ifile: string ofile: string for { c := posix.getopt(i32(len(runtime.args__)), raw_data(runtime.args__), ":abf:o:") (c != -1) or_break switch c { case 'a': if bflg { errflg = true } else { aflg = true } case 'b': if aflg { errflg = true } else { bflg = true } case 'f': ifile = string(posix.optarg) case 'o': ofile = string(posix.optarg) case ':': /* -f or -o without operand */ fmt.eprintfln("Option -%c requires an operand", posix.optopt) errflg = true case '?': fmt.eprintfln("Unrecognized option: '-%c'", posix.optopt) errflg = true } } if errflg { fmt.eprintfln("usage: . . . ") posix.exit(2) } // Loop through remaining arguments: for ; posix.optind < i32(len(runtime.args__)); posix.optind += 1 { fmt.println(runtime.args__[posix.optind]) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getopt.html ]]

getpeername #

Source
getpeername :: proc "c" (socket: FD, address: ^sockaddr, address_len: ^socklen_t) -> result ---

Get the peer address of the specified socket. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpeername.html ]]

getpgid #

Source
getpgid :: proc "c" (pid: pid_t) -> pid_t ---

Returns the process group ID of the process whose process ID is equal to pid. If pid is 0, it returns the process group ID of the calling process. Returns: -1 on failure, the ID otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpgid.html ]]

getpgrp #

Source
getpgrp :: proc "c" () -> pid_t ---

Returns the process group ID of the calling process. Returns: no failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpgrp.html ]]

getpid #

Source
getpid :: proc "c" () -> pid_t ---

Returns the ID of the calling process. Returns: no failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html ]]

getppid #

Source
getppid :: proc "c" () -> pid_t ---

Returns the parent process ID. Returns: no failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getppid.html ]]

getpriority #

Source
getpriority :: proc "c" (which: Which_Prio, who: id_t) -> i32 ---

Gets the nice value of the process, process group or user given. Note that a nice value can be -1, so checking for an error would mean clearing errno, doing the call and then checking that this returns -1 and it has an errno. Returns: -1 (setting errno) on failure, the value otherwise Example: pid := posix.getpid() posix.set_errno(.NONE) prio := posix.getpriority(.PROCESS, pid) if err := posix.errno(); prio == -1 && err != .NONE { // Handle error... } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html ]]

getprotobyname #

Source
getprotobyname :: proc "c" (name: cstring) -> ^protoent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setprotoent.html ]]

getprotobynumber #

Source
getprotobynumber :: proc "c" (proto: i32) -> ^protoent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setprotoent.html ]]

getprotoent #

Source
getprotoent :: proc "c" () -> ^protoent ---

Reads the next entry of the database. Example: posix.setprotoent(true) defer posix.endprotoent() for ent := posix.getprotoent(); ent != nil; ent = posix.getprotoent() { fmt.println(ent) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setprotoent.html ]]

getpwent #

Source
@(link_name=LGETPWENT)
getpwent :: proc "c" () -> ^passwd ---

Returns the current entry in the user database. Returns: nil (setting errno) on error, nil (not setting errno) on success. Example: posix.setpwent() defer posix.endpwent() for e := posix.getpwent(); e != nil; e = posix.getpwent() { fmt.println(e) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpwent.html ]]

getpwnam #

Source
@(link_name=LGETPWNAM)
getpwnam :: proc "c" (name: cstring) -> ^passwd ---

Searches the database for an entry with a matching name. Returns: nil (setting errno) on error, nil (not setting errno) on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam.html ]]

getpwnam_r #

Source
@(link_name=LGETPWNAMR)
getpwnam_r :: proc "c" (name: cstring, pwd: ^passwd, buffer: [^]u8, bufsize: uint, result: ^^passwd) -> Errno ---

Searches the database for an entry with a matching name. Populating the pwd fields and using the buffer to allocate strings into. Setting result to nil on failure and to the address of pwd otherwise. ERANGE will be returned if there is not enough space in buffer. sysconf(_SC_GETPW_R_SIZE_MAX) can be called for the suggested size of this buffer, note that it could return -1. Example: length := posix.sysconf(._GETPW_R_SIZE_MAX) length = length == -1 ? 1024 : length buffer: [dynamic]byte defer delete(buffer) result: posix.passwd resultp: ^posix.passwd errno: posix.Errno for { if err := resize(&buffer, length); err != nil { fmt.panicf("allocation failure: %v", err) } errno = posix.getpwnam_r("root", &result, raw_data(buffer), len(buffer), &resultp) if errno != .ERANGE { break } } if errno != .NONE { panic(string(posix.strerror(errno))) } fmt.println(result) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwnam.html ]]

getpwuid #

Source
@(link_name=LGETPWUID)
getpwuid :: proc "c" (uid: uid_t) -> ^passwd ---

Searches the database for an entry with a matching uid. Returns: nil (setting errno) on error, nil (not setting errno) on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwuid.html ]]

getpwuid_r #

Source
@(link_name=LGETPWUIDR)
getpwuid_r :: proc "c" (uid: uid_t, pwd: ^passwd, buffer: [^]u8, bufsize: uint, result: ^^passwd) -> Errno ---

Searches the database for an entry with a matching uid. Populating the pwd fields and using the buffer to allocate strings into. Setting result to nil on failure and to the address of pwd otherwise. ERANGE will be returned if there is not enough space in buffer. sysconf(_SC_GETPW_R_SIZE_MAX) can be called for the suggested size of this buffer, note that it could return -1. See the example for getpwnam_r. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwuid_r.html ]]

getrlimit #

Source
getrlimit :: proc "c" (resource: Resource, rlp: ^rlimit) -> result ---

Get a resource limit. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html ]]

getrusage #

Source
@(link_name=LGETRUSAGE)
getrusage :: proc "c" (who: Which_Usage, rusage: ^rusage) -> result ---

Get resource usage. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getrusage.html ]]

gets #

Source
gets :: proc "c" (s: [^]u8) -> cstring ---

Get a string from the stdin stream. It is up to the user to make sure s is big enough. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gets.html ]]

getservbyname #

Source
getservbyname :: proc "c" (name: cstring, proto: cstring) -> ^servent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setservent.html ]]

getservbyport #

Source
getservbyport :: proc "c" (port: i32, proto: cstring) -> ^servent ---

Search the database from the beginning, and find the first entry that matches. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setservent.html ]]

getservent #

Source
getservent :: proc "c" () -> ^servent ---

Reads the next entry of the database. Example: posix.setservent(true) defer posix.endservent() for ent := posix.getservent(); ent != nil; ent = posix.getservent() { fmt.println(ent) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setservent.html ]]

getsid #

Source
getsid :: proc "c" (pid: pid_t) -> pid_t ---

Get the process group ID of the session leader. If pid is 0, it is the current process. Returns: -1 (setting errno) on failure, the pid otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsid.html ]]

getsockname #

Source
getsockname :: proc "c" (socket: FD, address: ^sockaddr, address_len: ^socklen_t) -> result ---

Get the socket name. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockname.html ]]

getsockopt #

Source
getsockopt :: proc "c" (socket: FD, level: i32, option_name: Sock_Option, option_value: rawptr, option_len: ^socklen_t) -> result ---

Retrieves the value for the option specified by option_name. level: either `c.int(posix.Protocol(...))` to specify a protocol level or `posix.SOL_SOCKET` to specify the socket local level. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsockopt.html ]]

getsubopt #

Source
getsubopt :: proc "c" (optionp: ^cstring, keylistp: [^]cstring, valuep: ^cstring) -> i32 ---

Parses suboption arguments in a flag argument. Returns: the index of the matched token string, or -1 if no token strings were matched Example: args := runtime.args__ Opt :: enum { RO, RW, NAME, NIL, } token := [Opt]cstring{ .RO = "ro", .RW = "rw", .NAME = "name", .NIL = nil, } Options :: struct { readonly, readwrite: bool, name: cstring, } opts: Options errfnd: bool for { opt := posix.getopt(i32(len(args)), raw_data(args), "o:") if opt == -1 { break } switch opt { case 'o': subopt := posix.optarg value: cstring for subopt != "" && !errfnd { o := posix.getsubopt(&subopt, &token[.RO], &value) switch Opt(o) { case .RO: opts.readonly = true case .RW: opts.readwrite = true case .NAME: if value == nil { fmt.eprintfln("missing value for suboption %s", token[.NAME]) errfnd = true continue } opts.name = value case .NIL: fallthrough case: fmt.eprintfln("no match found for token: %s", value) errfnd = true } } if opts.readwrite && opts.readonly { fmt.eprintfln("Only one of %s and %s can be specified", token[.RO], token[.RW]) errfnd = true } case: errfnd = true } } if errfnd || len(args) == 1 { fmt.eprintfln("\nUsage: %s -o <suboptstring>", args[0]) fmt.eprintfln("suboptions are 'ro', 'rw', and 'name=<value>'") posix.exit(1) } fmt.println(opts) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getsubopt.html ]]

gettimeofday #

Source
@(link_name=LGETTIMEOFDAY)
gettimeofday :: proc "c" (tp: ^timeval, tzp: rawptr = nil) -> result ---

Obtains the current time. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gettimeofday.html ]]

getuid #

Source
getuid :: proc "c" () -> uid_t ---

Returns the real user ID of the calling process. Returns: no failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getuid.html ]]

glob #

Source
@(link_name=LGLOB)
glob :: proc "c" (pattern: cstring, flags: bit_set[Glob_Flag_Bits], errfunc: proc "c" (epath: cstring, eerrno: Errno) -> b32 = nil, pglob: ^glob_t) -> Glob_Result ---

The glob() function is a pathname generator that shall implement the rules defined in [[ XCU Pattern Matching Notation; https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13 ]], with optional support for rule 3 in XCU [[ Patterns Used for Filename Expansion; https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13_03 ]]. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html ]]

globfree #

Source
@(link_name=LGLOBFREE)
globfree :: proc "c" (^glob_t) ---

Free the glob results. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/glob.html ]]

gmtime_r #

Source
@(link_name=LGMTIMER)
gmtime_r :: proc "c" (timer: ^time_t, result: ^tm) -> ^tm ---

Converts the time in seconds since epoch to a broken-down tm struct. Returns: nil (setting errno) on failure, the result pointer on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/gmtime_r.html ]]

grantpt #

Source
grantpt :: proc "c" (fildes: FD) -> result ---

Changes the mode and ownership of the slave pseudo-terminal device associated with its master pseudo-terminal counterpart. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/grantpt.html ]]

iconv #

Source
iconv :: proc "c" (cd: iconv_t, inbuf: ^[^]u8, inbytesleft: ^uint, outbuf: ^[^]u8, outbyteslen: ^uint) -> uint ---

Convert the sequence of characters from one codeset, in the array specified by inbuf, into a sequence of corresponding characters in another codeset, in the array specified by outbuf. Returns: -1 (setting errno) on failure, the number of non-identical conversions performed on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv.html ]]

iconv_close #

Source
iconv_close :: proc "c" (cd: iconv_t) -> result ---

Deallocates the conversion descriptor cd and all other associated resources allocated by iconv_open(). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv_close.html ]]

iconv_open #

Source
iconv_open :: proc "c" (tocode: cstring, fromcode: cstring) -> iconv_t ---

Returns a conversion descriptor that describes a conversion from the codeset specified by the string pointed to by the fromcode argument to the codeset specified by the string pointed to by the tocode argument. Returns: -1 (setting errno) on failure, a conversion descriptor on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/iconv_open.html ]]

if_freenameindex #

Source
if_freenameindex :: proc "c" (ptr: ^if_nameindex_t) ---

Frees memory allocated by if_nameindex. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/if_freenameindex.html ]]

if_indextoname #

Source
if_indextoname :: proc "c" (ifindex: u32, ifname: [^]u8) -> cstring ---

Returns the name corresponding to the index. ifname should be at least IF_NAMESIZE bytes in size. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/if_indextoname.html ]]

if_nameindex #

Source
if_nameindex :: proc "c" () -> [^]if_nameindex_t ---

Retrieve an array of name indexes. Where the last one has an index of 0 and name of nil. Returns: nil (setting errno) on failure, an array that should be freed with if_freenameindex otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nameindex.html ]]

if_nametoindex #

Source
if_nametoindex :: proc "c" (name: cstring) -> u32 ---

Returns the interface index matching the name or zero. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/if_nametoindex.html ]]

inet_ntoa #

Source
inet_ntoa :: proc "c" (in_addr) -> cstring ---

Convert the Internet host address specified by in to a string in the Internet standard dot notation. NOTE: returns a static string overwritten by further calls. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntoa.html ]]

inet_ntop #

Source
inet_ntop :: proc "c" (af: AF, src: rawptr, dst: [^]u8, size: socklen_t) -> cstring ---

Convert a numeric address into a text string suitable for presentation. Returns `nil` and sets `errno` on failure. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html ]]

inet_pton #

Source
inet_pton :: proc "c" (af: AF, src: cstring, dst: rawptr) -> pton_result ---

Convert an address in its standard text presentation form into its numeric binary form. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/inet_ntop.html ]]

initstate #

Source
@(link_name=LINITSTATE)
initstate :: proc "c" (seed: u32, state: [^]u8, size: uint) -> [^]u8 ---

Allows a state array, pointed to by the state argument, to be initialized for future use. Returns: the previous state array or nil on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/initstate.html ]]

isatty #

Source
isatty :: proc "c" (fildes: FD) -> b32 ---

Tests whether fildes is associated with a terminal device. Returns: false (setting errno) if fildes is invalid or not a terminal, true otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/isatty.html ]]

jrand48 #

Source
jrand48 :: proc "c" (xsubi: ^[3]u16) -> i64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: return signed long integers uniformly distributed over the interval [-231,231) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

kill #

Source
kill :: proc "c" (pid: pid_t, sig: Signal) -> result ---

Raise a signal to the process/group specified by pid. If sig is 0, this function can be used to check if the pid is just checked for validity. If pid is -1, the signal is sent to all processes that the current process has permission to send. If pid is negative (not -1), the signal is sent to all processes in the group identifier by the absolute value. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/kill.html ]]

killpg #

Source
killpg :: proc "c" (pgrp: pid_t, sig: Signal) -> result ---

Shorthand for `kill(-pgrp, sig)` which will kill all processes in the given process group. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/killpg.html ]]

l64a #

Source
l64a :: proc "c" (value: i64) -> cstring ---

The l64a() function shall take a long argument and return a pointer to the corresponding radix-64 representation. Returns: a string that may be invalidated by subsequent calls [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/a64l.html ]]

lchown #

Source
@(link_name=LLCHOWN)
lchown :: proc "c" (path: cstring, owner: uid_t, group: gid_t) -> result ---

If path points to a symbolic link, the owner and group of the link itself is changed. Equivalent to chown on normal files. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/lchown.html ]]

lcong48 #

Source
lcong48 :: proc "c" (param: ^[7]u16) ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. The srand48(), seed48(), and lcong48() functions are initialization entry points, one of which should be invoked before either drand48(), lrand48(), or mrand48() is called. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

link #

Source
link :: proc "c" (path1: cstring, path2: cstring) -> result ---

Creates a new link for the existing file path1 to path2. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html ]]

linkat #

Source
linkat :: proc "c" (fd1: FD, path1: cstring, fd2: FD, path2: cstring, flag: bit_set[AT_Flag_Bits]) -> result ---

If path1 is relative it is relative to directory fd1. If path2 is relative it is relative to directory fd2. If flag is { .SYMLINK_FOLLOW } path1 is resolved to its link if it is a link. Equivalent to link otherwise. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/link.html ]]

listen #

Source
listen :: proc "c" (socket: FD, backlog: i32) -> result ---

Mark the socket as a socket accepting connections. backlog provides a hint to limit the number of connections on the listen queue. Implementation may silently reduce the backlog, additionally `SOMAXCONN` specifies the maximum an implementation has to support. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/listen.html ]]

localtime_r #

Source
@(link_name=LLOCALTIMER)
localtime_r :: proc "c" (timer: ^time_t, result: ^tm) -> ^tm ---

Convert the time in seconds since epoch to a broken-down tm struct in local time. Returns: nil (setting errno) on failure, the result pointer on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/localtime_r.html ]]

lockf #

Source
lockf :: proc "c" (fildes: FD, function: Lock_Function, size: off_t) -> result ---

Locks sections of a file with advisory-mode locks. Example: fildes := posix.open("/home/cnd/mod1", { .RDWR }) if posix.lockf(fildes, .TLOCK, 10000) != .OK { errno := posix.errno(); #partial switch errno { case .EACCES, .EAGAIN: // File is already locked. case: // Other error. fmt.panicf("lockf failure: %v", posix.strerror(errno)) } } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/lockf.html ]]

lrand48 #

Source
lrand48 :: proc "c" () -> i64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: non-negative, long integers, uniformly distributed over the interval [0,231) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

lseek #

Source
lseek :: proc "c" (fildes: FD, offset: off_t, whence: Whence) -> off_t ---

Sets the file offset of the given file descriptor. If whence is .SET, the offset is set If whence is .CUR, the offset is the current offset + given offset If whence is .END, the offset is set to the size of the file + given offset Returns: the resulting offset or -1 (setting errno) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/lseek.html ]]

lstat #

Source
@(link_name=LLSTAT)
lstat :: proc "c" (path: cstring, buf: ^stat_t) -> result ---

Obtain information about a "file" at the given path. Does not follow symlinks (will stat the symlink itself). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html ]]

mkdir #

Source
mkdir :: proc "c" (path: cstring, mode: bit_set[Mode_Bits]) -> result ---

Make a directory. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html ]]

mkdirat #

Source
mkdirat :: proc "c" (fd: FD, path: cstring, mode: bit_set[Mode_Bits]) -> result ---

Equivalent to mkdir but relative paths are relative to fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdir.html ]]

mkdtemp #

Source
mkdtemp :: proc "c" (template: [^]u8) -> cstring ---

Creates a directory with a unique name derived from template. The application shall ensure that the string provided in template is a pathname ending with at least six trailing 'X' characters. Returns: nil (setting errno) on failure, template on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdtemp.html ]]

mkfifo #

Source
mkfifo :: proc "c" (path: cstring, mode: bit_set[Mode_Bits]) -> result ---

Make a FIFO special file. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifo.html ]]

mkfifoat #

Source
mkfifoat :: proc "c" (fd: FD, path: cstring, mode: bit_set[Mode_Bits]) -> result ---

Equivalent to mkfifo but relative paths are relative to fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkfifo.html ]]

mknod #

Source
@(link_name=LMKNOD)
mknod :: proc "c" (path: cstring, mode: bit_set[Mode_Bits], dev: dev_t) -> result ---

Make directory, special file, or regular file. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknodat.html ]]

mknodat #

Source
mknodat :: proc "c" (fd: FD, path: cstring, mode: bit_set[Mode_Bits], dev: dev_t) -> result ---

Equivalent to mknod but relative paths are relative to fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mknodat.html ]]

mkstemp #

Source
mkstemp :: proc "c" (template: cstring) -> FD ---

Creates a regular file with a unique name derived from template and return a file descriptor for the file open for reading and writing. The application shall ensure that the string provided in template is a pathname ending with at least six trailing 'X' characters. Returns: -1 (setting errno) on failure, an open file descriptor on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mkdtemp.html ]]

mlock #

Source
mlock :: proc "c" (addr: rawptr, len: uint) -> result ---

Locks a range of the process address space. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlock.html ]]

mlockall #

Source
mlockall :: proc "c" (flags: bit_set[Lock_Flag_Bits]) -> result ---

Locks all pages of the process address space. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlockall.html ]]

mmap #

Source
mmap :: proc "c" (
	addr:  rawptr, 
	len:   uint, 
	prot:  bit_set[Prot_Flag_Bits], 
	flags: bit_set[Map_Flag_Bits], 
	fd:    FD = -1, 
	off:   off_t = 0, 
) -> rawptr ---

Establish a mapping between an address space of a process and a memory object. Returns: MAP_FAILED (setting errno) on failure, the address in memory otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mmap.html ]]

mprotect #

Source
mprotect :: proc "c" (addr: rawptr, len: uint, prot: bit_set[Prot_Flag_Bits]) -> result ---

Set protection of a memory mapping. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mprotect.html ]]

mrand48 #

Source
mrand48 :: proc "c" () -> i64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: return signed long integers uniformly distributed over the interval [-231,231) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

msgctl #

Source
@(link_name=LMSGCTL)
msgctl :: proc "c" (msqid: FD, cmd: IPC_Cmd, buf: ^msqid_ds) -> result ---

Provides various operation as specified by the given cmd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/msgctl.html ]]

msgget #

Source
msgget :: proc "c" (key: key_t, msgflg: bit_set[IPC_Flag_Bits]) -> FD ---

Returns the message queue identifier associated with the argument key. Returns: -1 (setting errno) on failure, the identifier otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/msgget.html ]]

msgrcv #

Source
msgrcv :: proc "c" (msgid: FD, msgp: rawptr, msgsz: uint, msgtyp: i64, msgflg: bit_set[IPC_Flag_Bits]) -> int ---

Read a message from the queue. Returns: -1 (setting errno) on failure, the bytes received otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/msgrcv.html ]]

msgsnd #

Source
msgsnd :: proc "c" (msgid: FD, msgp: rawptr, msgsz: uint, msgflg: bit_set[IPC_Flag_Bits]) -> result ---

Send a message on the queue. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/msgsnd.html ]]

msync #

Source
@(link_name=LMSYNC)
msync :: proc "c" (addr: rawptr, len: uint, flags: bit_set[Sync_Flags_Bits]) -> result ---

Write all modified data to permanent storage locations. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html ]]

munlock #

Source
munlock :: proc "c" (addr: rawptr, len: uint) -> result ---

Unlocks a range of the process address space. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlock.html ]]

munlockall #

Source
munlockall :: proc "c" () -> result ---

Unlocks all pages of the process address space. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/mlockall.html ]]

munmap #

Source
munmap :: proc "c" (addr: rawptr, len: uint) -> result ---

Unmaps pages of memory. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/munmap.html ]]

nanosleep #

Source
@(link_name=LNANOSLEEP)
nanosleep :: proc "c" (rqtp: ^timespec, rmtp: ^timespec) -> result ---

Causes the current thread to be suspended from execution until either the time interval specified by rqtp has elapsed or a signal is delivered. Returns: -1 on failure (setting errno), if it was due to a signal, rmtp will be filled with the remaining time, 0 if all time has been slept [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html ]]

nice #

Source
nice :: proc "c" (incr: i32) -> i32 ---

Changes the nice value of a process. Higher values result in less favorable scheduling. Because -1 is a valid nice value, checking failure would be done by first setting errno to .NONE and then calling nice. Returns: the new nice value, or -1 (setting) errno on failure Example: posix.set_errno(.NONE) niceness := posix.nice(-20) if errno := posix.errno(); niceness == -1 && errno != .NONE { fmt.panicf("nice failure: %v", posix.strerror(errno)) } fmt.printfln("Niceness is now: %v", niceness) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/nice.html ]]

nl_langinfo #

Source
nl_langinfo :: proc "c" (nl_item) -> cstring ---

Return a pointer to a string containing information relevant to the particular language or cultural area defined in the current locale. Returns: a string that should not be freed or modified, and that can be invalidated at any time later Example: for item in posix.nl_item { fmt.printfln("%v: %q", item, posix.nl_langinfo(item)) } Possible Output: CODESET: "US-ASCII" D_T_FMT: "%a %b %e %H:%M:%S %Y" D_FMT: "%m/%d/%y" T_FMT: "%H:%M:%S" T_FMT_AMPM: "%I:%M:%S %p" AM_STR: "AM" PM_STR: "PM" DAY_1: "Sunday" DAY_2: "Monday" DAY_3: "Tuesday" DAY_4: "Wednesday" DAY_5: "Thursday" DAY_6: "Friday" DAY_7: "Saturday" ABDAY_1: "Sun" ABDAY_2: "Mon" ABDAY_3: "Tue" ABDAY_4: "Wed" ABDAY_5: "Thu" ABDAY_6: "Fri" ABDAY_7: "Sat" MON_1: "January" MON_2: "February" MON_3: "March" MON_4: "April" MON_5: "May" MON_6: "June" MON_7: "July" MON_8: "August" MON_9: "September" MON_10: "October" MON_11: "November" MON_12: "December" ABMON_1: "Jan" ABMON_2: "Feb" ABMON_3: "Mar" ABMON_4: "Apr" ABMON_5: "May" ABMON_6: "Jun" ABMON_7: "Jul" ABMON_8: "Aug" ABMON_9: "Sep" ABMON_10: "Oct" ABMON_11: "Nov" ABMON_12: "Dec" ERA: "" ERA_D_FMT: "" ERA_D_T_FMT: "" ERA_T_FMT: "" ALT_DIGITS: "" RADIXCHAR: "." THOUSEP: "" YESEXPR: "^[yY]" NOEXPR: "^[nN]" CRNCYSTR: "" [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/nl_langinfo.html ]]

nrand48 #

Source
nrand48 :: proc "c" (xsubi: ^[3]u16) -> i64 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. Returns: non-negative, long integers, uniformly distributed over the interval [0,231) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

open #

Source
open :: proc "c" (path: cstring, flags: bit_set[O_Flag_Bits], mode: ..bit_set[Mode_Bits]) -> FD ---

Establish the connection between a file and a file descriptor. It shall create an open file description that refers to a file and a file descriptor that refers to that open file description. The file descriptor is used by other I/O functions to refer to that file. The path argument points to a pathname naming the file Returns: -1 on failure (setting errno), a file descriptor on success. Example: // The following example opens the file /tmp/file, either by creating it (if it does not already exist), // or by truncating its length to 0 (if it does exist). In the former case, if the call creates a new file, // the access permission bits in the file mode of the file are set to permit reading and writing by the owner, // and to permit reading only by group members and others. fd := posix.open("/tmp/file", { .WRONLY, .CREAT, .TRUNC }, { .IRUSR, .IWUSR, .IRGRP, .IROTH }) // The following example uses the open() function to try to create the LOCKFILE file and open it for writing. // Since the open() function specifies the O_EXCL flag, the call fails if the file already exists. // In that case, the program assumes that someone else is updating the password file and exits. fd := posix.open("/etc/ptmp", { .WRONLY, .CREAT, .EXCL }, { .IRUSR, .IWUSR, .IRGRP, .IROTH }) if fd == -1 { fmt.println("cannot open /etc/ptmp") } // The following example opens a file for writing, creating the file if it does not already exist. // If the file does exist, the system truncates the file to zero bytes. fd := posix.open("/etc/ptmp", { .WRONLY, .CREAT, .TRUNC }, { .IRUSR, .IWUSR, .IRGRP, .IROTH }) if fd == -1 { fmt.println("cannot open output file") } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html ]]

open_memstream #

Source
open_memstream :: proc "c" (bufp: ^[^]u8, sizep: ^uint) -> ^FILE ---

Open a dynamic memory buffer stream. Returns: nil (setting errno) on failure, the stream on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open_memstream.html ]]

openat #

Source
openat :: proc "c" (fd: FD, path: cstring, flags: bit_set[O_Flag_Bits], mode: ..bit_set[Mode_Bits]) -> FD ---

Equivalent to the open() function except in the case where path specifies a relative path. In this case the file to be opened is determined relative to the directory associated with the file descriptor fd instead of the current working directory. Returns: -1 on failure (setting errno), a file descriptor on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html ]]

opendir #

Source
@(link_name=LOPENDIR)
opendir :: proc "c" (path: cstring) -> DIR ---

Open a directory stream corresponding to the directory named by the dirname argument. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdopendir.html ]]

pathconf #

Source
pathconf :: proc "c" (path: cstring, name: PC) -> i64 ---

Determines the current value of a configurable limit or option that is associated with a file or directory. Returns: value on success, -1 (setting errno) on failure, -1 (no errno) if the variable should be taken from limits [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fpathconf.html ]]

pause #

Source
pause :: proc "c" () -> i32 ---

Suspend the thread until a signal is received. Returns: -1 (setting errno to EINTR) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pause.html ]]

pclose #

Source
@(link_name=LPCLOSE)
pclose :: proc "c" (stream: ^FILE) -> i32 ---

Closes a pipe stream to or from a process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pclose.html ]]

pipe #

Source
pipe :: proc "c" (fildes: ^[2]FD) -> result ---

Create an interprocess channel. Example: fildes: [2]posix.FD if posix.pipe(&fildes) != .OK { // Handle error ... } switch posix.fork() { case -1: // Handle error ... case 0: /* Child - reads from pipe */ BSIZE :: 100 buf: [BSIZE]byte nbytes: int posix.close(fildes[1]) /* Write end is unused */ nbytes = posix.read(fildes[0], raw_data(buf[:]), BSIZE) /* Get data from pipe */ /* At this point, a further read would see end-of-file ... */ posix.close(fildes[0]) /* Finished with pipe */ fmt.println(string(buf[:nbytes])) posix.exit(0) case: /* Parent - write to pipe */ msg := raw_data(transmute([]byte)string("Hello world\n")) posix.close(fildes[0]) /* Read end is unused */ posix.write(fildes[1], msg, 12); /* Write data on pipe */ posix.close(fildes[1]) posix.exit(0) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pipe.html ]]

poll #

Source
poll :: proc "c" (fds: [^]pollfd, nfds: u32, timeout: i32) -> i32 ---

For each pointer in fds, poll() shall examine the given descriptor for the events. poll will identify on which descriptors writes or reads can be done. Returns: -1 (setting errno) on failure, 0 on timeout, the amount of fds that have been changed on success. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html ]]

popen #

Source
@(link_name=LPOPEN)
popen :: proc "c" (command: cstring, mode: cstring) -> ^FILE ---

Executes the command specified, creating a pipe and returning a pointer to a stream that can read or write from/to the pipe. Returns: nil (setting errno) on failure or a pointer to the stream Example: fp := posix.popen("ls *", "r") if fp == nil { /* Handle error */ } path: [1024]byte for posix.fgets(raw_data(path[:]), len(path), fp) != nil { posix.printf("%s", &path) } status := posix.pclose(fp) if status == -1 { /* Error reported by pclose() */ } else { /* Use functions described under wait() to inspect `status` in order to determine success/failure of the command executed by popen() */ } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/popen.html ]]

posix_madvise #

Source
posix_madvise :: proc "c" (addr: rawptr, len: uint, advice: MAdvice) -> Errno ---

Advise the implementation of expected behavior of the application. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_madvise.html ]]

posix_memalign #

Source
posix_memalign :: proc "c" (memptr: ^[^]u8, alignment: uint, size: uint) -> Errno ---

Allocates size bytes aligned on a boundary specified by alignment, and shall return a pointer to the allocated memory in memptr. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html ]]

posix_openpt #

Source
posix_openpt :: proc "c" (oflag: bit_set[O_Flag_Bits]) -> FD ---

Establishes a connection between a master device for a pseudo-terminal and a file descriptor. Returns: -1 (setting errno) on failure, an open file descriptor otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_openpt.html ]]

posix_spawn #

Source
posix_spawn :: proc "c" (
	pid:          ^pid_t, 
	path:         cstring, 
	file_actions: rawptr, 
	attrp:        rawptr, 
	argv:         [^]cstring, 
	envp:         [^]cstring, 
) -> Errno ---

Creates a child process from a provided filepath spawnp searches directories on the path for the file Returns: 0 on success, with the child pid returned in the pid argument, or error values on failure. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html ]]

pread #

Source
pread :: proc "c" (fd: FD, buf: [^]u8, nbyte: uint, offset: off_t) -> int ---

Equivalent to read on a specified offset instead of the internal offset. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html ]]

pselect #

Source
@(link_name=LPSELECT)
pselect :: proc "c" (
	nfds:     i32, 
	readfds:  ^fd_set, 
	writefds: ^fd_set, 
	errorfds: ^fd_set, 
	timeout:  ^timespec, 
	sigmask:  ^sigset_t, 
) -> i32 ---

Examines the file descriptor sets to see whether some of their descriptors are ready for writing, or have an exceptional condition pending, respectively. Returns: -1 (setting errno) on failure, total amount of bits set in the bit masks otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html ]]

psignal #

Source
psignal :: proc "c" (signum: Signal, message: cstring) ---

Writes a language-dependent message to stderror. Example: posix.psignal(.SIGSEGV, "that didn't go well") Possible Output: that didn't go well: Segmentation fault [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/psignal.html ]]

pthread_atfork #

Source
pthread_atfork :: proc "c" (prepare: proc "c" () -> !, parent: proc "c" () -> !, child: proc "c" () -> !) -> Errno ---

Register fork handlers to be called before and after fork(). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_atfork.html ]]

pthread_attr_destroy #

Source
pthread_attr_destroy :: proc "c" (attr: ^pthread_attr_t) -> Errno ---

Destroys a thread attributes object. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html ]]

pthread_attr_getdetachstate #

Source
pthread_attr_getdetachstate :: proc "c" (attr: ^pthread_attr_t, detachstate: ^Detach_State) -> Errno ---

The detachstate attribute controls whether the thread is created in a detached state. If the thread is created detached, then use of the ID of the newly created thread is an error. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getdetachstate.html ]]

pthread_attr_getguardsize #

Source
pthread_attr_getguardsize :: proc "c" (attr: ^pthread_attr_t, guardsize: ^uint) -> Errno ---

The guardsize attribute controls the size of the guard area for the created thread's stack. The guardsize attribute provides protection against overflow of the stack pointer. If a thread's stack is created with guard protection, the implementation allocates extra memory at the overflow end of the stack as a buffer against stack overflow of the stack pointer. If an application overflows into this buffer an error shall result (possibly in a SIGSEGV signal being delivered to the thread). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setguardsize.html ]]

pthread_attr_getinheritsched #

Source
pthread_attr_getinheritsched :: proc "c" (attr: ^pthread_attr_t, inheritsched: ^Inherit_Sched) -> Errno ---

When the attributes objects are used by pthread_create(), the inheritsched attribute determines how the other scheduling attributes of the created thread shall be set. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setinheritsched.html ]]

pthread_attr_getschedparam #

Source
pthread_attr_getschedparam :: proc "c" (attr: ^pthread_attr_t, param: ^sched_param) -> Errno ---

Gets the scheduling param. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedparam.html ]]

pthread_attr_getschedpolicy #

Source
pthread_attr_getschedpolicy :: proc "c" (attr: ^pthread_attr_t, policy: ^Sched_Policy) -> Errno ---

Gets the scheduling poicy. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedpolicy.html ]]

pthread_attr_getscope #

Source
pthread_attr_getscope :: proc "c" (attr: ^pthread_attr_t, contentionscope: ^Thread_Scope) -> Errno ---

Gets the contention scope. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getscope.html ]]

pthread_attr_getstack #

Source
pthread_attr_getstack :: proc "c" (attr: ^pthread_attr_t, stackaddr: ^[^]u8, stacksize: ^uint) -> Errno ---

Get the area of storage to be used for the created thread's stack. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html ]]

pthread_attr_getstacksize #

Source
pthread_attr_getstacksize :: proc "c" (attr: ^pthread_attr_t, stacksize: ^uint) -> Errno ---

Gets the stack size. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstacksize.html ]]

pthread_attr_init #

Source
pthread_attr_init :: proc "c" (attr: ^pthread_attr_t) -> Errno ---

Initializes a thread attributes object. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html ]]

pthread_attr_setdetachstate #

Source
pthread_attr_setdetachstate :: proc "c" (attr: ^pthread_attr_t, detachstate: Detach_State) -> Errno ---

The detachstate attribute controls whether the thread is created in a detached state. If the thread is created detached, then use of the ID of the newly created thread is an error. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getdetachstate.html ]]

pthread_attr_setguardsize #

Source
pthread_attr_setguardsize :: proc "c" (attr: ^pthread_attr_t, guardsize: uint) -> Errno ---

The guardsize attribute controls the size of the guard area for the created thread's stack. The guardsize attribute provides protection against overflow of the stack pointer. If a thread's stack is created with guard protection, the implementation allocates extra memory at the overflow end of the stack as a buffer against stack overflow of the stack pointer. If an application overflows into this buffer an error shall result (possibly in a SIGSEGV signal being delivered to the thread). [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setguardsize.html ]]

pthread_attr_setinheritsched #

Source
pthread_attr_setinheritsched :: proc "c" (attr: ^pthread_attr_t, inheritsched: Inherit_Sched) -> Errno ---

When the attributes objects are used by pthread_create(), the inheritsched attribute determines how the other scheduling attributes of the created thread shall be set. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setinheritsched.html ]]

pthread_attr_setschedparam #

Source
pthread_attr_setschedparam :: proc "c" (attr: ^pthread_attr_t, param: ^sched_param) -> Errno ---

Sets the scheduling param. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedparam.html ]]

pthread_attr_setschedpolicy #

Source
pthread_attr_setschedpolicy :: proc "c" (attr: ^pthread_attr_t, policy: Sched_Policy) -> Errno ---

Sets the scheduling poicy. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedpolicy.html ]]

pthread_attr_setscope #

Source
pthread_attr_setscope :: proc "c" (attr: ^pthread_attr_t, contentionscope: Thread_Scope) -> Errno ---

Sets the contention scope. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getscope.html ]]

pthread_attr_setstack #

Source
pthread_attr_setstack :: proc "c" (attr: ^pthread_attr_t, stackaddr: [^]u8, stacksize: uint) -> Errno ---

Specify the area of storage to be used for the created thread's stack. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstack.html ]]

pthread_attr_setstacksize #

Source
pthread_attr_setstacksize :: proc "c" (attr: ^pthread_attr_t, stacksize: uint) -> Errno ---

Sets the stack size. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstacksize.html ]]

pthread_cancel #

Source
pthread_cancel :: proc "c" (thread: pthread_t) -> Errno ---

Cancel the execution of a thread. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cancel.html ]]

pthread_create #

Source
pthread_create :: proc "c" (thread: ^pthread_t, attr: ^pthread_attr_t, start_routine: proc "c" (arg: rawptr) -> rawptr, arg: rawptr) -> Errno ---

Creates a new thread with the given attributes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html ]]

pthread_detach #

Source
pthread_detach :: proc "c" (thread: pthread_t) -> Errno ---

Indicate that storage for the thread can be reclaimed when the thread terminates. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_detach.html ]]

pthread_equal #

Source
pthread_equal :: proc "c" (t1: pthread_t, t2: pthread_t) -> b32 ---

Compare thread IDs. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_equal.html ]]

pthread_exit #

Source
pthread_exit :: proc "c" (value_ptr: rawptr) -> ! ---

Terminates the calling thread and make the given value available to any successfull join calls. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html ]]

pthread_getconcurrency #

Source
pthread_getconcurrency :: proc "c" () -> i32 ---

Gets the current concurrency hint. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getconcurrency.html ]]

pthread_getcpuclockid #

Source
pthread_getcpuclockid :: proc "c" (thread_id: pthread_t, clock_id: ^clockid_t) -> Errno ---

Access a thread CPU-time clock. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getcpuclockid.html ]]

pthread_getschedparam #

Source
pthread_getschedparam :: proc "c" (thread: pthread_t, policy: ^Sched_Policy, param: ^sched_param) -> Errno ---

Gets the scheduling policy and parameters. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html ]]

pthread_getspecific #

Source
pthread_getspecific :: proc "c" (key: pthread_key_t) -> rawptr ---

Returns the value currently bound to the specified key on behalf of the calling thread. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getspecific.html ]]

pthread_join #

Source
pthread_join :: proc "c" (thread: pthread_t, value_ptr: ^rawptr = nil) -> Errno ---

Suspends execution of the calling thread until the target thread terminates. Example: ar: [10_000]i32 sb1 := ar[:5_000] sb2 := ar[5_000:] th1, th2: posix.pthread_t posix.pthread_create(&th1, nil, incer, &sb1) posix.pthread_create(&th2, nil, incer, &sb2) posix.pthread_join(th1) posix.pthread_join(th2) incer :: proc "c" (arg: rawptr) -> rawptr { sb := (^[]i32)(arg) for &val in sb { val += 1 } return nil } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html ]]

pthread_key_create #

Source
pthread_key_create :: proc "c" (key: ^pthread_key_t, destructor: proc "c" (value: rawptr) = nil) -> Errno ---

Creates a thread-specific data key visible to all threads in the process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_key_create.html ]]

pthread_key_delete #

Source
pthread_key_delete :: proc "c" (key: pthread_key_t) -> Errno ---

Deletes a thread-specific data key visible to all threads in the process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_key_delete.html ]]

pthread_kill #

Source
pthread_kill :: proc "c" (thread: pthread_t, sig: Signal) -> Errno ---

Send a signal to a thread. As with kill, if sig is 0, only validation (of the pthread_t given) is done and no signal is sent. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_kill.html ]]

pthread_self #

Source
pthread_self :: proc "c" () -> pthread_t ---

Get the calling thread ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_self.html ]]

pthread_setcancelstate #

Source
pthread_setcancelstate :: proc "c" (state: Cancel_State, oldstate: ^Cancel_State) -> Errno ---

Atomically set the calling thread's cancelability and return the previous value. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setcancelstate.html ]]

pthread_setcanceltype #

Source
pthread_setcanceltype :: proc "c" (type: Cancel_Type, oldtype: ^Cancel_Type) -> Errno ---

Atomically set the calling thread's cancel type and return the previous value. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setcancelstate.html ]]

pthread_setconcurrency #

Source
pthread_setconcurrency :: proc "c" (new_level: i32) -> Errno ---

Sets the current desired concurrency hint. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getconcurrency.html ]]

pthread_setschedparam #

Source
pthread_setschedparam :: proc "c" (thread: pthread_t, policy: Sched_Policy, param: ^sched_param) -> Errno ---

Sets the scheduling policy and parameters. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html ]]

pthread_setschedprio #

Source
pthread_setschedprio :: proc "c" (thread: pthread_t, prio: i32) -> Errno ---

Sets the scheduling priority for the thread given. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setschedprio.html ]]

pthread_setspecific #

Source
pthread_setspecific :: proc "c" (key: pthread_key_t, value: rawptr) -> Errno ---

Sets the value currently bound to the specified key on behalf of the calling thread. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getspecific.html ]]

pthread_sigmask #

Source
pthread_sigmask :: proc "c" (how: Sig, set: ^sigset_t, oset: ^sigset_t) -> Errno ---

Examine and change blocked signals. Equivalent to sigprocmask(), without the restriction that the call be made in a single-threaded process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html ]]

pthread_testcancel #

Source
pthread_testcancel :: proc "c" () -> ! ---

Creates a cancellation point in the calling thread. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_testcancel.html ]]

ptsname #

Source
ptsname :: proc "c" (fildes: FD) -> cstring ---

Returns the name of the slave pseudo-terminal device associated with a master pseudo-terminal device. Returns: nil (setting errno) on failure, the name on success, which may be invalidated on subsequent calls [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ptsname.html ]]

putc_unlocked #

Source
@(link_name=LPUTC_UNLOCKED)
putc_unlocked :: proc "c" (ch: i32, stream: ^FILE) -> i32 ---

Equivalent to putc but unaffected by locks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getc_unlocked.html ]]

putchar_unlocked #

Source
@(link_name=LPUTCHAR_UNLOCKED)
putchar_unlocked :: proc "c" (ch: i32) -> i32 ---

Equivalent to putchar but unaffected by locks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getc_unlocked.html ]]

putenv #

Source
@(link_name=LPUTENV)
putenv :: proc "c" (string: cstring) -> i32 ---

Uses the string argument to set environment variable values. Returns: 0 on success, non-zero (setting errno) on failure Example: if posix.putenv("HOME=/usr/home") != 0 { fmt.panicf("putenv failure: %v", posix.strerror(posix.errno())) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/putenv.html ]]

pwrite #

Source
pwrite :: proc "c" (fd: FD, buf: [^]u8, buflen: uint, offset: off_t) -> int ---

Equivalent to write on a specified offset instead of the internal offset. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html ]]

raise #

Source
raise :: proc "c" (sig: Signal) -> result ---

Raises a signal, calling its handler and then returning. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/raise.html ]]

rand_r #

Source
rand_r :: proc "c" (seed: ^u32) -> i32 ---

Computes a sequence of pseudo-random integers in the range [0, {RAND_MAX}]. (The value of the {RAND_MAX} macro shall be at least 32767.) If rand_r() is called with the same initial value for the object pointed to by seed and that object is not modified between successive returns and calls to rand_r(), the same sequence shall be generated. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/rand_r.html ]]

random #

Source
random :: proc "c" () -> i64 ---

Use a non-linear additive feedback random-number generator employing a default state array size of 31 long integers to return successive pseudo-random numbers in the range from 0 to 231-1. The period of this random-number generator is approximately 16 x (231-1). The size of the state array determines the period of the random-number generator. Increasing the state array size shall increase the period. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/initstate.html ]]

read #

Source
read :: proc "c" (fd: FD, buf: [^]u8, nbyte: uint) -> int ---

Read from a file. Returns: the amount of bytes read or -1 (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pread.html ]]

readdir #

Source
@(link_name=LREADDIR)
readdir :: proc "c" (dirp: DIR) -> ^dirent ---

Returns a pointer to a structure representing the directory entry at the current position in the directory stream specified by the argument dirp, and position the directory stream at the next entry. Returns nil when the end is reached or an error occurred (which sets errno). Example: posix.set_errno(.NONE) entry := posix.readdir(dirp) if entry == nil { if errno := posix.errno(); errno != .NONE { panic(string(posix.strerror(errno))) } else { fmt.println("end of directory stream") } } else { fmt.println(entry) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html ]]

readlink #

Source
readlink :: proc "c" (path: cstring, buf: [^]u8, bufsize: uint) -> int ---

Read the contents of a symbolic link. Returns: the amount of bytes read or -1 (setting errno) on failure. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html ]]

readlinkat #

Source
readlinkat :: proc "c" (fd: FD, path: cstring, buf: [^]u8, bufsize: uint) -> int ---

Equivalent to readlink but relative paths are resolved based on the dir fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readlink.html ]]

readv #

Source
readv :: proc "c" (fildes: FD, iov: [^]iovec, iovcnt: i32) -> int ---

Equivalent to read() but takes a vector of inputs. iovcnt can be 0..=IOV_MAX in length. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readv.html ]]

realpath #

Source
realpath :: proc "c" (file_name: cstring, resolved_name: [^]u8 = nil) -> cstring ---

Derive, from the pathname file_name, an absolute pathname that resolves to the same directory entry, whose resolution does not involve '.', '..', or symbolic links. If resolved_name is not `nil` it should be larger than `PATH_MAX` and the result will use it as a backing buffer. If resolved_name is `nil` the returned string is allocated by `malloc`. Returns: `nil` (setting errno) on failure, the "real path" otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/realpath.html ]]

recv #

Source
recv :: proc "c" (socket: FD, buffer: rawptr, length: uint, flags: bit_set[Msg_Flag_Bits]) -> int ---

Receives a message from a socket. Blocks (besides with O_NONBLOCK) if there is nothing to receive. Returns: 0 when the peer shutdown with no more messages, -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/recv.html ]]

recvfrom #

Source
recvfrom :: proc "c" (
	socket:      FD, 
	buffer:      rawptr, 
	length:      uint, 
	flags:       bit_set[Msg_Flag_Bits], 
	address:     ^sockaddr, 
	address_len: ^socklen_t, 
) -> int ---

Receives a message from a socket. Equivalent to recv() but retrieves the source address too. Returns: 0 when the peer shutdown with no more messages, -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html ]]

recvmsg #

Source
recvmsg :: proc "c" (socket: FD, message: ^msghdr, flags: bit_set[Msg_Flag_Bits]) -> int ---

Receives a message from a socket. Returns: 0 when the peer shutdown with no more messages, -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html ]]

renameat #

Source
renameat :: proc "c" (oldfd: FD, old: cstring, newfd: FD, new: cstring) -> result ---

Equivalent to rename but relative directories are resolved from their respective fds. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/renameat.html ]]

rewinddir #

Source
@(link_name="rewinddir" + INODE_SUFFIX)
rewinddir :: proc "c" (dirp: DIR) ---

Reset the position of the directory stream to which dirp refers to the beginning of the directory. It shall also cause the directory stream to refer to the current state of the corresponding directory, as a call to opendir() would have done. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/rewinddir.html ]]

rmdir #

Source
@(link_name=LRMDIR)
rmdir :: proc "c" (path: cstring) -> result ---

Remove an (empty) directory. ]] More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/rmdir.html ]]

scandir #

Source
@(link_name=LSCANDIR)
scandir :: proc "c" (dir: cstring, sel: ^[^]^dirent, filter: proc "c" (^dirent) -> b32 = nil, compar: proc "c" ([^]^dirent, [^]^dirent) -> i32 = alphasort) -> i32 ---

Scan the directory dir, calling the function referenced by sel on each directory entry. Example: list: [^]^posix.dirent ret := posix.scandir(#directory, &list, nil, posix.alphasort) if ret < 0 { panic(string(posix.strerror(posix.errno()))) } defer posix.free(list) entries := list[:ret] for entry in entries { log.info(entry) posix.free(entry) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/scandir.html ]]

sched_get_priority_max #

Source
sched_get_priority_max :: proc "c" (policy: Sched_Policy) -> i32 ---

Returns the minimum for the given scheduling policy. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html ]]

sched_get_priority_min #

Source
sched_get_priority_min :: proc "c" (policy: Sched_Policy) -> i32 ---

Returns the maximum for the given scheduling policy. Returns: -1 (setting errno) on failure, the maximum on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html ]]

sched_yield #

Source
sched_yield :: proc "c" () -> result ---

Forces the running thread to relinquish the processor until it again becomes the head of its thread list.

seed48 #

Source
seed48 :: proc "c" (seed16v: ^[3]u16) -> ^[3]u16 ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. The srand48(), seed48(), and lcong48() functions are initialization entry points, one of which should be invoked before either drand48(), lrand48(), or mrand48() is called. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

seekdir #

Source
@(link_name="seekdir" + INODE_SUFFIX)
seekdir :: proc "c" (dirp: DIR, loc: i64) ---

The seekdir() function shall set the position of the next readdir() operation on the directory stream specified by dirp to the position specified by loc. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/seekdir.html ]]

select #

Source
@(link_name=LSELECT)
select :: proc "c" (nfds: i32, readfds: ^fd_set, writefds: ^fd_set, errorfds: ^fd_set, timeout: ^timeval) -> i32 ---

Equivalent to pselect() except a more specific timeout resolution (nanoseconds), does not have a signal mask, and may modify the timeout. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pselect.html ]]

semctl #

Source
@(link_name=LSEMCTL)
semctl :: proc "c" (semid: FD, semnum: i32, cmd: Sem_Cmd, args: ..semun) -> i32 ---

Provides various semaphore control operation as specified by cmd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/semctl.html ]]

semget #

Source
semget :: proc "c" (key: key_t, nsems: i32, semflg: bit_set[IPC_Flag_Bits]) -> FD ---

Returns the semaphore identifier associated with key. Returns: -1 (setting errno) on failure, a semaphore file descriptor otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/semget.html ]]

semop #

Source
semop :: proc "c" (semid: FD, sops: [^]sembuf, nsops: uint) -> result ---

Perform atomically a user-defined array of semaphore operations in array order on the set of semaphores associated with the semaphore identifier specified by the argument semid. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/semop.html ]]

send #

Source
send :: proc "c" (socket: FD, buffer: rawptr, length: uint, flags: bit_set[Msg_Flag_Bits]) -> int ---

Sends a message on a socket. Returns: -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/send.html ]]

sendmsg #

Source
sendmsg :: proc "c" (socket: FD, message: ^msghdr, flags: bit_set[Msg_Flag_Bits]) -> int ---

Sends a message on a socket. Returns: -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html ]]

sendto #

Source
sendto :: proc "c" (
	socket:    FD, 
	message:   rawptr, 
	length:    uint, 
	flags:     bit_set[Msg_Flag_Bits], 
	dest_addr: ^sockaddr, 
	dest_len:  socklen_t, 
) -> int ---

Sends a message on a socket. If the socket is connectionless, the dest_addr is used to send to. Returns: -1 (setting errno) on failure, the amount of bytes received on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sendto.html ]]

setegid #

Source
setegid :: proc "c" (gid: gid_t) -> result ---

Set the effective group ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setegid.html ]]

setenv #

Source
setenv :: proc "c" (envname: cstring, envval: cstring, overwrite: b32) -> result ---

Updates or add a variable in the environment of the calling process. Example: if posix.setenv("HOME", "/usr/home") != .OK { fmt.panicf("putenv failure: %v", posix.strerror(posix.errno())) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setenv.html ]]

seteuid #

Source
seteuid :: proc "c" (uid: uid_t) -> result ---

Sets the effective user ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/seteuid.html ]]

setgid #

Source
setgid :: proc "c" (gid: gid_t) -> result ---

Sets the group ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setgid.html ]]

setgrent #

Source
setgrent :: proc "c" () -> ! ---

Rewinds the group database so getgrent() returns the first entry again. Checking status would be done by setting errno to 0, calling this, and checking errno. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/endgrent.html ]]

sethostent #

Source
sethostent :: proc "c" (stayopen: b32) ---

Opens a connection to the database and set the next entry to the first entry in the database. This reads /etc/hosts on most systems. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sethostent.html ]]

setitimer #

Source
@(link_name=LSETITIMER)
setitimer :: proc "c" (which: ITimer, value: ^itimerval, ovalue: ^itimerval) -> result ---

Set the timer to the value given, and store the previous value in ovalue if it is not nil. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getitimer.html ]]

setkey #

Source
setkey :: proc "c" (key: [^]u8) ---

Provides access to an implementation-defined encoding algorithm. The argument of setkey() is an array of length 64 bytes containing only the bytes with numerical value of 0 and 1. If this string is divided into groups of 8, the low-order bit in each group is ignored; this gives a 56-bit key which is used by the algorithm. This is the key that shall be used with the algorithm to encode a string block passed to encrypt(). The setkey() function shall not change the setting of errno if successful. An application wishing to check for error situations should set errno to 0 before calling setkey(). If errno is non-zero on return, an error has occurred. Example: key: [64]byte // set key bytes... posix.set_errno(.NONE) posix.setkey(raw_data(key)) if errno := posix.errno(); errno != .NONE { fmt.panicf("setkey failure: %s", posix.strerror(errno)) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setkey.html ]]

setnetent #

Source
setnetent :: proc "c" (stayopen: b32) ---

Opens and rewinds the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setnetent.html ]]

setpgid #

Source
setpgid :: proc "c" (pid: pid_t, pgid: pid_t) -> result ---

Set process group ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpgid.html ]]

setpgrp #

Source
setpgrp :: proc "c" () -> pid_t ---

Set the process group ID to that of the process. Returns: the process group id, no failures are defined [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpgrp.html ]]

setpriority #

Source
setpriority :: proc "c" (which: Which_Prio, who: id_t, value: i32) -> result ---

Sets the nice value of the process, process group or user given. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html ]]

setprotoent #

Source
setprotoent :: proc "c" (stayopen: b32) ---

Opens and rewinds the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setprotoent.html ]]

setpwent #

Source
setpwent :: proc "c" () -> ! ---

Rewinds the user database so that the next getpwent() returns the first entry. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setpwent.html ]]

setregid #

Source
setregid :: proc "c" (rgid: gid_t, egid: gid_t) -> result ---

Set the real and effective group IDs. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setregid.html ]]

setreuid #

Source
setreuid :: proc "c" (ruid: uid_t, euid: uid_t) -> result ---

Set real and effective user IDs. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setreuid.html ]]

setrlimit #

Source
setrlimit :: proc "c" (resource: Resource, rlp: ^rlimit) -> result ---

Set a resource limit. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/getrlimit.html ]]

setservent #

Source
setservent :: proc "c" (stayopen: b32) ---

Opens and rewinds the database. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setservent.html ]]

setsid #

Source
setsid :: proc "c" () -> pid_t ---

Create session and set process group ID. Returns: the new process group ID or -1 (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsid.html ]]

setsockopt #

Source
setsockopt :: proc "c" (socket: FD, level: i32, option_name: Sock_Option, option_value: rawptr, option_len: socklen_t) -> result ---

Sets the specified option. level: either `c.int(posix.Protocol(...))` to specify a protocol level or `posix.SOL_SOCKET` to specify the socket local level. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setsockopt.html ]]

setstate #

Source
setstate :: proc "c" (state: [^]u8) -> [^]u8 ---

Sets the state array of the random number generator. Returns: the previous state array or nil on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/initstate.html ]]

setuid #

Source
setuid :: proc "c" (uid: uid_t) -> result ---

Set user ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/setuid.html ]]

shm_open #

Source
shm_open :: proc "c" (name: cstring, oflag: bit_set[O_Flag_Bits], args: ..any) -> FD ---

https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/shm_open.2.html

shm_unlink #

Source
shm_unlink :: proc "c" (name: cstring) -> result ---

Removes a shared memory object. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shm_unlink.html ]]

shmat #

Source
shmat :: proc "c" (shmid: FD, shmaddr: rawptr, shmflag: bit_set[SHM_Flag_Bits]) -> rawptr ---

Attaches the shared memory segment associated with the identifier into the address space of the calling process. Returns: nil (setting errno) on failure, the address otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shmat.html ]]

shmctl #

Source
@(link_name=LSHMCTL)
shmctl :: proc "c" (shmid: FD, cmd: IPC_Cmd, buf: ^shmid_ds) -> result ---

Provides various shared memory operation as specified by the given cmd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shmctl.html ]]

shmdt #

Source
shmdt :: proc "c" (shmaddr: rawptr) -> result ---

Detaches the shared memory segment located at the address specified. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shmdt.html ]]

shmget #

Source
shmget :: proc "c" (key: key_t, size: uint, shmflag: bit_set[SHM_Flag_Bits]) -> FD ---

Returns the shared memory identifier associated with key. Returns: -1 (setting errno) on failure, the shared memory ID otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shmget.html ]]

shutdown #

Source
shutdown :: proc "c" (socket: FD, how: Shut) -> result ---

Shuts down a socket end or both. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/shutdown.html ]]

sigaction #

Source
@(link_name=LSIGACTION)
sigaction :: proc "c" (sig: Signal, act: ^sigaction_t, oact: ^sigaction_t) -> result ---

Examine and change a signal action. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaction.html ]]

sigaltstack #

Source
@(link_name=LSIGALTSTACK)
sigaltstack :: proc "c" (ss: ^stack_t, oss: ^stack_t) -> result ---

Set and get the signal alternate stack context. Example: sigstk := posix.stack_t { ss_sp = make([^]byte, posix.SIGSTKSZ) or_else panic("allocation failure"), ss_size = posix.SIGSTKSZ, ss_flags = {}, } if posix.sigaltstack(&sigstk, nil) != .OK { fmt.panicf("sigaltstack failure: %v", posix.strerror(posix.errno())) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigaltstack.html ]]

sighold #

Source
sighold :: proc "c" (sig: Signal) -> result ---

Adds sig to the signal mask of the calling process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sighold.html ]]

sigignore #

Source
sigignore :: proc "c" (sig: Signal) -> result ---

Sets the disposition of sig to SIG_IGN. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sighold.html ]]

siginterrupt #

Source
siginterrupt :: proc "c" (sig: Signal, flag: b32) -> result ---

Changes the restart behavior when a function is interrupted by the specified signal. If flag is true, SA_RESTART is removed, added otherwise. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/siginterrupt.html ]]

sigismember #

Source
@(link_name=LSIGISMEMBER)
sigismember :: proc "c" (set: ^sigset_t, signo: Signal) -> i32 ---

Test for a signal in a signal set. Returns: 1 if it is a member, 0 if not, -1 (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigismember.html ]]

siglongjmp #

Source
@(link_name=LSIGLONGJMP)
siglongjmp :: proc "c" (env: ^sigjmp_buf, val: i32) -> ! ---

Equivalent to longjmp() but restores saved signal masks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/siglongjump.html ]]

signal #

Source
signal :: proc "c" (sig: Signal, func: proc "c" (Signal)) -> proc "c" (Signal) ---

Set a signal handler. func can either be: - `auto_cast posix.SIG_DFL` setting the default handler for that specific signal - `auto_cast posix.SIG_IGN` causing the specific signal to be ignored - a custom signal handler Returns: SIG_ERR (setting errno), the last value of func on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/signal.html ]]

sigpause #

Source
sigpause :: proc "c" (sig: Signal) -> result ---

Removes sig from the signal mask of the calling process and suspend the calling process until a signal is received. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sighold.html ]]

sigpending #

Source
@(link_name=LSIGPENDING)
sigpending :: proc "c" (set: ^sigset_t) -> result ---

Stores the set of signals that are blocked from delivery to the calling thread and that are pending on the process or the calling thread. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigpending.html ]]

sigprocmask #

Source
@(link_name=LSIGPROCMASK)
sigprocmask :: proc "c" (how: Sig, set: ^sigset_t, oldset: ^sigset_t) -> result ---

Examine and change blocked signals in a single-threaded process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_sigmask.html ]]

sigrelse #

Source
sigrelse :: proc "c" (sig: Signal) -> result ---

Removes sig from the signal mask of the calling process. Returns: always -1. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sighold.html ]]

sigsetjmp #

Source
@(link_name=LSIGSETJMP)
sigsetjmp :: proc "c" (env: ^sigjmp_buf, savemask: b32) -> i32 ---

Equivalent to setjmp() but restores saved signal masks. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/siglongjump.html ]]

sigsuspend #

Source
@(link_name=LSIGSUSPEND)
sigsuspend :: proc "c" (sigmask: ^sigset_t) -> result ---

Wait for one of the given signals. Returns: always -1 [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigsuspend.html ]]

sigwait #

Source
sigwait :: proc "c" (set: ^sigset_t, sig: ^Signal) -> Errno ---

Wait for queued signals. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sigwait.html ]]

sleep #

Source
sleep :: proc "c" (seconds: u32) -> u32 ---

Suspend execution for an interval of time. Returns: the time left to sleep (may be > 0 in case of signals) [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html ]]

sockatmark #

Source
sockatmark :: proc "c" (socket: FD) -> i32 ---

Determine wheter a socket is at the out-of-band mark. Returns: -1 (setting errno) on failure, 0 if not at the mark, 1 if it is [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sockatmark.html ]]

socket #

Source
@(link_name=LSOCKET)
socket :: proc "c" (domain: AF, type: Sock, protocol: Protocol = .IP) -> FD ---

Creates a socket. Returns: -1 (setting errno) on failure, file descriptor of socket otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html ]]

socketpair #

Source
socketpair :: proc "c" (domain: AF, type: Sock, protocol: Protocol, socket_vector: ^[2]FD) -> result ---

Create a pair of connected sockets. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/socketpair.html ]]

sprintf #

Source
sprintf :: proc "c" (s: [^]u8, format: cstring, args: ..any) -> i32 ---

Equivalent to fprintf but output is written to s, it is the user's responsibility to ensure there is enough space. Return: number of bytes written, negative (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/dprintf.html ]]

srand48 #

Source
srand48 :: proc "c" (seedval: i64) ---

This family of functions shall generate pseudo-random numbers using a linear congruential algorithm and 48-bit integer arithmetic. The srand48(), seed48(), and lcong48() functions are initialization entry points, one of which should be invoked before either drand48(), lrand48(), or mrand48() is called. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/drand48.html ]]

srandom #

Source
@(link_name=LSRANDOM)
srandom :: proc "c" (seed: u32) ---

Initializes the current state array using the value of seed. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/initstate.html ]]

stat #

Source
@(link_name=LSTAT)
stat :: proc "c" (path: cstring, buf: ^stat_t) -> result ---

Obtain information about a "file" at the given path. Follows symbolic links. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatat.html ]]

statvfs #

Source
@(link_name=LSTATVFS)
statvfs :: proc "c" (path: cstring, buf: ^statvfs_t) -> result ---

Obtains information about the file system containing the file named by path. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/statvfs.html ]]

strerror_r #

Source
strerror_r :: proc "c" (errnum: Errno, strerrbuf: [^]u8, buflen: uint) -> Errno ---

Map the error number to a locale-dependent error message string and put it in the buffer. Returns: ERANGE if the buffer is not big enough [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror_r.html ]]

strfmon #

Source
strfmon :: proc "c" (s: [^]u8, maxsize: uint, format: cstring, args: ..any) -> uint ---

Places characters into the array pointed to by s as controlled by the string format. No more than maxsize bytes are placed into the array. Returns: -1 (setting errno) on failure, the number of bytes added to s otherwise Example: posix.setlocale(.ALL, "en_US.UTF-8") value := 123456.789 buffer: [100]byte size := posix.strfmon(raw_data(buffer[:]), len(buffer), "%n", value) if int(size) == -1 { fmt.panicf("strfmon failure: %s", posix.strerror(posix.errno())) } fmt.println(string(buffer[:size])) Output: $123,456.79 [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strfmon.html ]]

strptime #

Source
strptime :: proc "c" (buf: [^]u8, format: cstring, tm: ^tm) -> cstring ---

Converts the character string to values which are stored in tm, using the specified format. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strptime.html ]]

strsignal #

Source
strsignal :: proc "c" (sig: Signal) -> cstring ---

Map the signal number to an implementation-defined string. Returns: a string that may be invalidated by subsequent calls [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/strsignal.html ]]

swab #

Source
@(link_name=LSWAB)
swab :: proc "c" (src: [^]u8, dest: [^]u8, nbytes: int) ---

Copy nbyte bytes, from src, to dest, exchanging adjecent bytes. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/swab.html ]]

symlink #

Source
symlink :: proc "c" (path1: cstring, path2: cstring) -> result ---

Creates a symbolic link called path2 that contains a link to path1. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html ]]

symlinkat #

Source
symlinkat :: proc "c" (path1: cstring, fd: FD, path2: cstring) -> result ---

Equivalent to symlink but relative paths are resolved to dir fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html ]]

sync #

Source
sync :: proc "c" () -> ! ---

Schedule file system updates. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sync.html ]]

sysconf #

Source
sysconf :: proc "c" (name: SC) -> i64 ---

Determines the current value of configurable system limit or options. Returns: value on success, -1 (setting errno) on failure, -1 (no errno) if the variable should be taken from limits [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html ]]

tcdrain #

Source
tcdrain :: proc "c" (fildes: FD) -> result ---

Wait for transmission of output. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcdrain.html ]]

tcflow #

Source
tcflow :: proc "c" (fildes: FD, action: TC_Action) -> result ---

Suspend or restart the transmission or reception of data. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflow.html ]]

tcflush #

Source
tcflush :: proc "c" (fildes: FD, queue_selector: TC_Queue) -> result ---

Flush non-transmitted output data, non-read input data, or both. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcflush.html ]]

tcgetattr #

Source
tcgetattr :: proc "c" (fildes: FD, termios_p: ^termios) -> result ---

Get the parameters associated with the terminal. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetattr.html ]]

tcgetpgrp #

Source
tcgetpgrp :: proc "c" (fildes: FD) -> pid_t ---

Get the foreground process group ID. Returns: -1 (setting errno) on failure, the id otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetpgrp.html ]]

tcgetsid #

Source
tcgetsid :: proc "c" (fildes: FD) -> pid_t ---

Get the process group ID for the session leader for the controlling terminal. Returns: -1 (setting errno) on failure, the pid otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcgetsid.html ]]

tcsendbreak #

Source
tcsendbreak :: proc "c" (fildes: FD, duration: i32) -> result ---

Send a break for a specific duration. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsendbreak.html ]]

tcsetattr #

Source
tcsetattr :: proc "c" (fildes: FD, optional_actions: TC_Optional_Action, termios_p: ^termios) -> result ---

Set the parameters associated with the terminal. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetattr.html ]]

tcsetpgrp #

Source
tcsetpgrp :: proc "c" (fildes: FD, pgid_id: pid_t) -> result ---

Set the foreground process group ID. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetpgrp.html ]]

telldir #

Source
@(link_name="telldir" + INODE_SUFFIX)
telldir :: proc "c" (dirp: DIR) -> i64 ---

The telldir() function shall obtain the current location associated with the directory stream specified by dirp. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/telldir.html ]]

tempnam #

Source
@(link_name=LTEMPNAM)
tempnam :: proc "c" (dir: cstring, pfx: cstring) -> cstring ---

Create a name for a temporary file. Returns: an allocated cstring that needs to be freed, nil on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tempnam.html ]]

times #

Source
@(link_name=LTIMES)
times :: proc "c" (buffer: ^tms) -> clock_t ---

Get time accounting information. Returns: -1 (setting errno) on failure, the elapsed real time, since an arbitrary point in the past

truncate #

Source
truncate :: proc "c" (path: cstring, length: off_t) -> result ---

Truncates a file to the specified length. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/truncate.html ]]

ttyname #

Source
ttyname :: proc "c" (fildes: FD) -> cstring ---

Find the path name of a terminal. Returns: nil (setting errno) on failure, the name, which may be invalidated by subsequent calls on success [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ttyname.html ]]

ttyname_r #

Source
ttyname_r :: proc "c" (fildes: FD, name: [^]u8, namesize: uint) -> Errno ---

Equivalent to ttyname but name is placed into the buf. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ttyname.html ]]

tzset #

Source
tzset :: proc "c" () -> ! ---

Uses the value of the environment variable TZ (or default) to set time conversion info. `daylight` is set to whether daylight saving time conversion should be done. `timezone` is set to the difference, in seconds, between UTC and local standard time. `tzname` is set by `tzname[0] = "std"` and `tzname[1] = "dst"` Example: posix.tzset() fmt.println(posix.tzname) fmt.println(posix.daylight) fmt.println(posix.timezone) Possible Output: ["CET", "CEST"] true -3600 [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/tzset.html ]]

ulimit #

Source
ulimit :: proc "c" (i: i32, arg: ..i64) -> i64 ---

Control process limits. Note that -1 is a valid return value, applications should clear errno, do this call and then check both -1 and the errno to determine status. Returns: -1 (setting errno) on failure. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/ulimit.html ]]

umask #

Source
umask :: proc "c" (cmask: bit_set[Mode_Bits]) -> bit_set[Mode_Bits] ---

Set and get the file mode creation flags. Makes the file mode permissions bits in cmask the new default for the process. Returns: the previous value [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/umask.html ]]

uname #

Source
uname :: proc "c" (uname: ^utsname) -> i32 ---

Stores information identifying the current system in the given structure. Returns: non-negative on success, -1 (setting errno) on failure NOTE: have a look at `core:sys/info` for similar/better system information. Example: uname: posix.utsname posix.uname(&uname) fmt.printfln("%#v", uname) Possible Output: utsname{ sysname = Darwin, nodename = Laytans-MacBook-Pro.local, release = 23.5.0, version = Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-11331.111.3~1/RELEASE_ARM64_T8103, machine = arm64, } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/uname.html ]]

unlink #

Source
@(link_name=LUNLINK)
unlink :: proc "c" (path: cstring) -> result ---

Remove a directory entry. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html ]]

unlinkat #

Source
unlinkat :: proc "c" (fd: FD, path: cstring, flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to unlink or rmdir (if flag is .REMOVEDIR) but relative paths are relative to the dir fd. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html ]]

unlockpt #

Source
unlockpt :: proc "c" (fildes: FD) -> result ---

Unlocks the slave pseudo-terminal device associated with the master to which fildes refers. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlockpt.html ]]

unsetenv #

Source
@(link_name=LUNSETENV)
unsetenv :: proc "c" (name: cstring) -> result ---

Removes an environment variable from the environment of the calling process. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/unsetenv.html ]]

utime #

Source
@(link_name=LUTIME)
utime :: proc "c" (path: cstring, times: ^utimbuf) -> result ---

Set file access and modification times. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/utime.html ]]

utimensat #

Source
utimensat :: proc "c" (fd: FD, path: cstring, times: ^[2]timespec, flag: bit_set[AT_Flag_Bits]) -> result ---

Equivalent to futimens. Relative directories are based on fd. Symlinks may or may not be followed based on the flags. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/futimens.html ]]

utimes #

Source
@(link_name=LUTIMES)
utimes :: proc "c" (path: cstring, times: ^[2]timeval) -> result ---

Sets the access and modification times of the file at the given path. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/utimes.html ]]

wait #

Source
wait :: proc "c" (stat_loc: ^i32) -> pid_t ---

Obtains status information pertaining to one of the caller's child processes. Returns: -1 (setting errno) on failure or signal on calling process, the pid of the process that caused the return otherwise [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html ]]

waitid #

Source
waitid :: proc "c" (idtype: idtype_t, id: id_t, infop: ^siginfo_t, options: bit_set[Wait_Flag_Bits]) -> i32 ---

Obtains status information pertaining to the given idtype_t and id specifier. Returns: 0 if WNOHANG and no status available, 0 if child changed state, -1 (setting errno) on failure [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitid.html ]]

waitpid #

Source
waitpid :: proc "c" (pid: pid_t, stat_loc: ^i32, options: bit_set[Wait_Flag_Bits]) -> pid_t ---

Obtains status information pertaining to the given pid specifier. If pid is -1, status is requested for any child process. If pid is greater than 0, it specifies the process ID of a single child process. If pid is 0, it specifies any child process whose process group ID is equal to that of the call. If pid is < -1, status is requested for any child whose process group ID is the absolute value of pid. Returns: -1 (setting errno) on failure or signal on calling process, 0 if NOHANG and status is not available, the pid of the process that caused the return otherwise Example: // The following example demonstrates the use of waitpid(), fork(), and the macros used to // interpret the status value returned by waitpid() (and wait()). The code segment creates a // child process which does some unspecified work. Meanwhile the parent loops performing calls // to waitpid() to monitor the status of the child. The loop terminates when child termination // is detected. child_pid := posix.fork(); switch child_pid { case -1: // `fork` failed. panic("fork failed") case 0: // This is the child. // Do some work... case: for { status: i32 wpid := posix.waitpid(child_pid, &status, { .UNTRACED, .CONTINUED }) if wpid == -1 { panic("waitpid failure") } switch { case posix.WIFEXITED(status): fmt.printfln("child exited, status=%v", posix.WEXITSTATUS(status)) case posix.WIFSIGNALED(status): fmt.printfln("child killed (signal %v)", posix.WTERMSIG(status)) case posix.WIFSTOPPED(status): fmt.printfln("child stopped (signal %v", posix.WSTOPSIG(status)) case posix.WIFCONTINUED(status): fmt.println("child continued") case: // Should never happen. fmt.println("unexpected status (%x)", status) } if posix.WIFEXITED(status) || posix.WIFSIGNALED(status) { break } } } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/wait.html ]]

WEXITSTATUS #

Source
WEXITSTATUS :: proc "contextless" (x: i32) -> i32 {…}

If WIFEXITED is true, returns the exit status.

WIFCONTINUED #

Source
WIFCONTINUED :: proc "contextless" (x: i32) -> bool {…}

If status was returned for a child process that has continued from a job control stop.

WIFSIGNALED #

Source
WIFSIGNALED :: proc "contextless" (x: i32) -> bool {…}

If terminated due to an uncaught signal.

WIFSTOPPED #

Source
WIFSTOPPED :: proc "contextless" (x: i32) -> bool {…}

If status was returned for a child process that is currently stopped.

wordfree #

Source
wordfree :: proc "c" (pwordexp: ^wordexp_t) ---

Free the space allocated during word expansion. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html ]]

write #

Source
write :: proc "c" (fd: FD, buf: [^]u8, buflen: uint) -> int ---

Write on a file. Returns: the amount of bytes written or -1 (setting errno) on failure. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/write.html ]]

writev #

Source
writev :: proc "c" (fildes: FD, iov: [^]iovec, iovcnt: i32) -> int ---

Equivalent to write() but takes a vector of inputs. iovcnt can be 0..=IOV_MAX in length. [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/readv.html ]]

WSTOPSIG #

Source
WSTOPSIG :: proc "contextless" (x: i32) -> Signal {…}

If WIFSTOPPED, the signal that caused the child process to stop.

WTERMSIG #

Source
WTERMSIG :: proc "contextless" (x: i32) -> Signal {…}

If WIFSIGNALED is true, returns the signal.

Procedure Groups

1

Variables

14

environ #

Source
environ: [^]cstring

Example: for i, entry := 0, posix.environ[0]; entry != nil; i, entry = i+1, posix.environ[i] { fmt.println(entry) } [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/execl.html ]]

timezone #

Source
@(link_name=LTIMEZONE)
timezone: i64

The time in seconds between UTC and local standard time.