Commit fba3bf51 authored by jD91mZM2's avatar jD91mZM2
Browse files

Merge branch 'assert' into 'master'

Make assert more hygienic

See merge request !166
parents 758f6815 614b2f51
Pipeline #1449 failed with stages
in 9 minutes and 16 seconds
#ifndef _ASSERT_H
#define _ASSERT_H
#ifndef _BITS_ASSERT_H
#define _BITS_ASSERT_H
#ifdef NDEBUG
# define assert(cond)
#else
# include <stdio.h>
# define assert(cond) if (!(cond)) { \
fprintf(stderr, "%s: %s:%d: Assertion `%s` failed.\n", __func__, __FILE__, __LINE__, #cond); \
abort(); \
}
__assert(__func__, __FILE__, __LINE__, #cond); \
}
#endif
#endif
sys_includes = ["bits/assert.h"]
include_guard = "_ASSERT_H"
language = "C"
style = "Tag"
[enum]
prefix_with_name = true
//! assert implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/assert.h.html
use c_str::CStr;
use core::fmt::Write;
use header::{stdio, stdlib};
use platform;
use platform::types::*;
#[no_mangle]
pub unsafe extern "C" fn __assert(func: *const c_char, file: *const c_char, line: c_int, cond: *const c_char) {
let func = CStr::from_ptr(func).to_str().unwrap();
let file = CStr::from_ptr(file).to_str().unwrap();
let cond = CStr::from_ptr(cond).to_str().unwrap();
write!(*stdio::stderr, "{}: {}:{}: Assertion `{}` failed.\n", func, file, line, cond).unwrap();
stdlib::abort();
}
pub mod aio;
pub mod arpa_inet;
pub mod assert;
pub mod ctype;
pub mod dirent;
pub mod errno;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment