From b755078e3e68d93eaea265f638ef05340ff5633b Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 2 Mar 2009 10:30:00 -0800 Subject: [PATCH] New function time_timeval(). --- lib/timeval.c | 11 ++++++++++- lib/timeval.h | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/timeval.c b/lib/timeval.c index 25dedfea..327a8cde 100644 --- a/lib/timeval.c +++ b/lib/timeval.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -119,6 +119,15 @@ time_msec(void) return (long long int) now.tv_sec * 1000 + now.tv_usec / 1000; } +/* Stores the current time, accurate within TIME_UPDATE_INTERVAL ms, into + * '*tv'. */ +void +time_timeval(struct timeval *tv) +{ + refresh_if_ticked(); + *tv = now; +} + /* Configures the program to die with SIGALRM 'secs' seconds from now, if * 'secs' is nonzero, or disables the feature if 'secs' is zero. */ void diff --git a/lib/timeval.h b/lib/timeval.h index b31cac11..fadb1bec 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2008 The Board of Trustees of The Leland Stanford +/* Copyright (c) 2008, 2009 The Board of Trustees of The Leland Stanford * Junior University * * We are making the OpenFlow specification and associated documentation @@ -39,6 +39,7 @@ #include "util.h" struct pollfd; +struct timeval; /* POSIX allows floating-point time_t, but we don't support it. */ BUILD_ASSERT_DECL(TYPE_IS_INTEGER(time_t)); @@ -60,6 +61,7 @@ void time_init(void); void time_refresh(void); time_t time_now(void); long long int time_msec(void); +void time_timeval(struct timeval *); void time_alarm(unsigned int secs); int time_poll(struct pollfd *, int n_pollfds, int timeout); -- 2.30.2