libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 40f7a33a09018b3e6911cdf68a88a159c979946c
parent 0e85520a9ba28cf0ad9ddf3c604ccf129f0e593e
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 27 Aug 2021 11:34:35 +0300

mhd_mono_clock: updated clock IDs

Diffstat:
Msrc/microhttpd/mhd_mono_clock.c | 30++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/microhttpd/mhd_mono_clock.c b/src/microhttpd/mhd_mono_clock.c @@ -183,9 +183,23 @@ MHD_monotonic_sec_counter_init (void) } else #endif /* CLOCK_MONOTONIC_COARSE */ +#ifdef CLOCK_MONOTONIC_RAW_APPROX + /* Darwin-specific clock */ + /* Not affected by frequency adjustment, returns clock value cached at + * context switch. Can be "milliseconds old", but it's fast. */ + if (0 == clock_gettime (CLOCK_MONOTONIC_RAW_APPROX, + &ts)) + { + mono_clock_id = CLOCK_MONOTONIC_RAW_APPROX; + mono_clock_start = ts.tv_sec; + mono_clock_source = _MHD_CLOCK_GETTIME; + } + else +#endif /* CLOCK_MONOTONIC_RAW */ #ifdef CLOCK_MONOTONIC_RAW - /* Linux-specific clock */ - /* Not affected by frequency adjustment, but don't count time in suspend */ + /* Linux and Darwin clock */ + /* Not affected by frequency adjustment, + * on Linux don't count time in suspend */ if (0 == clock_gettime (CLOCK_MONOTONIC_RAW, &ts)) { @@ -221,6 +235,18 @@ MHD_monotonic_sec_counter_init (void) } else #endif /* CLOCK_BOOTTIME */ +#ifdef CLOCK_UPTIME + /* non-Linux clock */ + /* Doesn't count time in suspend */ + if (0 == clock_gettime (CLOCK_UPTIME, + &ts)) + { + mono_clock_id = CLOCK_UPTIME; + mono_clock_start = ts.tv_sec; + mono_clock_source = _MHD_CLOCK_GETTIME; + } + else +#endif /* CLOCK_BOOTTIME */ #endif /* HAVE_CLOCK_GETTIME */ #ifdef HAVE_CLOCK_GET_TIME /* Darwin-specific monotonic clock */