summaryrefslogtreecommitdiff
path: root/include/lib/utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lib/utils.h')
-rw-r--r--include/lib/utils.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/include/lib/utils.h b/include/lib/utils.h
index 9cc5468b..0936cbb3 100644
--- a/include/lib/utils.h
+++ b/include/lib/utils.h
@@ -55,4 +55,11 @@
#define round_down(value, boundary) \
((value) & ~round_boundary(value, boundary))
+/*
+ * Evaluates to 1 if (ptr + inc) overflows, 0 otherwise.
+ * Both arguments must be unsigned pointer values (i.e. uintptr_t).
+ */
+#define check_uptr_overflow(ptr, inc) \
+ (((ptr) > UINTPTR_MAX - (inc)) ? 1 : 0)
+
#endif /* __UTILS_H__ */