| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ | 5 #ifndef BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ |
| 6 #define BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ | 6 #define BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ |
| 7 | 7 |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 : [output] "=r"(result) | 26 : [output] "=r"(result) |
| 27 : [first] "r"(a), [second] "r"(b)); | 27 : [first] "r"(a), [second] "r"(b)); |
| 28 | 28 |
| 29 return result; | 29 return result; |
| 30 } | 30 } |
| 31 | 31 |
| 32 inline int32_t SaturatedNegative(int32_t a) { | 32 inline int32_t SaturatedNegative(int32_t a) { |
| 33 return SaturatedSubtraction(0, a); | 33 return SaturatedSubtraction(0, a); |
| 34 } | 34 } |
| 35 | 35 |
| 36 inline int32_t SaturatedAbsolute(int32_t a) { |
| 37 if (a >= 0) |
| 38 return a; |
| 39 return SaturatedNegative(a); |
| 40 } |
| 41 |
| 36 inline int GetMaxSaturatedSetResultForTesting(int fractional_shift) { | 42 inline int GetMaxSaturatedSetResultForTesting(int fractional_shift) { |
| 37 // For ARM Asm version the set function maxes out to the biggest | 43 // For ARM Asm version the set function maxes out to the biggest |
| 38 // possible integer part with the fractional part zero'd out. | 44 // possible integer part with the fractional part zero'd out. |
| 39 // e.g. 0x7fffffc0. | 45 // e.g. 0x7fffffc0. |
| 40 return std::numeric_limits<int>::max() & ~((1 << fractional_shift) - 1); | 46 return std::numeric_limits<int>::max() & ~((1 << fractional_shift) - 1); |
| 41 } | 47 } |
| 42 | 48 |
| 43 inline int GetMinSaturatedSetResultForTesting(int fractional_shift) { | 49 inline int GetMinSaturatedSetResultForTesting(int fractional_shift) { |
| 44 return std::numeric_limits<int>::min(); | 50 return std::numeric_limits<int>::min(); |
| 45 } | 51 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 : [output] "=r"(result) | 99 : [output] "=r"(result) |
| 94 : [value] "r"(value), [saturate] "n"(Saturate), | 100 : [value] "r"(value), [saturate] "n"(Saturate), |
| 95 [shift] "n"(fractional_shift)); | 101 [shift] "n"(fractional_shift)); |
| 96 | 102 |
| 97 return result; | 103 return result; |
| 98 } | 104 } |
| 99 | 105 |
| 100 } // namespace base | 106 } // namespace base |
| 101 | 107 |
| 102 #endif // BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ | 108 #endif // BASE_NUMERICS_SATURATED_ARITHMETIC_ARM_H_ |
| OLD | NEW |