[algs] Use __builtin_mul_overflow
Compiles to smaller binary.
This commit is contained in:
parent
a10cfe3f32
commit
25adbb3825
|
@ -853,10 +853,14 @@ hb_in_ranges (T u, T lo1, T hi1, Ts... ds)
|
||||||
* Overflow checking.
|
* Overflow checking.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Consider __builtin_mul_overflow use here also */
|
|
||||||
static inline bool
|
static inline bool
|
||||||
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
|
hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
|
||||||
{
|
{
|
||||||
|
#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
|
||||||
|
unsigned result;
|
||||||
|
return __builtin_mul_overflow (count, size, &result);
|
||||||
|
#endif
|
||||||
|
|
||||||
return (size > 0) && (count >= ((unsigned int) -1) / size);
|
return (size > 0) && (count >= ((unsigned int) -1) / size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue