Add an appropriate fallback to hb_int_mul_overflows
This commit is contained in:
parent
32f431406e
commit
9ffa50fe5d
|
@ -645,16 +645,17 @@ hb_unsigned_mul_overflows (unsigned int count, unsigned int size)
|
||||||
return (size > 0) && (count >= ((unsigned int) -1) / size);
|
return (size > 0) && (count >= ((unsigned int) -1) / size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Right now we only have one use for signed overflow and as it
|
static inline bool
|
||||||
* is GCC 5.1 > and clang we don't care about its fallback ATM */
|
hb_int_mul_overflows (int x, int y, int &result)
|
||||||
#ifndef __has_builtin
|
{
|
||||||
# define __has_builtin(x) 0
|
|
||||||
#endif
|
|
||||||
#if __has_builtin(__builtin_mul_overflow)
|
#if __has_builtin(__builtin_mul_overflow)
|
||||||
# define hb_signed_mul_overflows(x, y, result) __builtin_mul_overflow(x, y, &result)
|
return __builtin_mul_overflow (x, y, &result);
|
||||||
#else
|
#else
|
||||||
# define hb_signed_mul_overflows(x, y, result) (result = (x) * (y), false)
|
int64_t sink = (int64_t) x * y;
|
||||||
|
result = sink;
|
||||||
|
return result != sink;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -90,9 +90,9 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
|
||||||
return arrayZ[i-1].toCoord;
|
return arrayZ[i-1].toCoord;
|
||||||
|
|
||||||
int factor;
|
int factor;
|
||||||
if (hb_signed_mul_overflows (arrayZ[i].toCoord - arrayZ[i-1].toCoord,
|
if (unlikely (hb_int_mul_overflows (arrayZ[i].toCoord - arrayZ[i-1].toCoord,
|
||||||
value - arrayZ[i-1].fromCoord,
|
value - arrayZ[i-1].fromCoord,
|
||||||
factor))
|
factor)))
|
||||||
return arrayZ[i-1].toCoord;
|
return arrayZ[i-1].toCoord;
|
||||||
|
|
||||||
int denom = arrayZ[i].fromCoord - arrayZ[i-1].fromCoord;
|
int denom = arrayZ[i].fromCoord - arrayZ[i-1].fromCoord;
|
||||||
|
|
|
@ -219,6 +219,10 @@ extern "C" void hb_free_impl(void *ptr);
|
||||||
* Compiler attributes
|
* Compiler attributes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __has_builtin
|
||||||
|
# define __has_builtin(x) 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)
|
#if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)
|
||||||
#define likely(expr) (__builtin_expect (!!(expr), 1))
|
#define likely(expr) (__builtin_expect (!!(expr), 1))
|
||||||
#define unlikely(expr) (__builtin_expect (!!(expr), 0))
|
#define unlikely(expr) (__builtin_expect (!!(expr), 0))
|
||||||
|
|
Loading…
Reference in New Issue