File: time_t_workarounds.diff

package info (click to toggle)
rust-nix 0.29.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 3,096 kB
  • sloc: ansic: 18; makefile: 7
file content (55 lines) | stat: -rw-r--r-- 1,847 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
This patch works around an issue related to time64.

while posix says that tv_usec has type suseconds_t, glibc with
time64 enabled is not consistent with this. This patch adds conversion
operations (which would be implicit conversions in C/C++) to workaround this.

Index: rust-nix-0.26.2/src/sys/time.rs
===================================================================
--- rust-nix-0.26.2.orig/src/sys/time.rs
+++ rust-nix-0.26.2/src/sys/time.rs
@@ -529,7 +529,7 @@ impl TimeValLike for TimeVal {
         // https://github.com/rust-lang/libc/issues/1848
         TimeVal(timeval {
             tv_sec: secs as time_t,
-            tv_usec: micros as suseconds_t,
+            tv_usec: micros as _,
         })
     }
 
@@ -547,7 +547,7 @@ impl TimeValLike for TimeVal {
         // https://github.com/rust-lang/libc/issues/1848
         TimeVal(timeval {
             tv_sec: secs as time_t,
-            tv_usec: micros as suseconds_t,
+            tv_usec: micros as _,
         })
     }
 
@@ -584,7 +584,7 @@ impl TimeVal {
     pub const fn new(seconds: time_t, microseconds: suseconds_t) -> Self {
         Self(timeval {
             tv_sec: seconds,
-            tv_usec: microseconds,
+            tv_usec: microseconds as _,
         })
     }
 
@@ -602,7 +602,7 @@ impl TimeVal {
     }
 
     pub const fn tv_usec(&self) -> suseconds_t {
-        self.0.tv_usec
+        self.0.tv_usec as suseconds_t
     }
 }
 
Index: rust-nix-0.26.2/src/sys/resource.rs
===================================================================
--- rust-nix-0.26.2.orig/test/sys/test_resource.rs
+++ rust-nix-0.26.2/test/sys/test_resource.rs
@@ -438,3 +438,3 @@
     assert_eq!(user.tv_sec(), rusage.ru_utime.tv_sec);
-    assert_eq!(user.tv_usec(), rusage.ru_utime.tv_usec);
+    assert_eq!(user.tv_usec() as u64, rusage.ru_utime.tv_usec as u64);
 }