From f4f238b09bc365e355ce404d02c7d7fd02662597 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 30 Jan 2018 13:05:25 -0800 Subject: [PATCH] Changes imported from Abseil "staging" branch: - c77facb7ba7c12d656e213e5d63d7dcd9d1f56ba Present the Writer* methods as an option, rather than an ... by Abseil Team - c6004d718f185868dee2ec48b4de6425399b062d Split exception_safety_testing out into its own cmake rul... by Jon Cohen - 9aa6fc7b34674472d808ed8021f3b20faea82f78 Downstream https://github.com/abseil/abseil-cpp/pull/69 by Jon Cohen - 13d340269f284b815cc409d2271099e535f4cba4 Internal change by Jon Cohen - 51840a9243ac9d47eb3c177398d10bb3341f3230 Fix assertion in conversion from floating point types to ... by Alex Strelnikov GitOrigin-RevId: c77facb7ba7c12d656e213e5d63d7dcd9d1f56ba Change-Id: I7590561b04a986ffbec7139bb9c3aea319a3b975 --- CMake/README.md | 6 ------ absl/base/CMakeLists.txt | 23 ++++++++++++++++++++++- absl/numeric/int128.cc | 14 +++++++++----- absl/synchronization/mutex.h | 4 ++-- absl/time/CMakeLists.txt | 1 - absl/types/CMakeLists.txt | 2 +- absl/utility/CMakeLists.txt | 3 --- 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/CMake/README.md b/CMake/README.md index 404d248e3..268fd65d8 100644 --- a/CMake/README.md +++ b/CMake/README.md @@ -1,4 +1,3 @@ - ## Abseil CMake build instructions @@ -79,8 +78,3 @@ As of this writing, that pull request requires -DBUILD_TESTING=OFF as it doesn't absl::synchronization absl::time absl::utility - - - - - diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt index 9d2de55fe..4b7b53a7b 100644 --- a/absl/base/CMakeLists.txt +++ b/absl/base/CMakeLists.txt @@ -62,7 +62,6 @@ list(APPEND BASE_INTERNAL_HEADERS # absl_base main library list(APPEND BASE_SRC "internal/cycleclock.cc" - "internal/exception_safety_testing.cc" "internal/raw_logging.cc" "internal/spinlock.cc" "internal/sysinfo.cc" @@ -117,6 +116,28 @@ absl_library( throw_delegate ) +if(BUILD_TESTING) + # exception-safety testing library + set(EXCEPTION_SAFETY_TESTING_SRC "internal/exception_safety_testing.cc") + set(EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES + ${ABSL_TEST_COMMON_LIBRARIES} + absl::base + absl::memory + absl::meta + absl::strings + absl::types + ) + +absl_library( + TARGET + absl_base_internal_exception_safety_testing + SOURCES + ${EXCEPTION_SAFETY_TESTING_SRC} + PUBLIC_LIBRARIES + ${EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES} +) +endif() + # dynamic_annotations library set(DYNAMIC_ANNOTATIONS_SRC "dynamic_annotations.cc") diff --git a/absl/numeric/int128.cc b/absl/numeric/int128.cc index de1b997ad..b32d8095f 100644 --- a/absl/numeric/int128.cc +++ b/absl/numeric/int128.cc @@ -104,11 +104,15 @@ void DivModImpl(uint128 dividend, uint128 divisor, uint128* quotient_ret, } template -uint128 Initialize128FromFloat(T v) { +uint128 MakeUint128FromFloat(T v) { + static_assert(std::is_floating_point::value, ""); + // Rounding behavior is towards zero, same as for built-in types. // Undefined behavior if v is NaN or cannot fit into uint128. - assert(!std::isnan(v) && v > -1 && v < std::ldexp(static_cast(1), 128)); + assert(std::isfinite(v) && v > -1 && + (std::numeric_limits::max_exponent <= 128 || + v < std::ldexp(static_cast(1), 128))); if (v >= std::ldexp(static_cast(1), 64)) { uint64_t hi = static_cast(std::ldexp(v, -64)); @@ -120,9 +124,9 @@ uint128 Initialize128FromFloat(T v) { } } // namespace -uint128::uint128(float v) : uint128(Initialize128FromFloat(v)) {} -uint128::uint128(double v) : uint128(Initialize128FromFloat(v)) {} -uint128::uint128(long double v) : uint128(Initialize128FromFloat(v)) {} +uint128::uint128(float v) : uint128(MakeUint128FromFloat(v)) {} +uint128::uint128(double v) : uint128(MakeUint128FromFloat(v)) {} +uint128::uint128(long double v) : uint128(MakeUint128FromFloat(v)) {} uint128& uint128::operator/=(uint128 other) { uint128 quotient = 0; diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h index 374cf57d2..9301222e0 100644 --- a/absl/synchronization/mutex.h +++ b/absl/synchronization/mutex.h @@ -233,8 +233,8 @@ class LOCKABLE Mutex { // // Aliases for `Mutex::Lock()`, `Mutex::Unlock()`, and `Mutex::TryLock()`. // - // Use the `Writer*()` versions of these method names when using complementary - // `Reader*()` methods to distingish simple exclusive `Mutex` usage (`Lock()`, + // These methods may be used (along with the complementary `Reader*()` + // methods) to distingish simple exclusive `Mutex` usage (`Lock()`, // etc.) from reader/writer lock usage. void WriterLock() EXCLUSIVE_LOCK_FUNCTION() { this->Lock(); } diff --git a/absl/time/CMakeLists.txt b/absl/time/CMakeLists.txt index 5c317fb01..a35617895 100644 --- a/absl/time/CMakeLists.txt +++ b/absl/time/CMakeLists.txt @@ -75,4 +75,3 @@ absl_test( ${TIME_TEST_PUBLIC_LIBRARIES} ) - diff --git a/absl/types/CMakeLists.txt b/absl/types/CMakeLists.txt index b2d95b48f..fd71f38b8 100644 --- a/absl/types/CMakeLists.txt +++ b/absl/types/CMakeLists.txt @@ -130,7 +130,7 @@ absl_test( # test any_exception_safety_test set(ANY_EXCEPTION_SAFETY_TEST_SRC "any_exception_safety_test.cc") -set(ANY_EXCEPTION_SAFETY_TEST_PUBLIC_LIBRARIES absl::any absl::base) +set(ANY_EXCEPTION_SAFETY_TEST_PUBLIC_LIBRARIES absl::any absl::base absl::base_internal_exception_safety_testing) absl_test( TARGET diff --git a/absl/utility/CMakeLists.txt b/absl/utility/CMakeLists.txt index fe8b32b9f..df21b85b3 100644 --- a/absl/utility/CMakeLists.txt +++ b/absl/utility/CMakeLists.txt @@ -43,6 +43,3 @@ absl_test( PUBLIC_LIBRARIES ${UTILITY_TEST_PUBLIC_LIBRARIES} ) - - -