diff --git a/lib/Common/Common/Int32Math.cpp b/lib/Common/Common/Int32Math.cpp index 8f5a25e5ac0..b85dafd7287 100644 --- a/lib/Common/Common/Int32Math.cpp +++ b/lib/Common/Common/Int32Math.cpp @@ -180,6 +180,9 @@ Int32Math::Inc(int32 val, int32 *pResult) *pResult = val + 1; // Overflow if result ends up less than input return *pResult <= val; +#elif defined(__APPLE__) + *pResult = val + 1; + return val == INT32_MAX; // Overflow if val was int max #else return __builtin_add_overflow(val, 1, pResult); #endif @@ -192,6 +195,9 @@ Int32Math::Dec(int32 val, int32 *pResult) *pResult = val - 1; // Overflow if result ends up greater than input return *pResult >= val; +#elif defined(__APPLE__) + *pResult = val - 1; + return val == INT32_MIN; // Overflow if val was int min #else return __builtin_sub_overflow(val, 1, pResult); #endif