-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
165 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
char **environ = 0; | ||
|
||
char *getenv(const char *name) | ||
{ | ||
size_t l = strchrnul(name, '=') - name; | ||
if (l && !name[l] && environ) | ||
for (char **e = environ; *e; e++) | ||
if (!strncmp(name, *e, l) && l[*e] == '=') | ||
return *e + l + 1; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,10 +94,4 @@ double floor(double x) | |
return x + y; | ||
} | ||
|
||
// TODO | ||
long double __extenddftf2(double a) | ||
{ | ||
return 0; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,6 @@ | |
#include <time.h> | ||
#include <unistd.h> | ||
|
||
char **__environ = 0; | ||
|
||
// TODO: | ||
uid_t geteuid(void) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 7 additions & 5 deletions
12
ulib/libax/src/cbindings/epoll.rs → ulib/libax/src/cbindings/io_mpx/epoll.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
use core::ffi::{c_char, c_double, c_float, c_int}; | ||
|
||
macro_rules! strto_float_impl { | ||
($type:ident, $s:expr, $endptr:expr) => {{ | ||
let mut s = $s; | ||
let endptr = $endptr; | ||
|
||
// TODO: Handle named floats: NaN, Inf... | ||
|
||
while isspace(*s as c_int) { | ||
s = s.offset(1); | ||
} | ||
|
||
let mut result: $type = 0.0; | ||
let mut radix = 10; | ||
|
||
let result_sign = match *s as u8 { | ||
b'-' => { | ||
s = s.offset(1); | ||
-1.0 | ||
} | ||
b'+' => { | ||
s = s.offset(1); | ||
1.0 | ||
} | ||
_ => 1.0, | ||
}; | ||
|
||
if *s as u8 == b'0' && *s.offset(1) as u8 == b'x' { | ||
s = s.offset(2); | ||
radix = 16; | ||
} | ||
|
||
while let Some(digit) = (*s as u8 as char).to_digit(radix) { | ||
result *= radix as $type; | ||
result += digit as $type; | ||
s = s.offset(1); | ||
} | ||
|
||
if *s as u8 == b'.' { | ||
s = s.offset(1); | ||
|
||
let mut i = 1.0; | ||
while let Some(digit) = (*s as u8 as char).to_digit(radix) { | ||
i *= radix as $type; | ||
result += digit as $type / i; | ||
s = s.offset(1); | ||
} | ||
} | ||
|
||
let s_before_exponent = s; | ||
|
||
let exponent = match (*s as u8, radix) { | ||
(b'e' | b'E', 10) | (b'p' | b'P', 16) => { | ||
s = s.offset(1); | ||
|
||
let is_exponent_positive = match *s as u8 { | ||
b'-' => { | ||
s = s.offset(1); | ||
false | ||
} | ||
b'+' => { | ||
s = s.offset(1); | ||
true | ||
} | ||
_ => true, | ||
}; | ||
|
||
// Exponent digits are always in base 10. | ||
if (*s as u8 as char).is_digit(10) { | ||
let mut exponent_value = 0; | ||
|
||
while let Some(digit) = (*s as u8 as char).to_digit(10) { | ||
exponent_value *= 10; | ||
exponent_value += digit; | ||
s = s.offset(1); | ||
} | ||
|
||
let exponent_base = match radix { | ||
10 => 10u128, | ||
16 => 2u128, | ||
_ => unreachable!(), | ||
}; | ||
|
||
if is_exponent_positive { | ||
Some(exponent_base.pow(exponent_value) as $type) | ||
} else { | ||
Some(1.0 / (exponent_base.pow(exponent_value) as $type)) | ||
} | ||
} else { | ||
// Exponent had no valid digits after 'e'/'p' and '+'/'-', rollback | ||
s = s_before_exponent; | ||
None | ||
} | ||
} | ||
_ => None, | ||
}; | ||
|
||
// Return pointer should be *mut | ||
if !endptr.is_null() { | ||
*endptr = s as *mut _; | ||
} | ||
|
||
if let Some(exponent) = exponent { | ||
result_sign * result * exponent | ||
} else { | ||
result_sign * result | ||
} | ||
}}; | ||
} | ||
|
||
fn isspace(c: c_int) -> bool { | ||
c == c_int::from(b' ') | ||
|| c == c_int::from(b'\t') | ||
|| c == c_int::from(b'\n') | ||
|| c == c_int::from(b'\r') | ||
|| c == 0x0b | ||
|| c == 0x0c | ||
} | ||
|
||
/// `strtod` implementation | ||
#[no_mangle] | ||
pub unsafe extern "C" fn ax_strtod(s: *const c_char, endptr: *mut *mut c_char) -> c_double { | ||
strto_float_impl!(c_double, s, endptr) | ||
} | ||
|
||
/// `strtof`implementation | ||
#[no_mangle] | ||
pub unsafe extern "C" fn ax_strtof(s: *const c_char, endptr: *mut *mut c_char) -> c_float { | ||
strto_float_impl!(c_float, s, endptr) | ||
} |
Oops, something went wrong.