Add safe rules for time#260
Conversation
The output between linux and macos differs
| } | ||
| } | ||
|
|
||
| #[cfg(target_os = "linux")] |
There was a problem hiding this comment.
the implementation seems to be the same in linux and mac; why do we need both?
There was a problem hiding this comment.
Only the signature is different between linux and macos. Linux receives a struct timezone pointer, macos receives a void pointer:
https://man7.org/linux/man-pages/man2/gettimeofday.2.html
https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/gettimeofday.2.html
| } | ||
|
|
||
| #[cfg(target_os = "linux")] | ||
| fn f8(a0: Ptr<Timeval>, a1: Ptr<::libc::timezone>) -> i32 { |
There was a problem hiding this comment.
with this 2nd parameter?
| } | ||
|
|
||
| #[cfg(target_os = "macos")] | ||
| fn f8(a0: Ptr<Timeval>, a1: AnyPtr) -> i32 { |
There was a problem hiding this comment.
this is ignoring the 2nd parameter. At least it should have a TODO.
There was a problem hiding this comment.
Both man pages (linux and macos) say that the second param is obsolete. I will add a comment about that
There was a problem hiding this comment.
I added a comment about that
| *__tm.tm_yday.borrow_mut() = __dt.day_of_year() as i32 - 1; | ||
| *__tm.tm_isdst.borrow_mut() = 0; | ||
| *__tm.tm_gmtoff.borrow_mut() = 0; | ||
| *__tm.tm_zone.borrow_mut() = Ptr::from_string_literal(b"GMT"); |
There was a problem hiding this comment.
It's GMT on linux and UTC on macos
This reverts commit b32c7da.
This also adds a new dependency called jiff. jiff is used to avoid manually implementing strftime and localtime_r
In general, nix only contains safe wrappers over syscalls. Everything which is a pure library implementation is not included