summaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
new file mode 100644
index 0000000..71484e5
--- /dev/null
+++ b/src/common.c
@@ -0,0 +1,21 @@
+#include "common.h"
+#include <time.h>
+
+char *va(const char *fmt, ...)
+{
+ va_list vl;
+ static char buffer[4096];
+
+ va_start(vl, fmt);
+ vsnprintf(buffer, sizeof(buffer), fmt, vl);
+ va_end(vl);
+
+ return buffer;
+}
+
+int64_t get_time(void)
+{
+ struct timespec ts;
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ return ts.tv_sec * 1000000000 + ts.tv_nsec;
+}