From 00c891c0c8e187feba3ca953efafd897de56d826 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Sat, 2 Aug 2025 22:56:07 +0200 Subject: [PATCH] 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 Tested-by: Commit checker robot --- headers/compatibility/bsd/sys/time.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/headers/compatibility/bsd/sys/time.h b/headers/compatibility/bsd/sys/time.h index 02471b2916..06ad1d530b 100644 --- a/headers/compatibility/bsd/sys/time.h +++ b/headers/compatibility/bsd/sys/time.h @@ -39,6 +39,14 @@ #define timespecvalid_interval(a) ((a)->tv_sec >= 0 \ && (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 extern "C" {