overflow-arith.h 277 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#pragma once

#include <linux/kernel.h>

#ifdef CC_HAVE_BUILTIN_OVERFLOW

#define overflow_usub __builtin_usub_overflow

#else

static inline bool overflow_usub(unsigned int a, unsigned int b,
				 unsigned int *res)
{
	*res = a - b;
	return *res > a ? true : false;
}

#endif