Skip to content

Commit bcbf9eb

Browse files
committed
feat: deprecate windows time64_t
Functionality related to Windows `time64_t` has been deprecated in favor of a single, 64-bit wide `time_t`. This has also required some work into getting rid of the conditional compilation uses of `time_t` on GNU target environments, and tweaking the `max_align_t` type. The `FIXME` comment on the tier 1 platform support for Windows with GNU has also been removed as no segfaults were observed.
1 parent f3417ae commit bcbf9eb

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

libc-test/build.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ fn test_cygwin(target: &str) {
753753
fn test_windows(target: &str) {
754754
assert!(target.contains("windows"));
755755
let gnu = target.contains("gnu");
756-
let i686 = target.contains("i686");
757756

758757
let mut cfg = ctest_cfg();
759758

@@ -818,19 +817,9 @@ fn test_windows(target: &str) {
818817
cfg.skip_alias(move |alias| match alias.ident() {
819818
"SSIZE_T" if !gnu => true,
820819
"ssize_t" if !gnu => true,
821-
// FIXME(windows): The size and alignment of this type are incorrect
822-
"time_t" if gnu && i686 => true,
823820
_ => false,
824821
});
825822

826-
cfg.skip_struct(move |struct_| {
827-
match struct_.ident() {
828-
// FIXME(windows): The size and alignment of this struct are incorrect
829-
"timespec" if gnu && i686 => true,
830-
_ => false,
831-
}
832-
});
833-
834823
cfg.skip_const(move |constant| {
835824
match constant.ident() {
836825
// FIXME(windows): API error:

libc-test/tests/windows_time.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Ensures Windows `time`-related routines align with `libc`'s interface. By
2+
//! default, both MSVC and GNU (under `mingw`) expose 64-bit symbols. `libc`
3+
//! also does that, but there's been slight inconsistencies in the past.
4+
5+
#![cfg(windows)]
6+
7+
/// Ensures a 64-bit write is performed on values that should always be 64 bits.
8+
/// This may fail if
9+
/// (1) the routine links with its 32-bit variant. This only happens if
10+
/// `_USE_32BIT_TIME_T` is defined. In theory, this should not be
11+
/// possible when working with Rust's `libc`.
12+
/// (2) Or `time_t` is 32-bits, and a 64-bit write overwrites both array items.
13+
/// This should neither be possible unless the above macro is defined.
14+
/// Support for non-64-bit values in `libc` should thus be non-existent.
15+
#[test]
16+
fn test_64_bit_store() {
17+
let mut time_values: [libc::time_t; 2] = [123, 456];
18+
let ptr = time_values.as_mut_ptr();
19+
unsafe { libc::time(ptr) };
20+
assert!(time_values[0] != 123);
21+
assert_eq!(time_values[1], 456);
22+
}

src/windows/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,7 @@ pub type clock_t = i32;
1818

1919
pub type errno_t = c_int;
2020

21-
cfg_if! {
22-
if #[cfg(all(target_arch = "x86", target_env = "gnu"))] {
23-
pub type time_t = i32;
24-
} else {
25-
pub type time_t = i64;
26-
}
27-
}
21+
pub type time_t = i64;
2822

2923
pub type off_t = i32;
3024
pub type dev_t = u32;
@@ -34,6 +28,12 @@ extern_ty! {
3428
pub enum timezone {}
3529
}
3630

31+
#[deprecated(
32+
since = "1.0.0",
33+
note = "This time-related value, among others, is part of the shift \
34+
towards using a single, 64-bit-sized `time_t`. See #PENDING for \
35+
discussion."
36+
)]
3737
pub type time64_t = i64;
3838

3939
pub type SOCKET = crate::uintptr_t;

0 commit comments

Comments
 (0)