mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
AK: Add timeval_to_timespec and timespec_to_timeval conversion methods
Add the ability to easily convert between timeval and timespec.
This commit is contained in:
parent
089022e7f6
commit
1a80aa999a
Notes:
sideshowbarker
2024-07-19 07:16:04 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/1a80aa999ab Pull-request: https://github.com/SerenityOS/serenity/pull/1964 Reviewed-by: https://github.com/awesomekling
1 changed files with 16 additions and 0 deletions
16
AK/Time.h
16
AK/Time.h
|
@ -50,7 +50,23 @@ inline void timeval_add(const TimevalType& a, const TimevalType& b, TimevalType&
|
|||
}
|
||||
}
|
||||
|
||||
template<typename TimevalType, typename TimespecType>
|
||||
inline void timeval_to_timespec(const TimevalType& tv, TimespecType& ts)
|
||||
{
|
||||
ts.tv_sec = tv.tv_sec;
|
||||
ts.tv_nsec = tv.tv_usec * 1000;
|
||||
}
|
||||
|
||||
template<typename TimespecType, typename TimevalType>
|
||||
inline void timespec_to_timeval(const TimespecType& ts, TimevalType& tv)
|
||||
{
|
||||
tv.tv_sec = ts.tv_sec;
|
||||
tv.tv_usec = ts.tv_nsec / 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using AK::timeval_add;
|
||||
using AK::timeval_sub;
|
||||
using AK::timeval_to_timespec;
|
||||
using AK::timespec_to_timeval;
|
||||
|
|
Loading…
Reference in a new issue