Skip to content

Commit 434a398

Browse files
committed
Auto merge of #150752 - thesummer:update-libc-0.2.179, r=<try>
Update libc to v0.2.183 try-job: dist-various*
2 parents 37cfa17 + 05cda35 commit 434a398

5 files changed

Lines changed: 25 additions & 13 deletions

File tree

library/Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,9 @@ dependencies = [
146146

147147
[[package]]
148148
name = "libc"
149-
version = "0.2.178"
149+
version = "0.2.183"
150150
source = "registry+https://github.com/rust-lang/crates.io-index"
151-
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
151+
checksum = "b5b646652bf6661599e1da8901b3b9522896f01e736bad5f723fe7a3a27f899d"
152152
dependencies = [
153153
"rustc-std-workspace-core",
154154
]

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ miniz_oxide = { version = "0.8.0", optional = true, default-features = false }
3333
addr2line = { version = "0.25.0", optional = true, default-features = false }
3434

3535
[target.'cfg(not(all(windows, target_env = "msvc")))'.dependencies]
36-
libc = { version = "0.2.178", default-features = false, features = [
36+
libc = { version = "0.2.183", default-features = false, features = [
3737
'rustc-dep-of-std',
3838
], public = true }
3939

library/std/src/sys/fs/unix.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1872,7 +1872,12 @@ fn file_time_to_timespec(time: Option<SystemTime>) -> io::Result<libc::timespec>
18721872
io::ErrorKind::InvalidInput,
18731873
"timestamp is too small to set as a file time",
18741874
)),
1875-
None => Ok(libc::timespec { tv_sec: 0, tv_nsec: libc::UTIME_OMIT as _ }),
1875+
None => Ok({
1876+
let mut ts = libc::timespec::default();
1877+
ts.tv_sec = 0;
1878+
ts.tv_nsec = libc::UTIME_OMIT as _;
1879+
ts
1880+
}),
18761881
}
18771882
}
18781883

library/std/src/sys/pal/unix/time.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use core::mem;
12
use core::num::niche_types::Nanoseconds;
23

34
use crate::io;
@@ -6,8 +7,12 @@ use crate::time::Duration;
67
const NSEC_PER_SEC: u64 = 1_000_000_000;
78

89
#[allow(dead_code)] // Used for pthread condvar timeouts
9-
pub const TIMESPEC_MAX: libc::timespec =
10-
libc::timespec { tv_sec: <libc::time_t>::MAX, tv_nsec: 1_000_000_000 - 1 };
10+
pub const TIMESPEC_MAX: libc::timespec = {
11+
let mut ts = unsafe { mem::zeroed::<libc::timespec>() };
12+
ts.tv_sec = <libc::time_t>::MAX;
13+
ts.tv_nsec = 1_000_000_000 - 1;
14+
ts
15+
};
1116

1217
// This additional constant is only used when calling
1318
// `libc::pthread_cond_timedwait`.
@@ -164,9 +169,11 @@ impl Timespec {
164169

165170
#[allow(dead_code)]
166171
pub fn to_timespec(&self) -> Option<libc::timespec> {
167-
Some(libc::timespec {
168-
tv_sec: self.tv_sec.try_into().ok()?,
169-
tv_nsec: self.tv_nsec.as_inner().try_into().ok()?,
172+
Some({
173+
let mut ts = libc::timespec::default();
174+
ts.tv_sec = self.tv_sec.try_into().ok()?;
175+
ts.tv_nsec = self.tv_nsec.as_inner().try_into().ok()?;
176+
ts
170177
})
171178
}
172179

library/std/src/sys/thread/unix.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -570,10 +570,10 @@ pub fn sleep(dur: Duration) {
570570
// nanosleep will fill in `ts` with the remaining time.
571571
unsafe {
572572
while secs > 0 || nsecs > 0 {
573-
let mut ts = libc::timespec {
574-
tv_sec: cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t,
575-
tv_nsec: nsecs,
576-
};
573+
let mut ts = libc::timespec::default();
574+
ts.tv_sec = cmp::min(libc::time_t::MAX as u64, secs) as libc::time_t;
575+
ts.tv_nsec = nsecs;
576+
577577
secs -= ts.tv_sec as u64;
578578
let ts_ptr = &raw mut ts;
579579
let r = nanosleep(ts_ptr, ts_ptr);

0 commit comments

Comments
 (0)