From 5429147b8b79333705f7799ce764fe03c2ce8a2c Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 27 Feb 2024 15:53:25 -0800 Subject: [PATCH] Move strftime, strftime_l, strptime to linux_like Bionic, uclibc and emscripten all support these functions. See: https://github.com/aosp-mirror/platform_bionic/blob/2215ad406b253f12e270cdd0876e19e9df2aa6d4/libc/include/time.h https://github.com/wbx-github/uclibc-ng/blame/fc3b6dc46a80e1f4aa468472aa6c7083f3bc6581/include/time.h https://github.com/emscripten-core/emscripten/blob/e25fa53069665c1f6c3be4ba5ed1d6ae82339849/system/lib/libc/musl/include/time.h (apply to `main`) [ make required changes to test files, resolve conflicts - Trevor ] (cherry picked from commit 4d6fe50954424fd89a5a229f8e0dbc9862d6809b) --- libc-test/semver/linux-gnu.txt | 3 --- libc-test/semver/linux-musl.txt | 3 --- libc-test/semver/linux.txt | 3 +++ src/unix/linux_like/linux/gnu/mod.rs | 15 --------------- src/unix/linux_like/linux/musl/mod.rs | 15 --------------- src/unix/linux_like/mod.rs | 15 +++++++++++++++ 6 files changed, 18 insertions(+), 36 deletions(-) diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index c4a8047a933c4..08ad12967f618 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -704,9 +704,6 @@ euidaccess eaccess asctime_r ctime_r -strftime -strftime_l -strptime dirname posix_basename gnu_basename diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index f6e293aa9b7fc..f0209f05dff27 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -84,7 +84,4 @@ pututxline pwritev64 reallocarray setutxent -strftime -strftime_l -strptime timex diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index ea0f848017b86..dc7af956cf4d8 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3941,8 +3941,11 @@ statvfs64 strcasecmp strcasestr strchrnul +strftime +strftime_l strncasecmp strndup +strptime strsignal swapoff swapon diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 706ee3264ff44..25eb4327cd5be 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1472,21 +1472,6 @@ extern "C" { pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char; - pub fn strftime( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - ) -> ::size_t; - pub fn strftime_l( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - locale: ::locale_t, - ) -> ::size_t; - pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; - pub fn confstr(name: ::c_int, buf: *mut ::c_char, len: ::size_t) -> ::size_t; pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; /// POSIX version of `basename(3)`, defined in `libgen.h`. diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 1a93c39fd3a0a..f1fc8cc76ee67 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -878,21 +878,6 @@ extern "C" { pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; - pub fn strftime( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - ) -> ::size_t; - pub fn strftime_l( - s: *mut ::c_char, - max: ::size_t, - format: *const ::c_char, - tm: *const ::tm, - locale: ::locale_t, - ) -> ::size_t; - pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; - pub fn dirname(path: *mut ::c_char) -> *mut ::c_char; pub fn basename(path: *mut ::c_char) -> *mut ::c_char; diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index bdbec9c651fc5..de27746971ed3 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1766,6 +1766,21 @@ extern "C" { pub fn uname(buf: *mut ::utsname) -> ::c_int; pub fn strchrnul(s: *const ::c_char, c: ::c_int) -> *mut ::c_char; + + pub fn strftime( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + ) -> ::size_t; + pub fn strftime_l( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + locale: ::locale_t, + ) -> ::size_t; + pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; } // LFS64 extensions