Skip to content

Commit 8bb4294

Browse files
[libc] Fix compilation warnings on 32-bit archs (#97745)
timespec's tv_nsec is a long int, which has different sizes in 32-bit and 64-bit platforms, so this patch adds one and fixes another static_cast throw warnings in 32-bit archs
1 parent 2307d27 commit 8bb4294

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

libc/src/sched/linux/sched_rr_get_interval.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ LLVM_LIBC_FUNCTION(int, sched_rr_get_interval,
3636
tid, &ts32);
3737
if (ret == 0) {
3838
tp->tv_sec = ts32.tv_sec;
39-
tp->tv_nsec = ts32.tv_nsec;
39+
tp->tv_nsec = static_cast<long int>(ts32.tv_nsec);
4040
}
4141
} else
4242
// When tp is a nullptr, we still do the syscall to set ret and errno

libc/test/src/__support/time/linux/timeout_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ TEST(LlvmLibcSupportLinuxTimeoutTest, NoChangeIfClockIsMonotonic) {
4545
ensure_monotonicity(*result);
4646
ASSERT_FALSE(result->is_realtime());
4747
ASSERT_EQ(result->get_timespec().tv_sec, static_cast<time_t>(10000));
48-
ASSERT_EQ(result->get_timespec().tv_nsec, static_cast<time_t>(0));
48+
ASSERT_EQ(result->get_timespec().tv_nsec, static_cast<long int>(0));
4949
}
5050
TEST(LlvmLibcSupportLinuxTimeoutTest, ValidAfterConversion) {
5151
timespec ts;

0 commit comments

Comments
 (0)