overflow-arith.h 277 B

123456789101112131415161718
  1. #pragma once
  2. #include <linux/kernel.h>
  3. #ifdef CC_HAVE_BUILTIN_OVERFLOW
  4. #define overflow_usub __builtin_usub_overflow
  5. #else
  6. static inline bool overflow_usub(unsigned int a, unsigned int b,
  7. unsigned int *res)
  8. {
  9. *res = a - b;
  10. return *res > a ? true : false;
  11. }
  12. #endif