xref: /relibc/src/header/assert/mod.rs (revision ed19381547d66b76981ea1e4ff942c5a4da45ab7)
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!(
21         "{}: {}:{}: Assertion `{}` failed.",
22         func,
23         file,
24         line,
25         cond
26     );
27 
28     core::intrinsics::abort();
29 }
30