Skip to content

Commit

Permalink
Auto merge of #2358 - hcsch:add-strtof, r=JohnTitor
Browse files Browse the repository at this point in the history
Add `strtof` for all platforms that have `strtod`

All platforms that have `strtod` very likely also have `strtof`. Having `strtof` allows for fuzzing of [`hexf-parse::parse_hexf32`](https://github.com/lifthrasiir/hexf) comparing against `strtof`, which can't (easily) be done with `strtod`, due to float rounding and over-/underflow behavior.

I'm unsure of whether the `strtof` declaration in `src/unix/mod.rs` also needs a link name adjustment for x86 macos. I haven't been able to find anything about this after a rough search in this repo and on Google. I haven't added it for now since only `strtod` (edit: out of the `strtoX` functions) seems to have the changed link name (and I don't have a mac handy to test the available symbols with), but feel free to tell me if it's needed and I'll adjust the PR accordingly.
  • Loading branch information
bors committed Aug 24, 2021
2 parents 594192f + f0dd7a9 commit 72fdbd8
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions libc-test/semver/android.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,7 @@ strsignal
strspn
strstr
strtod
strtof
strtok
strtol
strtoul
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,7 @@ strrchr
strspn
strstr
strtod
strtof
strtok
strtol
strtoul
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ strrchr
strspn
strstr
strtod
strtof
strtok
strtol
strtoul
Expand Down
1 change: 1 addition & 0 deletions src/fuchsia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3394,6 +3394,7 @@ extern "C" {
pub fn perror(s: *const c_char);
pub fn atoi(s: *const c_char) -> c_int;
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
Expand Down
1 change: 1 addition & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ extern "C" {
link_name = "strtod$UNIX2003"
)]
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
Expand Down
1 change: 1 addition & 0 deletions src/vxworks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,7 @@ extern "C" {
pub fn perror(s: *const c_char);
pub fn atoi(s: *const c_char) -> c_int;
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
Expand Down
1 change: 1 addition & 0 deletions src/wasi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ extern "C" {
pub fn atoi(s: *const c_char) -> c_int;
pub fn atof(s: *const c_char) -> c_double;
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;

Expand Down
1 change: 1 addition & 0 deletions src/windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ extern "C" {
pub fn perror(s: *const c_char);
pub fn atoi(s: *const c_char) -> c_int;
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;
Expand Down

0 comments on commit 72fdbd8

Please sign in to comment.