summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDanny Holman <dholman@gymli.org>2024-08-24 01:48:09 -0500
committerDanny Holman <dholman@gymli.org>2024-08-24 01:48:09 -0500
commita002576056e26673f0141e46786f44f0b9c90b70 (patch)
treea1b814a07a61a21c550b2f3a0765a5eabfae064f /include
parent76d7d478a9e5ad10b76e246367779216fbd0fb60 (diff)
core: add a header for utility functions
Add a header for dumping utility functions that are commonly used across several files. This header should only contain small, inline-able functions of no more than 5-10 lines of code. Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to 'include')
-rw-r--r--include/rune_util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/rune_util.h b/include/rune_util.h
new file mode 100644
index 0000000..f0613c9
--- /dev/null
+++ b/include/rune_util.h
@@ -0,0 +1,11 @@
+#ifndef RUNE_UTIL_H
+#define RUNE_UTIL_H
+
+#include <stdint.h>
+
+static inline uint32_t clamp(uint32_t value, float min, float max) {
+ const uint32_t ret = value < min ? min : value;
+ return ret > max ? max : ret;
+}
+
+#endif