aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/time_posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/support/time_posix.c')
-rw-r--r--src/core/support/time_posix.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c
index 841485c4b4..a274400243 100644
--- a/src/core/support/time_posix.c
+++ b/src/core/support/time_posix.c
@@ -32,6 +32,7 @@
*/
#include <grpc/support/port_platform.h>
+#include <src/core/support/time_precise.h>
#ifdef GPR_POSIX_TIME
@@ -66,8 +67,14 @@ void gpr_time_init(void) {}
gpr_timespec gpr_now(gpr_clock_type clock) {
struct timespec now;
GPR_ASSERT(clock != GPR_TIMESPAN);
- clock_gettime(clockid_for_gpr_clock[clock], &now);
- return gpr_from_timespec(now, clock);
+ if (clock == GPR_CLOCK_PRECISE) {
+ gpr_timespec ret;
+ gpr_precise_clock_now(&ret);
+ return ret;
+ } else {
+ clock_gettime(clockid_for_gpr_clock[clock], &now);
+ return gpr_from_timespec(now, clock);
+ }
}
#else
/* For some reason Apple's OSes haven't implemented clock_gettime. */
@@ -104,6 +111,9 @@ gpr_timespec gpr_now(gpr_clock_type clock) {
now.tv_sec = now_dbl * 1e-9;
now.tv_nsec = now_dbl - now.tv_sec * 1e9;
break;
+ case GPR_CLOCK_PRECISE:
+ gpr_precise_clock_now(&now);
+ break;
case GPR_TIMESPAN:
abort();
}