aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra/time.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2018-09-03 12:30:36 +0200
committerDamjan Marion <dmarion@me.com>2018-09-03 16:51:40 +0000
commit4dffd1c9988020619caff9b8d3b350e7f79e0398 (patch)
tree58d6b48f3925e815b68dfe04d3946c80ad1c24a1 /src/vppinfra/time.h
parentea5b5be4eeb0f4cd80cb466bd6e31cad33c57960 (diff)
Compile vppinfra on macOS
Add missing calls to clib_mem_init to vppinfra test codes. Change-Id: I53ffc6fc287d1a378065bb86c18b6e995ecdb775 Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vppinfra/time.h')
-rw-r--r--src/vppinfra/time.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/vppinfra/time.h b/src/vppinfra/time.h
index ced9677d1e2..64370d523bb 100644
--- a/src/vppinfra/time.h
+++ b/src/vppinfra/time.h
@@ -237,10 +237,14 @@ void clib_time_init (clib_time_t * c);
always_inline f64
unix_time_now (void)
{
+ struct timespec ts;
+#ifdef __MACH__
+ clock_gettime (CLOCK_REALTIME, &ts);
+#else
/* clock_gettime without indirect syscall uses GLIBC wrappers which
we don't want. Just the bare metal, please. */
- struct timespec ts;
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
return ts.tv_sec + 1e-9 * ts.tv_nsec;
}
@@ -249,7 +253,11 @@ always_inline u64
unix_time_now_nsec (void)
{
struct timespec ts;
+#ifdef __MACH__
+ clock_gettime (CLOCK_REALTIME, &ts);
+#else
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
return 1e9 * ts.tv_sec + ts.tv_nsec;
}
@@ -257,7 +265,11 @@ always_inline void
unix_time_now_nsec_fraction (u32 * sec, u32 * nsec)
{
struct timespec ts;
+#ifdef __MACH__
+ clock_gettime (CLOCK_REALTIME, &ts);
+#else
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
*sec = ts.tv_sec;
*nsec = ts.tv_nsec;
}