Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
redox-os
relibc
Commits
fba3bf51
Commit
fba3bf51
authored
Oct 07, 2018
by
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
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/assert.h
→
include/
bits/
assert.h
View file @
fba3bf51
#ifndef _ASSERT_H
#ifndef
_BITS
_ASSERT_H
#define _ASSERT_H
#define
_BITS
_ASSERT_H
#ifdef NDEBUG
#ifdef NDEBUG
# define assert(cond)
# define assert(cond)
#else
#else
# include <stdio.h>
# define assert(cond) if (!(cond)) { \
# define assert(cond) if (!(cond)) { \
fprintf(stderr, "%s: %s:%d: Assertion `%s` failed.\n", __func__, __FILE__, __LINE__, #cond); \
__assert(__func__, __FILE__, __LINE__, #cond); \
abort(); \
}
}
#endif
#endif
#endif
#endif
src/header/assert/cbindgen.toml
0 → 100644
View file @
fba3bf51
sys_includes
=
["bits/assert.h"]
include_guard
=
"_ASSERT_H"
language
=
"C"
style
=
"Tag"
[enum]
prefix_with_name
=
true
src/header/assert/mod.rs
0 → 100644
View file @
fba3bf51
//! 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
();
}
src/header/mod.rs
View file @
fba3bf51
pub
mod
aio
;
pub
mod
aio
;
pub
mod
arpa_inet
;
pub
mod
arpa_inet
;
pub
mod
assert
;
pub
mod
ctype
;
pub
mod
ctype
;
pub
mod
dirent
;
pub
mod
dirent
;
pub
mod
errno
;
pub
mod
errno
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment