Skip to content

Commit

Permalink
Auto merge of #2957 - SteveLauC:time-fn, r=JohnTitor
Browse files Browse the repository at this point in the history
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:)
  • Loading branch information
bors committed Oct 12, 2022
2 parents 88b2ed2 + bfc4064 commit 2173b34
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
6 changes: 5 additions & 1 deletion libc-test/semver/linux-gnu.txt
Expand Up @@ -653,4 +653,8 @@ utmpname
utmpx
utmpxname
euidaccess
eaccess
eaccess
asctime_r
ctime_r
strftime
strptime
5 changes: 4 additions & 1 deletion libc-test/semver/linux-musl.txt
Expand Up @@ -49,4 +49,7 @@ pwritev64
reallocarray
timex
euidaccess
eaccess
eaccess
asctime_r
strftime
strptime
11 changes: 11 additions & 0 deletions src/unix/linux_like/linux/gnu/mod.rs
Expand Up @@ -1335,6 +1335,17 @@ extern "C" {

pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;

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 strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
}

extern "C" {
Expand Down
10 changes: 10 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Expand Up @@ -757,6 +757,16 @@ extern "C" {

pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;
pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int;

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 strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char;
}

cfg_if! {
Expand Down

0 comments on commit 2173b34

Please sign in to comment.