Index: base/numerics/saturated_arithmetic.h |
diff --git a/base/numerics/saturated_arithmetic.h b/base/numerics/saturated_arithmetic.h |
index 7e24fe3617b127fe6641574271f55d3dbafd5f06..012832b014b1d47e61c2a5134307ee05fde13c82 100644 |
--- a/base/numerics/saturated_arithmetic.h |
+++ b/base/numerics/saturated_arithmetic.h |
@@ -56,6 +56,14 @@ ALWAYS_INLINE int32_t SaturatedNegative(int32_t a) { |
return -a; |
} |
+ALWAYS_INLINE int32_t SaturatedAbsolute(int32_t a) { |
+ if (a >= 0) |
+ return a; |
+ if (UNLIKELY(a == std::numeric_limits<int>::min())) |
+ return std::numeric_limits<int>::max(); |
+ return -a; |
+} |
+ |
ALWAYS_INLINE int GetMaxSaturatedSetResultForTesting(int fractional_shift) { |
// For C version the set function maxes out to max int, this differs from |
// the ARM asm version, see saturated_arithmetic_arm.h for the equivalent asm |