Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
DOC-ONLY: upgrade the "requests" package
[vpp.git]
/
src
/
vppinfra
/
time.h
diff --git
a/src/vppinfra/time.h
b/src/vppinfra/time.h
index
ced9677
..
64370d5
100644
(file)
--- 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)
{
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. */
/* 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);
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
return ts.tv_sec + 1e-9 * ts.tv_nsec;
}
return ts.tv_sec + 1e-9 * ts.tv_nsec;
}
@@
-249,7
+253,11
@@
always_inline u64
unix_time_now_nsec (void)
{
struct timespec ts;
unix_time_now_nsec (void)
{
struct timespec ts;
+#ifdef __MACH__
+ clock_gettime (CLOCK_REALTIME, &ts);
+#else
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
return 1e9 * ts.tv_sec + ts.tv_nsec;
}
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;
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);
syscall (SYS_clock_gettime, CLOCK_REALTIME, &ts);
+#endif
*sec = ts.tv_sec;
*nsec = ts.tv_nsec;
}
*sec = ts.tv_sec;
*nsec = ts.tv_nsec;
}