AK: Use POSIX specified types for Time::to_timespec and to_timeval

The previous implementation assumed 64-bit time_t and 32-bit long,
which is not true on some 32-bit systems
This commit is contained in:
Richard Wurth 2021-08-21 22:49:44 -04:00 committed by Andreas Kling
parent f5b69dce0b
commit 4b2953125b
Notes: sideshowbarker 2024-07-18 05:23:22 +09:00

View file

@ -170,12 +170,12 @@ i64 Time::to_nanoseconds() const
timespec Time::to_timespec() const
{
VERIFY(m_nanoseconds < 1'000'000'000);
return { static_cast<i64>(m_seconds), static_cast<i32>(m_nanoseconds) };
return { static_cast<time_t>(m_seconds), static_cast<long>(m_nanoseconds) };
}
timeval Time::to_timeval() const
{
VERIFY(m_nanoseconds < 1'000'000'000);
return { static_cast<i64>(m_seconds), static_cast<i32>(m_nanoseconds) / 1000 };
return { static_cast<time_t>(m_seconds), static_cast<suseconds_t>(m_nanoseconds) / 1000 };
}
Time Time::operator+(const Time& other) const