Commit 22717ce2 by Lei Zhang Committed by Commit Bot

Wrap safe numerics library in namespace angle.

When ANGLE is used with Chromium, having two copies of safe numerics code in namespace base causes ODR violations. BUG=449754 Change-Id: I686049e7d8926373d00dd17ec8142fa3c508b9c5 Reviewed-on: https://chromium-review.googlesource.com/513434Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 04a56818
...@@ -10,7 +10,12 @@ License: Chromium ...@@ -10,7 +10,12 @@ License: Chromium
License File: LICENSE in Chromium/src License File: LICENSE in Chromium/src
Description: Description:
base::numerics is a library for doing some simple safe math and conversions. To update the checkout, simply base::numerics is a library for doing some simple safe math and conversions.
overwrite the base/numerics folder with Chromium's latest. The only modifications are to the base/logging.h To update the checkout, simply overwrite the base/numerics folder with
file which defines CHECK to be ASSERT to be compatible with ANGLE. Chromium's latest.
Modifications:
- base/logging.h defines CHECK to be ASSERT to be compatible with ANGLE.
- base/numerics/*.h uses namespace angle::base instead of base:: to avoid ODR
violations when ANGLE code is mixed with Chromium code.
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/numerics/safe_conversions_impl.h" #include "base/numerics/safe_conversions_impl.h"
namespace angle
{
namespace base namespace base
{ {
...@@ -171,4 +174,6 @@ typedef StrictNumeric<size_t> SizeT; ...@@ -171,4 +174,6 @@ typedef StrictNumeric<size_t> SizeT;
} // namespace base } // namespace base
} // namespace angle
#endif // BASE_NUMERICS_SAFE_CONVERSIONS_H_ #endif // BASE_NUMERICS_SAFE_CONVERSIONS_H_
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
#include <climits> #include <climits>
#include <limits> #include <limits>
namespace angle
{
namespace base namespace base
{ {
namespace internal namespace internal
...@@ -266,4 +269,6 @@ constexpr RangeConstraint DstRangeRelationToSrcRange(Src value) ...@@ -266,4 +269,6 @@ constexpr RangeConstraint DstRangeRelationToSrcRange(Src value)
} // namespace internal } // namespace internal
} // namespace base } // namespace base
} // namespace angle
#endif // BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_ #endif // BASE_NUMERICS_SAFE_CONVERSIONS_IMPL_H_
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/numerics/safe_math_impl.h" #include "base/numerics/safe_math_impl.h"
namespace angle
{
namespace base namespace base
{ {
...@@ -321,4 +324,6 @@ using internal::CheckedNumeric; ...@@ -321,4 +324,6 @@ using internal::CheckedNumeric;
} // namespace base } // namespace base
} // namespace angle
#endif // BASE_NUMERICS_SAFE_MATH_H_ #endif // BASE_NUMERICS_SAFE_MATH_H_
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
#include "base/numerics/safe_conversions.h" #include "base/numerics/safe_conversions.h"
namespace angle
{
namespace base namespace base
{ {
namespace internal namespace internal
...@@ -567,4 +570,6 @@ struct IsIntegerArithmeticSafe ...@@ -567,4 +570,6 @@ struct IsIntegerArithmeticSafe
} // namespace internal } // namespace internal
} // namespace base } // namespace base
} // namespace angle
#endif // BASE_NUMERICS_SAFE_MATH_IMPL_H_ #endif // BASE_NUMERICS_SAFE_MATH_IMPL_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment