Title: [184369] trunk/Source/WTF
Revision
184369
Author
[email protected]
Date
2015-05-14 21:36:27 -0700 (Thu, 14 May 2015)

Log Message

Reverted r177753, now that <rdar://problem/19347133> is fixed.

Rubber-stamped by Benjamin Poulain.

* wtf/SaturatedArithmetic.h:
(signedAddOverflows):
(signedSubtractOverflows):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (184368 => 184369)


--- trunk/Source/WTF/ChangeLog	2015-05-15 04:14:39 UTC (rev 184368)
+++ trunk/Source/WTF/ChangeLog	2015-05-15 04:36:27 UTC (rev 184369)
@@ -1,3 +1,13 @@
+2015-05-14  Dan Bernstein  <[email protected]>
+
+        Reverted r177753, now that <rdar://problem/19347133> is fixed.
+
+        Rubber-stamped by Benjamin Poulain.
+
+        * wtf/SaturatedArithmetic.h:
+        (signedAddOverflows):
+        (signedSubtractOverflows):
+
 2015-05-14  Myles C. Maxfield  <[email protected]>
 
         Add String literal overloads to equalIgnoringASCIICase()

Modified: trunk/Source/WTF/wtf/SaturatedArithmetic.h (184368 => 184369)


--- trunk/Source/WTF/wtf/SaturatedArithmetic.h	2015-05-15 04:14:39 UTC (rev 184368)
+++ trunk/Source/WTF/wtf/SaturatedArithmetic.h	2015-05-15 04:36:27 UTC (rev 184369)
@@ -39,6 +39,9 @@
 
 inline bool signedAddOverflows(int32_t a, int32_t b, int32_t& result)
 {
+#if COMPILER_HAS_CLANG_BUILTIN(__builtin_sadd_overflow)
+    return __builtin_sadd_overflow(a, b, &result);
+#else
     uint32_t ua = a;
     uint32_t ub = b;
     uint32_t uresult = ua + ub;
@@ -47,6 +50,7 @@
     // Can only overflow if the signed bit of the two values match. If the signed
     // bit of the result and one of the values differ it did overflow.
     return !((ua ^ ub) >> 31) && (uresult ^ ua) >> 31;
+#endif
 }
 
 inline int32_t saturatedAddition(int32_t a, int32_t b)
@@ -67,6 +71,9 @@
 
 inline bool signedSubtractOverflows(int32_t a, int32_t b, int32_t& result)
 {
+#if COMPILER_HAS_CLANG_BUILTIN(__builtin_ssub_overflow)
+    return __builtin_ssub_overflow(a, b, &result);
+#else
     uint32_t ua = a;
     uint32_t ub = b;
     uint32_t uresult = ua - ub;
@@ -75,6 +82,7 @@
     // Can only overflow if the signed bit of the two values do not match. If the
     // signed bit of the result and the first value differ it did overflow.
     return (ua ^ ub) >> 31 && (uresult ^ ua) >> 31;
+#endif
 }
 
 inline int32_t saturatedSubtraction(int32_t a, int32_t b)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to