Fix stdlib div functions, add _Exit
This commit is contained in:
@@ -2,7 +2,7 @@ sys_includes = ["stddef.h", "alloca.h"]
|
||||
include_guard = "_STDLIB_H"
|
||||
trailer = "#include <bits/stdlib.h>"
|
||||
language = "C"
|
||||
style = "Tag"
|
||||
style = "Type"
|
||||
|
||||
[enum]
|
||||
prefix_with_name = true
|
||||
|
||||
@@ -33,6 +33,11 @@ pub const MB_LEN_MAX: c_int = 4;
|
||||
static mut ATEXIT_FUNCS: [Option<extern "C" fn()>; 32] = [None; 32];
|
||||
static mut RNG: Option<XorShiftRng> = None;
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn _Exit(status: c_int) {
|
||||
unistd::_exit(status);
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn a64l(s: *const c_char) -> c_long {
|
||||
if s.is_null() {
|
||||
@@ -144,6 +149,11 @@ pub extern "C" fn atol(s: *const c_char) -> c_long {
|
||||
dec_num_from_ascii!(s, c_long)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn atoll(s: *const c_char) -> c_longlong {
|
||||
dec_num_from_ascii!(s, c_longlong)
|
||||
}
|
||||
|
||||
unsafe extern "C" fn void_cmp(a: *const c_void, b: *const c_void) -> c_int {
|
||||
*(a as *const i32) - *(b as *const i32) as c_int
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ EXPECT_BINS=\
|
||||
stdlib/a64l \
|
||||
stdlib/atof \
|
||||
stdlib/atoi \
|
||||
stdlib/div \
|
||||
stdlib/env \
|
||||
stdlib/mkostemps \
|
||||
stdlib/rand \
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#include <stdlib.h>
|
||||
volatile float f;
|
||||
volatile long double ld;
|
||||
volatile unsigned long long ll;
|
||||
lldiv_t mydivt;
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char* tmp;
|
||||
f = strtof("gnu", &tmp);
|
||||
ld = strtold("gnu", &tmp);
|
||||
ll = strtoll("gnu", &tmp, 10);
|
||||
ll = strtoull("gnu", &tmp, 10);
|
||||
ll = llabs(10);
|
||||
mydivt = lldiv(10,1);
|
||||
ll = mydivt.quot;
|
||||
ll = mydivt.rem;
|
||||
ll = atoll("10");
|
||||
_Exit(0);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user