Commit 24a0eec
committed
Auto merge of rust-lang#96657 - cuviper:time64, r=joshtriplett
Use 64-bit time on 32-bit linux-gnu
The standard library suffered the [Year 2038 problem][Y2038] in two main places on targets with 32-bit `time_t`:
- In `std::time::SystemTime`, we stored a `timespec` that has `time_t` seconds. This is now changed to directly store 64-bit seconds and nanoseconds, and on 32-bit linux-gnu we try to use `__clock_gettime64` (glibc 2.34+) to get the larger timestamp.
- In `std::fs::Metadata`, we store a `stat64`, which has 64-bit `off_t` but still 32-bit `time_t`, and unfortunately that is baked in the API by the (deprecated) `MetadataExt::as_raw_stat()`. However, we can use `statx` for 64-bit `statx_timestamp` to store in addition to the `stat64`, as we already do to support creation time, and the rest of the `MetadataExt` methods can return those full values. Note that some filesystems may still be limited in their actual timestamp support, but that's not something Rust can change.
There remain a few places that need `timespec` for system call timeouts -- I leave that to future work.
[Y2038]: https://en.wikipedia.org/wiki/Year_2038_problemFile tree
5 files changed
+205
-168
lines changed- library/std/src
- os/linux
- sys/unix
5 files changed
+205
-168
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
360 | 365 | | |
361 | 366 | | |
362 | 367 | | |
363 | 368 | | |
364 | 369 | | |
365 | | - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
366 | 376 | | |
367 | 377 | | |
368 | 378 | | |
369 | 379 | | |
370 | 380 | | |
371 | | - | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 | | |
373 | 388 | | |
374 | 389 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
116 | 124 | | |
117 | 125 | | |
118 | | - | |
119 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
120 | 129 | | |
121 | 130 | | |
122 | 131 | | |
| |||
192 | 201 | | |
193 | 202 | | |
194 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
195 | 211 | | |
196 | 212 | | |
197 | 213 | | |
| |||
310 | 326 | | |
311 | 327 | | |
312 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
313 | 359 | | |
314 | 360 | | |
315 | 361 | | |
| |||
335 | 381 | | |
336 | 382 | | |
337 | 383 | | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
| 384 | + | |
342 | 385 | | |
343 | 386 | | |
344 | 387 | | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
| 388 | + | |
349 | 389 | | |
350 | 390 | | |
351 | 391 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
| 392 | + | |
356 | 393 | | |
357 | 394 | | |
358 | 395 | | |
359 | 396 | | |
360 | 397 | | |
361 | 398 | | |
362 | 399 | | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
367 | 408 | | |
368 | 409 | | |
369 | 410 | | |
370 | 411 | | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
| 412 | + | |
375 | 413 | | |
376 | 414 | | |
377 | 415 | | |
378 | 416 | | |
379 | | - | |
380 | | - | |
381 | | - | |
382 | | - | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
383 | 425 | | |
384 | 426 | | |
385 | 427 | | |
386 | 428 | | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
| 429 | + | |
391 | 430 | | |
392 | 431 | | |
393 | 432 | | |
| |||
397 | 436 | | |
398 | 437 | | |
399 | 438 | | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
| 439 | + | |
404 | 440 | | |
405 | 441 | | |
406 | 442 | | |
| |||
413 | 449 | | |
414 | 450 | | |
415 | 451 | | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
| 452 | + | |
420 | 453 | | |
421 | 454 | | |
422 | 455 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
65 | | - | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
0 commit comments