plat/apple.rs (Apple)#
Source: lib/plat/apple.rs
apple -- macOS and iOS through libSystem (docs/APPLE.md)
Apple keeps only libSystem stable, not the system calls under it (decision 2), so everything here
is a libSystem call, as on Android through Bionic. This is the start of the port (AP2): process,
environment, time, files (apple_sys.rs), threads, semaphores, the wake-up, system information
(apple_thread.rs), crash reports (apple_crash.rs); windows answer as on a system without a display
(apple_disp.rs) until AP4.
main(): libSystem's start calls it (a program without std); it calls the app's jfgui_main and ends
the process with its result. std_start() (feature std) does the same from the program's own fn
main, whose main is std's. The arguments and the environment come from _NSGetArgv and
_NSGetEnviron, so a program with std reads the same.
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32the entry libSystem's start calls (a program without std; std brings its own main)fn std_start() -> !(feature std) the start of a program with std, from itsfn main(rt::main!, ui::main! or the program's own): what main does without std, with rt's panic hook first and the end through std::process::exit; with the feature unwind a panic that leaves the app ends it therefn win_test_usage() -> (u64, u64, u64)(test aid) the process's CPU time (us), resident memory and its own footprint (bytes), as on Windows and Linux (render3dtest and uigputest measure with it)fn time_us() -> u64monotonic time in microseconds (CLOCK_MONOTONIC)fn unix_time_ns() -> i64wall-clock time: nanoseconds since 1970-01-01 00:00 UTC (CLOCK_REALTIME)fn args() -> Vec<String>the command line, argument 0 (the program) firstfn env(name: &str) -> Option<String>the value of an environment variable [plat_env / plat_getenv]fn getenv(name: &str) -> Option<String>the same as env (ASMLIB's plat_getenv)fn setenv(name: &str, value: Option<&str>) -> boolset (Some) or remove (None) an environment variable of this process [plat_setenv]fn sleep_ms(ms: u32)sleep for ms milliseconds (EINTR: the rest is slept)fn current_exe() -> Option<String>the path of this program's file (_NSGetExecutablePath; modhost.rs has it on Windows and Linux), None when it cannot be read