aboutsummaryrefslogtreecommitdiff
path: root/util/time.c
AgeCommit message (Collapse)Author
2024-02-15Define _POSIX_C_SOURCE globallySimon Ser
Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead, require POSIX.1-2008 globally. A lot of core source files depend on that already. Some care must be taken on a few select files where we need a bit more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and some files need BSD extensions (_DEFAULT_SOURCE). In both cases, these feature test macros imply _POSIX_C_SOURCE. Make sure to not define both these macros and _POSIX_C_SOURCE explicitly to avoid POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001 but _XOPEN_SOURCE says POSIX.1-2008). Additionally, there is one special case in render/vulkan/vulkan.c. That file needs major()/minor(), and these are system-specific. On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need to make sure it's not defined for this file. On Linux, we can explicitly include <sys/sysmacros.h> and ensure that apart from symbols defined there the file only uses POSIX toys.
2023-06-05util: add timespec_to_nsecRose Hudson
2022-11-25util/time: use int64_t return value for get_current_time_msec()Simon Ser
0xFFFFFFFF milliseconds is 4,294,967,295 ms so about 50 days. A little bit too close for comfort. Use int64_t instead of uint64_t to avoid C's implicit conversion footguns in computations.
2021-07-28util/time: make NSEC_PER_SEC staticDylan Araps
This fixes static linking with libseat. Closes #3072
2020-12-18util/time: add timespec_from_nsecSimon Ser
2020-06-06util/time: move `timespec_sub` to time utilitiesTudor Brindus
2020-06-06util/time: de-duplicate `timespec_to_msec`Tudor Brindus
2020-06-06util: fix and move `get_current_time_msec` into a util fileTudor Brindus
This commit makes `get_current_time_msec` correctly return milliseconds as opposed to microseconds. It also considers the value of `tv_sec`, so we don't lose occasionally go back in time by one second. Finally, the function is moved into `util/time.cc` so that it can be reused elsewhere without having to consider these pitfalls.