aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--command.c8
-rw-r--r--runloop.c7
-rw-r--r--util.c9
-rw-r--r--util.h6
4 files changed, 17 insertions, 13 deletions
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 <sys/select.h>
#include <sys/time.h>
#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 <sys/time.h>
+#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);