Replace 'unreachable!' macro with custom implementation
Currently, the library uses the unreachable! macro to mark code paths that should never be reached. However, this macro generates additional panic-related code, which is unnecessary for our use case and increases the binary size.
Maybe we can replace it with a custom unreachable function.
pub fn unreachable() -> ! {
unsafe { asm!("", options(noreturn)) }
}
Rust compiler automatically generates instruction such as ud2, which is sufficient for marking unreachable code.
This function can be used after exit functions without causing undefined behavior.
This approach will ensure that the compiler treats the code path as unreachable without generating any extra panic-related code.
Maybe we shall just remove unreachable!() macro, as it is used only in exit()/exit_group()/thr_exit(). The return value of these syscalls is ! never type.