summaryrefslogtreecommitdiffstats
path: root/src/fastd.h
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2014-01-26 04:48:35 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2014-01-26 04:48:35 +0100
commit9fe7f35ce87dceb368c7ddffd7f6902dca24b97a (patch)
tree0cd7abeae5bdd54764d2a80848a6f1b09ad51112 /src/fastd.h
parent53d331406d6b1cbe934528f87023b87887993e0e (diff)
downloadfastd-9fe7f35ce87dceb368c7ddffd7f6902dca24b97a.tar
fastd-9fe7f35ce87dceb368c7ddffd7f6902dca24b97a.zip
Add timeout helpers
Diffstat (limited to 'src/fastd.h')
-rw-r--r--src/fastd.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/fastd.h b/src/fastd.h
index f713841..42878e2 100644
--- a/src/fastd.h
+++ b/src/fastd.h
@@ -409,6 +409,16 @@ static inline int timespec_diff(const struct timespec *tp1, const struct timespe
return ((tp1->tv_sec - tp2->tv_sec))*1000 + (tp1->tv_nsec - tp2->tv_nsec)/1e6;
}
+static inline bool fastd_timed_out(const fastd_context_t *ctx, const struct timespec *timeout) {
+ return !timespec_after(timeout, &ctx->now);
+}
+
+static inline struct timespec fastd_in_seconds(const fastd_context_t *ctx, int seconds) {
+ struct timespec ret = ctx->now;
+ ret.tv_sec += seconds;
+ return ret;
+}
+
static inline bool strequal(const char *str1, const char *str2) {
if (str1 && str2)
return (!strcmp(str1, str2));