Chromium Code Reviews| Index: src/IceDefs.h |
| diff --git a/src/IceDefs.h b/src/IceDefs.h |
| index 7ea34be88f1f40415bdd02346193629adfd3b3a0..353f22f1d4c26419e8fe45729d1e045c16860756 100644 |
| --- a/src/IceDefs.h |
| +++ b/src/IceDefs.h |
| @@ -225,6 +225,7 @@ enum VerboseItem { |
| IceV_Random = 1 << 10, |
| IceV_Folding = 1 << 11, |
| IceV_RMW = 1 << 12, |
| + IceV_Loop = 1 << 13, |
| IceV_All = ~IceV_None, |
| IceV_Most = IceV_All & ~IceV_LinearScan |
| }; |
| @@ -291,6 +292,17 @@ enum RandomizationPassesEnum { |
| RPE_num |
| }; |
| +inline bool add_overflow(uint32_t x, uint32_t y, uint32_t *sum) { |
|
Jim Stichnoth
2015/09/03 21:35:09
Maybe this should go in IceUtils.h? Also, documen
ascull
2015/09/03 22:47:12
Done.
|
| + static_assert(std::is_same<uint32_t, unsigned>::value, "Need to match type"); |
| +#if __has_builtin(__builtin_uadd_overflow) |
| + return __builtin_uadd_overflow(x, y, sum); |
| +#else |
| + uint64_t res = static_cast<uint64_t>(x) + y; |
| + *sum = static_cast<uint32_t>(res); |
| + return res > std::numeric_limits<uint32_t>; |
| +#endif |
| +} |
| + |
| } // end of namespace Ice |
| #endif // SUBZERO_SRC_ICEDEFS_H |