From 886fc77026a2a805e5d166b2f87bd24720ad9ea4 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 8 May 2017 22:05:51 +0200 Subject: server: Factor out make_timestamp() into util.c --- command.c | 8 +------- runloop.c | 7 +------ util.c | 9 +++++++++ util.h | 6 ++++++ 4 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 util.c create mode 100644 util.h diff --git a/command.c b/command.c index 2695c93..b0b9a26 100644 --- a/command.c +++ b/command.c @@ -9,13 +9,7 @@ #include "db.h" #include "net.h" #include "user_data.h" - - -static i64 make_timestamp(void){ - struct timeval tv; - gettimeofday(&tv,NULL); - return (i64)tv.tv_sec*1000000+tv.tv_usec; -} +#include "util.h" static bool cmd_register(struct conn_data *data,const char *tag,const char **args){ diff --git a/runloop.c b/runloop.c index 119bf01..f95975c 100644 --- a/runloop.c +++ b/runloop.c @@ -3,6 +3,7 @@ #include #include #include "runloop.h" +#include "util.h" struct fd_list_item{ @@ -25,12 +26,6 @@ static void constructor(void){ } -static i64 make_timestamp(void){ - struct timeval tv; - gettimeofday(&tv,NULL); - return (i64)tv.tv_sec*1000000+tv.tv_usec; -} - void runloop_set_timeout(i64 usecs,runloop_callback *cb){ timeout_usecs=usecs; timeout_callback=cb; diff --git a/util.c b/util.c new file mode 100644 index 0000000..6887ce9 --- /dev/null +++ b/util.c @@ -0,0 +1,9 @@ +#include +#include "util.h" + + +i64 make_timestamp(void){ + struct timeval tv; + gettimeofday(&tv,NULL); + return (i64)tv.tv_sec*1000000+tv.tv_usec; +} diff --git a/util.h b/util.h new file mode 100644 index 0000000..e161efe --- /dev/null +++ b/util.h @@ -0,0 +1,6 @@ +#pragma once + +#include "global.h" + + +i64 make_timestamp(void); -- cgit v1.2.3-70-g09d2