From f0dd7a93e9b7f45382dc6d96e9308881a0874ff0 Mon Sep 17 00:00:00 2001 From: Hans Christian Schmitz Date: Sun, 22 Aug 2021 17:55:13 +0200 Subject: [PATCH] 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` comparing against `strtof`, which can't (easily) be done with `strtod`, due to float rounding and over-/underflow behavior. --- libc-test/semver/android.txt | 1 + libc-test/semver/unix.txt | 1 + libc-test/semver/windows.txt | 1 + src/fuchsia/mod.rs | 1 + src/unix/mod.rs | 1 + src/vxworks/mod.rs | 1 + src/wasi.rs | 1 + src/windows/mod.rs | 1 + 8 files changed, 8 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 94d7bd7882622..8903fc481a429 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -3215,6 +3215,7 @@ strsignal strspn strstr strtod +strtof strtok strtol strtoul diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 300dd266636c8..5d878ed327df7 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -814,6 +814,7 @@ strrchr strspn strstr strtod +strtof strtok strtol strtoul diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index 5f1c97b8e4c68..259e3766ff634 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -298,6 +298,7 @@ strrchr strspn strstr strtod +strtof strtok strtol strtoul diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index e7150eac37f99..237760429d36e 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -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; diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 21f903b65902d..3ac1669b9a882 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -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; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 7372abea6a4fe..2772d68d2f4b1 100755 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -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; diff --git a/src/wasi.rs b/src/wasi.rs index 0fc6280258635..f66ca92857955 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -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; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 1b5de0bacb4a0..71af46a27299e 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -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;