sys/time.h: Add TIMEVAL_TO_TIMESPEC and TIMESPEC_TO_TIMEVAL.

They're found in this header on the BSDs and Linux.

Change-Id: Ic822138dbedb046f85c5d4e92bf393a4496bd6a1
Reviewed-on: https://review.haiku-os.org/c/haiku/+/9556
Reviewed-by: waddlesplash <[email protected]>
Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
Peter van Dijk
2025-08-03 22:47:57 +00:00
committed by waddlesplash
parent e32d782cb4
commit 00c891c0c8
+8
View File
@@ -39,6 +39,14 @@
#define timespecvalid_interval(a) ((a)->tv_sec >= 0 \ #define timespecvalid_interval(a) ((a)->tv_sec >= 0 \
&& (a)->tv_nsec >= 0 && (&)->tv_nsec < 1000000000L) && (a)->tv_nsec >= 0 && (&)->tv_nsec < 1000000000L)
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
(ts)->tv_sec = (tv)->tv_sec; \
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
} while (0)
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
(tv)->tv_sec = (ts)->tv_sec; \
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
} while (0)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {