From 6a58758d5f4198305191747c5c8b6af3c5057898 Mon Sep 17 00:00:00 2001 From: LegionMammal978 Date: Mon, 12 Dec 2022 19:02:00 -0500 Subject: [PATCH] Add ISO C functions atof, atol, atoll, strtoll, strtoull --- libc-test/semver/android.txt | 5 +++++ libc-test/semver/apple.txt | 1 - libc-test/semver/dragonfly.txt | 1 - libc-test/semver/freebsd.txt | 1 - libc-test/semver/fuchsia.txt | 5 +++++ libc-test/semver/linux.txt | 1 - libc-test/semver/netbsd.txt | 1 - libc-test/semver/openbsd.txt | 1 - libc-test/semver/unix.txt | 5 +++++ libc-test/semver/windows.txt | 4 ++++ src/fuchsia/mod.rs | 6 +++++- src/unix/bsd/mod.rs | 1 - src/unix/haiku/mod.rs | 1 - src/unix/hermit/mod.rs | 1 - src/unix/linux_like/emscripten/mod.rs | 1 - src/unix/linux_like/linux/mod.rs | 1 - src/unix/mod.rs | 5 +++++ src/unix/newlib/mod.rs | 1 - src/unix/solarish/mod.rs | 1 - src/vxworks/mod.rs | 5 +++++ src/wasi.rs | 6 +++++- src/windows/mod.rs | 6 +++++- 22 files changed, 44 insertions(+), 16 deletions(-) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 815a97eeb3c49..c2c417a2da2b6 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2854,7 +2854,10 @@ arphdr arpreq arpreq_old atexit +atof atoi +atol +atoll bind blkcnt_t blksize_t @@ -3504,7 +3507,9 @@ strtod strtof strtok strtol +strtoll strtoul +strtoull strxfrm suseconds_t swapoff diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt index 329c8cdaac15b..3a39b2e9ca20b 100644 --- a/libc-test/semver/apple.txt +++ b/libc-test/semver/apple.txt @@ -1818,7 +1818,6 @@ arc4random arc4random_buf arc4random_uniform arphdr -atof attrgroup_t attribute_set_t attrlist diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt index 8d0172c112adf..115c2919af3b1 100644 --- a/libc-test/semver/dragonfly.txt +++ b/libc-test/semver/dragonfly.txt @@ -1221,7 +1221,6 @@ arc4random arc4random_buf arc4random_uniform arphdr -atof backtrace backtrace_symbols backtrace_symbols_fd diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index 8a7756c2a2812..c188346b9b740 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -1493,7 +1493,6 @@ arc4random arc4random_buf arc4random_uniform arphdr -atof au_asid_t au_id_t au_mask_t diff --git a/libc-test/semver/fuchsia.txt b/libc-test/semver/fuchsia.txt index a4ff41defe586..804b27093095a 100644 --- a/libc-test/semver/fuchsia.txt +++ b/libc-test/semver/fuchsia.txt @@ -1168,6 +1168,9 @@ accept4 acct aiocb atof +atoi +atol +atoll blkcnt64_t brk clearenv @@ -1366,6 +1369,8 @@ stat64 statfs statfs64 statvfs64 +strtoll +strtoull swapoff swapon sync diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 087b1fc10c586..e64ebe1918e9e 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2868,7 +2868,6 @@ arpd_request arphdr arpreq arpreq_old -atof blkcnt64_t brk bsearch diff --git a/libc-test/semver/netbsd.txt b/libc-test/semver/netbsd.txt index d6d519fd58ddb..71cd0d3a48cdc 100644 --- a/libc-test/semver/netbsd.txt +++ b/libc-test/semver/netbsd.txt @@ -1166,7 +1166,6 @@ arc4random arc4random_buf arc4random_uniform arphdr -atof bsearch chflags chroot diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index 0dcd2b40c8ae4..07d419a61970e 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -977,7 +977,6 @@ arc4random arc4random_buf arc4random_uniform arphdr -atof backtrace backtrace_symbols backtrace_symbols_fd diff --git a/libc-test/semver/unix.txt b/libc-test/semver/unix.txt index 269c0ff0e5846..8928c27feff9f 100644 --- a/libc-test/semver/unix.txt +++ b/libc-test/semver/unix.txt @@ -451,7 +451,10 @@ access addrinfo alarm atexit +atof atoi +atol +atoll bind blkcnt_t blksize_t @@ -818,7 +821,9 @@ strtod strtof strtok strtol +strtoll strtoul +strtoull strxfrm suseconds_t symlink diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index 1ddf031b1440f..70ff4df20ff94 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -152,6 +152,8 @@ aligned_free atexit atof atoi +atol +atoll bind c_char c_double @@ -307,7 +309,9 @@ strtod strtof strtok strtol +strtoll strtoul +strtoull strxfrm system time diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 7a9edada1f50b..5c6aebde23b01 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -3402,11 +3402,16 @@ extern "C" { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; 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 strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; @@ -3448,7 +3453,6 @@ extern "C" { pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; pub fn abs(i: c_int) -> c_int; - pub fn atof(s: *const c_char) -> c_double; pub fn labs(i: c_long) -> c_long; pub fn rand() -> c_int; pub fn srand(seed: c_uint); diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d49e3c44028c9..84e572edabee4 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -613,7 +613,6 @@ extern "C" { pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; #[cfg_attr( all(target_os = "freebsd", any(freebsd12, freebsd11, freebsd10)), diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 005b1d9df5c56..95ddadaeeac47 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -1592,7 +1592,6 @@ extern "C" { pub fn _errnop() -> *mut ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); diff --git a/src/unix/hermit/mod.rs b/src/unix/hermit/mod.rs index eedfd28a49c23..6a656a8598f21 100644 --- a/src/unix/hermit/mod.rs +++ b/src/unix/hermit/mod.rs @@ -966,7 +966,6 @@ extern "C" { pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 11fbb31c3830d..f2024900cbca9 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1763,7 +1763,6 @@ extern "C" { pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 743927e5172f2..9658f07446370 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -3804,7 +3804,6 @@ extern "C" { pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fb9ebf792e53d..a5722381cb8ff 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -492,7 +492,10 @@ extern "C" { pub fn ferror(stream: *mut FILE) -> c_int; pub fn clearerr(stream: *mut FILE); pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; #[cfg_attr( all(target_os = "macos", target_arch = "x86"), link_name = "strtod$UNIX2003" @@ -500,7 +503,9 @@ extern "C" { 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 strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 1a694691a635f..3875f1cb4e9d3 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -621,7 +621,6 @@ extern "C" { pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; pub fn srand(seed: ::c_uint); diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index abe304e8ea52b..99135d5f5940a 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -2710,7 +2710,6 @@ extern "C" { pub fn abs(i: ::c_int) -> ::c_int; pub fn acct(filename: *const ::c_char) -> ::c_int; - pub fn atof(s: *const ::c_char) -> ::c_double; pub fn dirfd(dirp: *mut ::DIR) -> ::c_int; pub fn labs(i: ::c_long) -> ::c_long; pub fn rand() -> ::c_int; diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 2772d68d2f4b1..6b705e8a22c81 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -1119,11 +1119,16 @@ extern "C" { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; 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 strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; diff --git a/src/wasi.rs b/src/wasi.rs index c5dd670477129..abfebd6439326 100644 --- a/src/wasi.rs +++ b/src/wasi.rs @@ -540,12 +540,16 @@ extern "C" { pub fn setvbuf(stream: *mut FILE, buffer: *mut c_char, mode: c_int, size: size_t) -> c_int; pub fn setbuf(stream: *mut FILE, buf: *mut c_char); pub fn fgets(buf: *mut c_char, n: c_int, stream: *mut FILE) -> *mut c_char; - pub fn atoi(s: *const c_char) -> c_int; pub fn atof(s: *const c_char) -> c_double; + pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; 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 strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; pub fn strcpy(dst: *mut c_char, src: *const c_char) -> *mut c_char; pub fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 916019b1f211b..7f2f1ded19ec7 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -329,11 +329,16 @@ extern "C" { pub fn feof(stream: *mut FILE) -> c_int; pub fn ferror(stream: *mut FILE) -> c_int; pub fn perror(s: *const c_char); + pub fn atof(s: *const c_char) -> c_double; pub fn atoi(s: *const c_char) -> c_int; + pub fn atol(s: *const c_char) -> c_long; + pub fn atoll(s: *const c_char) -> c_longlong; 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 strtoll(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_longlong; pub fn strtoul(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulong; + pub fn strtoull(s: *const c_char, endp: *mut *mut c_char, base: c_int) -> c_ulonglong; pub fn calloc(nobj: size_t, size: size_t) -> *mut c_void; pub fn malloc(size: size_t) -> *mut c_void; pub fn realloc(p: *mut c_void, size: size_t) -> *mut c_void; @@ -374,7 +379,6 @@ extern "C" { pub fn memset(dest: *mut c_void, c: c_int, n: size_t) -> *mut c_void; pub fn abs(i: c_int) -> c_int; - pub fn atof(s: *const c_char) -> c_double; pub fn labs(i: c_long) -> c_long; pub fn rand() -> c_int; pub fn srand(seed: c_uint);