diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:14:27 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-04-08 13:15:01 +0200 |
| commit | cf534d762754860ed5b714974f99acd282d48b3b (patch) | |
| tree | bf22341cedfb50ee7bcd4e15f85add2329783f31 /src/time.c | |
| parent | 630fcb1846aed16b9ab62bcf700f668883f4521f (diff) | |
Restructure into src/{std,json}/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'src/time.c')
| -rw-r--r-- | src/time.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/time.c b/src/time.c deleted file mode 100644 index cbabf96..0000000 --- a/src/time.c +++ /dev/null @@ -1,48 +0,0 @@ -#include <time.h> - -#include "../include/assert.h" -#include "../include/time.h" -#include "../include/types.h" - -Time Time_get() { - struct timespec system_time; - assert(clock_gettime(CLOCK_MONOTONIC, &system_time) == 0, "clock_gettime failed"); - return (Time){system_time.tv_sec, system_time.tv_nsec}; -} - -f32 Time_ms(Time time) { - return time.s * 1e3 + time.ns / 1e6; -} - -Duration Time_diff(Time end, Time start) { - Duration d; - d.s = end.s - start.s; - d.ns = end.ns - start.ns; - if (d.ns >= (u64)1e9) { - d.s += d.ns / (u64)1e9; - d.ns = d.ns % (u64)1e9; - } - return d; -} - -f32 Duration_ms(Duration d) { - return d.s * 1e3 + d.ns / 1e6; -} - -Duration Duration_from_ms(f32 ms) { - Duration d; - d.s = (u64)(ms / 1e3); - d.ns = (u64)((ms - d.s * 1e3) * 1e6); - return d; -} - -Duration Duration_diff(Duration a, Duration b) { - Duration d; - d.s = a.s - b.s; - d.ns = a.ns - b.ns; - if (d.ns >= (u64)1e9) { - d.s += d.ns / (u64)1e9; - d.ns = d.ns % (u64)1e9; - } - return d; -} |
