xref: /relibc/src/header/assert/mod.rs (revision fd22fbbabfdcb99dacbd9e8317399ad91050d6cd)
1 //! assert implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/assert.h.html
2 
3 use crate::{
4     c_str::CStr,
5     header::{stdio, stdlib},
6     platform::types::*,
7 };
8 
9 #[no_mangle]
10 pub unsafe extern "C" fn __assert_fail(
11     func: *const c_char,
12     file: *const c_char,
13     line: c_int,
14     cond: *const c_char,
15 ) -> ! {
16     let func = CStr::from_ptr(func).to_str().unwrap();
17     let file = CStr::from_ptr(file).to_str().unwrap();
18     let cond = CStr::from_ptr(cond).to_str().unwrap();
19 
20     eprintln!("{}: {}:{}: Assertion `{}` failed.", func, file, line, cond);
21 
22     core::intrinsics::abort();
23 }
24