summaryrefslogtreecommitdiff
path: root/src/ticker.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ticker.h')
-rw-r--r--src/ticker.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/ticker.h b/src/ticker.h
new file mode 100644
index 0000000..f6387c4
--- /dev/null
+++ b/src/ticker.h
@@ -0,0 +1,23 @@
+// SPDX-FileCopyrightText: 2024 Lizzy Fleckenstein <lizzy@vlhl.dev>
+//
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+#ifndef TICKER_H
+#define TICKER_H
+
+#include <time.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+#define NANOS 1000000000
+
+typedef struct {
+ struct timespec timestamp;
+ uint64_t freq_nanos;
+} ticker;
+
+void ticker_init(ticker *t, uint64_t f);
+bool ticker_tick(ticker *t, uint64_t *dtime);
+int ticker_timeout(ticker *t);
+
+#endif