summaryrefslogtreecommitdiffstats
path: root/include/linux/overflow-arith.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/overflow-arith.h')
-rw-r--r--include/linux/overflow-arith.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/overflow-arith.h b/include/linux/overflow-arith.h
new file mode 100644
index 000000000000..e12ccf854a70
--- /dev/null
+++ b/include/linux/overflow-arith.h
@@ -0,0 +1,18 @@
1#pragma once
2
3#include <linux/kernel.h>
4
5#ifdef CC_HAVE_BUILTIN_OVERFLOW
6
7#define overflow_usub __builtin_usub_overflow
8
9#else
10
11static inline bool overflow_usub(unsigned int a, unsigned int b,
12 unsigned int *res)
13{
14 *res = a - b;
15 return *res > a ? true : false;
16}
17
18#endif