mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-23 03:06:48 +00:00
![Dag-Erling Smørgrav](/assets/img/avatar_default.png)
This also adds support for TIME_MONOTONIC to timespec_get(3). Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D41524
25 lines
387 B
C
25 lines
387 B
C
/*-
|
|
* Copyright (c) 2023 Dag-Erling Smørgrav
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <time.h>
|
|
|
|
int
|
|
timespec_getres(struct timespec *ts, int base)
|
|
{
|
|
|
|
switch (base) {
|
|
case TIME_UTC:
|
|
if (clock_getres(CLOCK_REALTIME, ts) == 0)
|
|
return (base);
|
|
break;
|
|
case TIME_MONOTONIC:
|
|
if (clock_getres(CLOCK_MONOTONIC, ts) == 0)
|
|
return (base);
|
|
break;
|
|
}
|
|
return (0);
|
|
}
|