[PATCH 4/8] OS utils: add os_reltime_expired()

Johannes Berg johannes
Mon Nov 25 12:56:05 PST 2013


From: Johannes Berg <johannes.berg at intel.com>

This helper functions checks whether a given entry has expired,
given the last active timestamp, the current time and a timeout.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/utils/os.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/utils/os.h b/src/utils/os.h
index 6689d44..f933292 100644
--- a/src/utils/os.h
+++ b/src/utils/os.h
@@ -96,6 +96,18 @@ static inline void os_reltime_age(struct os_reltime *start,
 }
 
 
+static inline int os_reltime_expired(struct os_reltime *now,
+				     struct os_reltime *ts,
+				     os_time_t timeout_secs)
+{
+	struct os_reltime age;
+
+	os_reltime_sub(now, ts, &age);
+	return (age.sec > timeout_secs) ||
+	       (age.sec == timeout_secs && age.usec > 0);
+}
+
+
 /**
  * os_mktime - Convert broken-down time into seconds since 1970-01-01
  * @year: Four digit year
-- 
1.8.4.rc3




More information about the Hostap mailing list