Skip to content

Commit 72fdbd8

Browse files
committed
Auto merge of #2358 - hcsch:add-strtof, r=JohnTitor
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.
2 parents 594192f + f0dd7a9 commit 72fdbd8

File tree

8 files changed

+8
-0
lines changed

8 files changed

+8
-0
lines changed

libc-test/semver/android.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,7 @@ strsignal
32153215
strspn
32163216
strstr
32173217
strtod
3218+
strtof
32183219
strtok
32193220
strtol
32203221
strtoul

libc-test/semver/unix.txt

+1
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,7 @@ strrchr
814814
strspn
815815
strstr
816816
strtod
817+
strtof
817818
strtok
818819
strtol
819820
strtoul

libc-test/semver/windows.txt

+1
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ strrchr
298298
strspn
299299
strstr
300300
strtod
301+
strtof
301302
strtok
302303
strtol
303304
strtoul

src/fuchsia/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3394,6 +3394,7 @@ extern "C" {
33943394
pub fn perror(s: *const c_char);
33953395
pub fn atoi(s: *const c_char) -> c_int;
33963396
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
3397+
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
33973398
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
33983399
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
33993400
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;

src/unix/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ extern "C" {
486486
link_name = "strtod$UNIX2003"
487487
)]
488488
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
489+
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
489490
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
490491
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
491492
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;

src/vxworks/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,7 @@ extern "C" {
11211121
pub fn perror(s: *const c_char);
11221122
pub fn atoi(s: *const c_char) -> c_int;
11231123
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
1124+
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
11241125
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
11251126
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
11261127
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;

src/wasi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ extern "C" {
447447
pub fn atoi(s: *const c_char) -> c_int;
448448
pub fn atof(s: *const c_char) -> c_double;
449449
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
450+
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
450451
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
451452
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
452453

src/windows/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ extern "C" {
319319
pub fn perror(s: *const c_char);
320320
pub fn atoi(s: *const c_char) -> c_int;
321321
pub fn strtod(s: *const c_char, endp: *mut *mut c_char) -> c_double;
322+
pub fn strtof(s: *const c_char, endp: *mut *mut c_char) -> c_float;
322323
pub fn strtol(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_long;
323324
pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong;
324325
pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void;

0 commit comments

Comments
 (0)