Skip to content

Commit

Permalink
jit: fix missing builtin with AppleClang
Browse files Browse the repository at this point in the history
  • Loading branch information
Jianchun Xu committed Sep 16, 2016
1 parent 134a736 commit 2b8acaf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Common/Common/Int32Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2b8acaf

Please sign in to comment.