From d68e278083fd68fd4dfa70d21f2401d6fe992e37 Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 29 Dec 2021 19:49:16 +0200 Subject: [PATCH] move nsTime to its own file --- src/builtins/md1.c | 1 + src/builtins/sysfn.c | 1 + src/h.h | 8 -------- src/main.c | 1 + src/opt/gc.c | 5 +++++ src/rtwrap.c | 1 + src/utils/hash.c | 1 + src/utils/time.h | 9 +++++++++ 8 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 src/utils/time.h diff --git a/src/builtins/md1.c b/src/builtins/md1.c index b4f74d56..4f47ba59 100644 --- a/src/builtins/md1.c +++ b/src/builtins/md1.c @@ -1,6 +1,7 @@ #include "../core.h" #include "../utils/each.h" #include "../utils/file.h" +#include "../utils/time.h" #include "../builtins.h" diff --git a/src/builtins/sysfn.c b/src/builtins/sysfn.c index fd16575a..8e4a84ef 100644 --- a/src/builtins/sysfn.c +++ b/src/builtins/sysfn.c @@ -8,6 +8,7 @@ #include "../utils/file.h" #include "../utils/wyhash.h" #include "../utils/mut.h" +#include "../utils/time.h" #include "../builtins.h" #include "../ns.h" #include "../nfns.h" diff --git a/src/h.h b/src/h.h index 6a760ae5..66799d5b 100644 --- a/src/h.h +++ b/src/h.h @@ -611,11 +611,3 @@ static B m_fork(B f, B g, B h); static B m_atop( B g, B h); - -#include -static inline u64 nsTime() { - struct timespec t; - // timespec_get(&t, TIME_UTC); // doesn't seem to exist on Android - clock_gettime(CLOCK_REALTIME, &t); - return (u64)(t.tv_sec*1000000000ll + t.tv_nsec); -} diff --git a/src/main.c b/src/main.c index 6bb30e91..e673f048 100644 --- a/src/main.c +++ b/src/main.c @@ -3,6 +3,7 @@ #include "ns.h" #include "utils/utf.h" #include "utils/file.h" +#include "utils/time.h" static B replPath; static Scope* gsc; diff --git a/src/opt/gc.c b/src/opt/gc.c index b073f3f9..d3b1521b 100644 --- a/src/opt/gc.c +++ b/src/opt/gc.c @@ -1,4 +1,9 @@ #include "gc.h" + +#ifdef LOG_GC +#include "../utils/time.h" +#endif + u64 gc_depth = 1; diff --git a/src/rtwrap.c b/src/rtwrap.c index b99c78ff..4e0a397d 100644 --- a/src/rtwrap.c +++ b/src/rtwrap.c @@ -3,6 +3,7 @@ #ifdef RT_PERF #include "builtins.h" #endif +#include "utils/time.h" #ifdef RT_WRAP typedef struct WFun WFun; diff --git a/src/utils/hash.c b/src/utils/hash.c index 6ec090b5..09030910 100644 --- a/src/utils/hash.c +++ b/src/utils/hash.c @@ -1,5 +1,6 @@ #include "../core.h" #include "hash.h" +#include "time.h" u64 wy_secret[4]; diff --git a/src/utils/time.h b/src/utils/time.h new file mode 100644 index 00000000..9b613d04 --- /dev/null +++ b/src/utils/time.h @@ -0,0 +1,9 @@ +#pragma once + +#include +static inline u64 nsTime() { + struct timespec t; + // timespec_get(&t, TIME_UTC); // doesn't seem to exist on Android + clock_gettime(CLOCK_REALTIME, &t); + return (u64)(t.tv_sec*1000000000ll + t.tv_nsec); +}