nightmaremail

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

oflops_compat.h (532B)


      1 #ifndef OFLOPS_H
      2 #define OFLOPS_H
      3 
      4 static inline int check_ofl(unsigned long long val, unsigned int *res)
      5 {
      6 	if (val >> 32)
      7 		return 1;
      8 	*res = (unsigned int)val;
      9 	return 0;
     10 }
     11 
     12 static inline int __builtin_add_overflow(unsigned int a, unsigned int b, unsigned int *res)
     13 {
     14 	unsigned long long val = a;
     15 	val += b;
     16 	return check_ofl(val, res);
     17 }
     18 
     19 static inline int __builtin_mul_overflow(unsigned int a, unsigned int b, unsigned int *res)
     20 {
     21 	unsigned long long val = a;
     22 	val *= b;
     23 	return check_ofl(val, res);
     24 }
     25 
     26 #endif /* OFLOPS_H */
     27