std1.0.0-beta-7 SafeC docs

Module sys

#include <std/sys.h> source

System declarations (C11/C17/C23 stdlib coverage)

Functions

sys_exitTerminate the process with the given exit code.
sys_abortTerminate the process abnormally (raises SIGABRT / triggers abort handler).
sys_systemRun a shell command and return its exit status. NULL → check if shell available.
sys_atexitRegister a function to be called at normal process exit. Returns 0 on success, non-zero if the registration limit is exceeded.
sys_getenvReturn the value of the environment variable named name, or NULL if not set. The returned pointer is owned by the environment.
sys_randReturn a pseudo-random integer in [0, RAND_MAX].
sys_srandSeed the PRNG. Use sys_time_now_ns() for a time-based seed.
sys_absAbsolute value of a 32-bit signed integer.
sys_llabsAbsolute value of a 64-bit signed integer.
sys_atoiConvert a decimal string to int. Stops at the first non-digit.
sys_atollConvert a decimal string to long long.
sys_atofConvert a decimal/scientific string to double.
sys_strtollStrtoll with explicit base (0 = auto-detect 0x/0 prefix). If end is non-null it is set to the first character not consumed.
sys_strtoullConvert string to unsigned long long.
sys_strtodConvert string to double.
sys_strtofConvert string to float.
sys_qsortSorts items in place; cmp(a, b) returns <0 / 0 / >0.
sys_bsearchBinary search of sorted items; the index of an element equal to key, or null.
sys_cpu_time_nsReturn processor time consumed by the program in nanoseconds. Same clock as time_cpu_ns() (time.h). Returns -1 on error.
sys_time_now_nsReturn wall-clock time in nanoseconds since the Unix epoch. Same clock as time_wall_ns() (time.h). Returns -1 on error.
sys_monotonic_nsReturn a monotonic timestamp in nanoseconds (suitable for elapsed-time measurement; epoch is unspecified). Returns -1 on error.

Macros

EXIT_SUCCESS
EXIT_FAILURE
RAND_MAX