summaryrefslogtreecommitdiff
path: root/user/lib/bound.c
diff options
context:
space:
mode:
Diffstat (limited to 'user/lib/bound.c')
-rw-r--r--user/lib/bound.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/user/lib/bound.c b/user/lib/bound.c
new file mode 100644
index 0000000..072a41a
--- /dev/null
+++ b/user/lib/bound.c
@@ -0,0 +1,12 @@
+#include <stdlib.h>
+
+unsigned int bound(unsigned int min, unsigned int value, unsigned int max)
+{
+ if (value < min) {
+ value = min;
+ }
+ if (value > max) {
+ value = max;
+ }
+ return value;
+}