aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / vendor / libc / src / new / qurt / stdlib.rs
| 1 | //! Header: `stdlib.h` |
| 2 | |
| 3 | use super::*; |
| 4 | use crate::prelude::*; |
| 5 | |
| 6 | // Exit status constants |
| 7 | pub const EXIT_SUCCESS: c_int = 0; |
| 8 | pub const EXIT_FAILURE: c_int = 1; |
| 9 | |
| 10 | // Maximum values |
| 11 | pub const RAND_MAX: c_int = 32767; |
| 12 | |
| 13 | extern "C" { |
| 14 | // Memory management |
| 15 | pub fn malloc(size: size_t) -> *mut c_void; |
| 16 | pub fn calloc(nmemb: size_t, size: size_t) -> *mut c_void; |
| 17 | pub fn realloc(ptr: *mut c_void, size: size_t) -> *mut c_void; |
| 18 | pub fn free(ptr: *mut c_void); |
| 19 | |
| 20 | // Process control |
| 21 | pub fn abort() -> !; |
| 22 | pub fn exit(status: c_int) -> !; |
| 23 | pub fn atexit(function: extern "C" fn()) -> c_int; |
| 24 | |
| 25 | // Environment |
| 26 | pub fn getenv(name: *const c_char) -> *mut c_char; |
| 27 | pub fn setenv(name: *const c_char, value: *const c_char, overwrite: c_int) -> c_int; |
| 28 | pub fn unsetenv(name: *const c_char) -> c_int; |
| 29 | |
| 30 | // String/number conversion |
| 31 | pub fn atoi(nptr: *const c_char) -> c_int; |
| 32 | pub fn atol(nptr: *const c_char) -> c_long; |
| 33 | pub fn atoll(nptr: *const c_char) -> c_longlong; |
| 34 | pub fn strtol(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_long; |
| 35 | pub fn strtoul(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_ulong; |
| 36 | pub fn strtoll(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_longlong; |
| 37 | pub fn strtoull(nptr: *const c_char, endptr: *mut *mut c_char, base: c_int) -> c_ulonglong; |
| 38 | pub fn strtod(nptr: *const c_char, endptr: *mut *mut c_char) -> c_double; |
| 39 | pub fn strtof(nptr: *const c_char, endptr: *mut *mut c_char) -> c_float; |
| 40 | |
| 41 | // Random numbers |
| 42 | pub fn rand() -> c_int; |
| 43 | pub fn srand(seed: c_uint); |
| 44 | |
| 45 | // Searching and sorting |
| 46 | pub fn qsort( |
| 47 | base: *mut c_void, |
| 48 | nmemb: size_t, |
| 49 | size: size_t, |
| 50 | compar: extern "C" fn(*const c_void, *const c_void) -> c_int, |
| 51 | ); |
| 52 | pub fn bsearch( |
| 53 | key: *const c_void, |
| 54 | base: *const c_void, |
| 55 | nmemb: size_t, |
| 56 | size: size_t, |
| 57 | compar: extern "C" fn(*const c_void, *const c_void) -> c_int, |
| 58 | ) -> *mut c_void; |
| 59 | |
| 60 | // Integer arithmetic |
| 61 | pub fn abs(j: c_int) -> c_int; |
| 62 | pub fn labs(j: c_long) -> c_long; |
| 63 | pub fn llabs(j: c_longlong) -> c_longlong; |
| 64 | pub fn div(numer: c_int, denom: c_int) -> div_t; |
| 65 | pub fn ldiv(numer: c_long, denom: c_long) -> ldiv_t; |
| 66 | pub fn lldiv(numer: c_longlong, denom: c_longlong) -> lldiv_t; |
| 67 | } |