exit_no_std/
lib.rs

1#![deny(warnings)]
2
3#![no_std]
4
5/// Terminates the current process with the specified exit code.
6#[cfg(target_os="dos")]
7pub fn exit(code: u8) -> ! {
8    pc_ints::int_21h_ah_4Ch_exit(code);
9    #[allow(clippy::empty_loop)]
10    loop { }
11}
12
13/// Terminates the current process with the specified exit code.
14#[cfg(all(not(target_os="dos"), windows))]
15pub fn exit(code: u8) -> ! {
16    unsafe { winapi::um::processthreadsapi::ExitProcess(
17        code as winapi::shared::minwindef::UINT
18    ); }
19    #[allow(clippy::empty_loop)]
20    loop { }
21}
22
23/// Terminates the current process with the specified exit code.
24#[cfg(all(not(target_os="dos"), not(windows)))]
25pub fn exit(code: u8) -> ! {
26    unsafe { libc::exit(code as u16 as i16 as libc::c_int) }
27}