File tree Expand file tree Collapse file tree 3 files changed +29
-18
lines changed
Expand file tree Collapse file tree 3 files changed +29
-18
lines changed Original file line number Diff line number Diff line change @@ -753,7 +753,6 @@ fn test_cygwin(target: &str) {
753753fn 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:
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -18,13 +18,7 @@ pub type clock_t = i32;
1818
1919pub 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
2923pub type off_t = i32 ;
3024pub 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+ ) ]
3737pub type time64_t = i64 ;
3838
3939pub type SOCKET = crate :: uintptr_t ;
You can’t perform that action at this time.
0 commit comments