mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 09:22:03 +00:00
lib: monotime.h tabs -> spaces
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
This commit is contained in:
parent
821cf0d9f6
commit
0ee70925de
@ -23,28 +23,28 @@
|
|||||||
|
|
||||||
#ifndef TIMESPEC_TO_TIMEVAL
|
#ifndef TIMESPEC_TO_TIMEVAL
|
||||||
/* should be in sys/time.h on BSD & Linux libcs */
|
/* should be in sys/time.h on BSD & Linux libcs */
|
||||||
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
|
#define TIMESPEC_TO_TIMEVAL(tv, ts) do { \
|
||||||
(tv)->tv_sec = (ts)->tv_sec; \
|
(tv)->tv_sec = (ts)->tv_sec; \
|
||||||
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
|
(tv)->tv_usec = (ts)->tv_nsec / 1000; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
#ifndef TIMEVAL_TO_TIMESPEC
|
#ifndef TIMEVAL_TO_TIMESPEC
|
||||||
/* should be in sys/time.h on BSD & Linux libcs */
|
/* should be in sys/time.h on BSD & Linux libcs */
|
||||||
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
|
#define TIMEVAL_TO_TIMESPEC(tv, ts) do { \
|
||||||
(ts)->tv_sec = (tv)->tv_sec; \
|
(ts)->tv_sec = (tv)->tv_sec; \
|
||||||
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
(ts)->tv_nsec = (tv)->tv_usec * 1000; \
|
||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline time_t monotime(struct timeval *tvo)
|
static inline time_t monotime(struct timeval *tvo)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
if (tvo) {
|
if (tvo) {
|
||||||
TIMESPEC_TO_TIMEVAL(tvo, &ts);
|
TIMESPEC_TO_TIMEVAL(tvo, &ts);
|
||||||
}
|
}
|
||||||
return ts.tv_sec;
|
return ts.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the following two return microseconds, not time_t!
|
/* the following two return microseconds, not time_t!
|
||||||
@ -53,25 +53,25 @@ static inline time_t monotime(struct timeval *tvo)
|
|||||||
* code more readable
|
* code more readable
|
||||||
*/
|
*/
|
||||||
static inline int64_t monotime_since(const struct timeval *ref,
|
static inline int64_t monotime_since(const struct timeval *ref,
|
||||||
struct timeval *out)
|
struct timeval *out)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
monotime(&tv);
|
monotime(&tv);
|
||||||
timersub(&tv, ref, &tv);
|
timersub(&tv, ref, &tv);
|
||||||
if (out)
|
if (out)
|
||||||
*out = tv;
|
*out = tv;
|
||||||
return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec;
|
return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int64_t monotime_until(const struct timeval *ref,
|
static inline int64_t monotime_until(const struct timeval *ref,
|
||||||
struct timeval *out)
|
struct timeval *out)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
monotime(&tv);
|
monotime(&tv);
|
||||||
timersub(ref, &tv, &tv);
|
timersub(ref, &tv, &tv);
|
||||||
if (out)
|
if (out)
|
||||||
*out = tv;
|
*out = tv;
|
||||||
return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec;
|
return (int64_t)tv.tv_sec * 1000000LL + tv.tv_usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _FRR_MONOTIME_H */
|
#endif /* _FRR_MONOTIME_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user