Skip to content

Commit 9960e1c

Browse files
committed
Auto merge of #2957 - SteveLauC:time-fn, r=JohnTitor
add some time functions on glibc and musl #### man pages * [asctime/ctime man page](https://man7.org/linux/man-pages/man3/ctime.3.html) * [strftime](https://man7.org/linux/man-pages/man3/strftime.3.html) * [strptime](https://man7.org/linux/man-pages/man3/strptime.3.html) I didn't add `ctime()/ctime_r()` on musl because they involve the `time_t` type, which elicits [a deprecation wraning](#1956). Is it fine to add these two functions on `musl`, they will have the same definitions as the `glibc` ones: ```rust pub fn ctime(timep: *const time_t) -> *mut ::c_char; pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char; ``` If it's ok, I will add them:)
2 parents 80b2ede + bfc4064 commit 9960e1c

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

libc-test/semver/linux-gnu.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -653,4 +653,8 @@ utmpname
653653
utmpx
654654
utmpxname
655655
euidaccess
656-
eaccess
656+
eaccess
657+
asctime_r
658+
ctime_r
659+
strftime
660+
strptime

libc-test/semver/linux-musl.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,7 @@ pwritev64
4949
reallocarray
5050
timex
5151
euidaccess
52-
eaccess
52+
eaccess
53+
asctime_r
54+
strftime
55+
strptime

src/unix/linux_like/linux/gnu/mod.rs

+11
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,17 @@ extern "C" {
13351335

13361336
pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
13371337
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
1338+
1339+
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
1340+
pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char;
1341+
1342+
pub fn strftime(
1343+
s: *mut ::c_char,
1344+
max: ::size_t,
1345+
format: *const ::c_char,
1346+
tm: *const ::tm,
1347+
) -> ::size_t;
1348+
pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
13381349
}
13391350

13401351
extern "C" {

src/unix/linux_like/linux/musl/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,16 @@ extern "C" {
757757

758758
pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
759759
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
760+
761+
pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char;
762+
763+
pub fn strftime(
764+
s: *mut ::c_char,
765+
max: ::size_t,
766+
format: *const ::c_char,
767+
tm: *const ::tm,
768+
) -> ::size_t;
769+
pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
760770
}
761771

762772
cfg_if! {

0 commit comments

Comments
 (0)