|
@@ -25,6 +25,17 @@
|
|
|
#ifndef __I915_UTILS_H
|
|
|
#define __I915_UTILS_H
|
|
|
|
|
|
+#if GCC_VERSION >= 70000
|
|
|
+#define add_overflows(A, B) \
|
|
|
+ __builtin_add_overflow_p((A), (B), (typeof((A) + (B)))0)
|
|
|
+#else
|
|
|
+#define add_overflows(A, B) ({ \
|
|
|
+ typeof(A) a = (A); \
|
|
|
+ typeof(B) b = (B); \
|
|
|
+ a + b < a; \
|
|
|
+})
|
|
|
+#endif
|
|
|
+
|
|
|
#define range_overflows(start, size, max) ({ \
|
|
|
typeof(start) start__ = (start); \
|
|
|
typeof(size) size__ = (size); \
|