diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index 5f88635998c950a6d423ca2b176f5d21ac0f47d2..23439a0904188d371cb5ca3be1cdffbdfdd7a328 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel @@ -286,6 +286,7 @@ cc_test( copts = ABSL_TEST_COPTS, deps = [ ":config", + "//absl/synchronization:thread_pool", "@com_google_googletest//:gtest_main", ], ) diff --git a/absl/base/casts.h b/absl/base/casts.h index 2a0adc29504bd57d9db8e35b75010fd5d5e62958..266c4a0a9356ba90e736163e2e808ddd78f86590 100644 --- a/absl/base/casts.h +++ b/absl/base/casts.h @@ -50,7 +50,7 @@ namespace absl { // // An `implicit_cast()` may also be used to annotate numeric type conversions // that, although safe, may produce compiler warnings (such as `long` to `int`). -// Additionally, an `implict_cast()` is also useful within return statements to +// Additionally, an `implicit_cast()` is also useful within return statements to // indicate a specific implicit conversion is being undertaken. // // Example: diff --git a/absl/base/config.h b/absl/base/config.h index cf47f84c33568517a7e0ffc2b4313b98509b748e..c768e7223b93f1a334d001f456458e2a807dbfab 100644 --- a/absl/base/config.h +++ b/absl/base/config.h @@ -56,6 +56,13 @@ #include <cstddef> #endif // __cplusplus +#if defined(__APPLE__) +// Included for TARGET_OS_IPHONE, __IPHONE_OS_VERSION_MIN_REQUIRED, +// __IPHONE_8_0. +#include <Availability.h> +#include <TargetConditionals.h> +#endif + #include "absl/base/policy_checks.h" // ----------------------------------------------------------------------------- @@ -151,12 +158,13 @@ // // Checks whether C++11's `thread_local` storage duration specifier is // supported. -// -// Notes: Clang implements the `thread_local` keyword but Xcode did not support -// the implementation until Xcode 8. #ifdef ABSL_HAVE_THREAD_LOCAL #error ABSL_HAVE_THREAD_LOCAL cannot be directly set -#elif !defined(__apple_build_version__) || __apple_build_version__ >= 8000042 +#elif !defined(__apple_build_version__) || \ + ((__apple_build_version__ >= 8000042) && \ + !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0)) +// Notes: Xcode's clang did not support `thread_local` until version +// 8, and even then not for iOS < 8.0. #define ABSL_HAVE_THREAD_LOCAL 1 #endif diff --git a/absl/base/config_test.cc b/absl/base/config_test.cc index ab04b447406b4342ca673e90f28cc2251a46625d..c839712a537e4169ca0165ff9f9d30b17e821e28 100644 --- a/absl/base/config_test.cc +++ b/absl/base/config_test.cc @@ -17,12 +17,12 @@ #include <cstdint> #include "gtest/gtest.h" +#include "absl/synchronization/internal/thread_pool.h" namespace { TEST(ConfigTest, Endianness) { - union - { + union { uint32_t value; uint8_t data[sizeof(uint32_t)]; } number; @@ -41,4 +41,20 @@ TEST(ConfigTest, Endianness) { #endif } +#if defined(ABSL_HAVE_THREAD_LOCAL) +TEST(ConfigTest, ThreadLocal) { + static thread_local int mine_mine_mine = 16; + EXPECT_EQ(16, mine_mine_mine); + { + absl::synchronization_internal::ThreadPool pool(1); + pool.Schedule([&] { + EXPECT_EQ(16, mine_mine_mine); + mine_mine_mine = 32; + EXPECT_EQ(32, mine_mine_mine); + }); + } + EXPECT_EQ(16, mine_mine_mine); +} +#endif + } // namespace diff --git a/absl/base/optimization.h b/absl/base/optimization.h index db8beafa3f2efd364f737891cc4b9ef0a2837c50..aaaffa495a9a6ee2898525af33d18dce9e84d25a 100644 --- a/absl/base/optimization.h +++ b/absl/base/optimization.h @@ -46,6 +46,7 @@ // GCC will not tail call given inline volatile assembly. #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __asm__ __volatile__("") #elif defined(_MSC_VER) +#include <intrin.h> // The __nop() intrinsic blocks the optimisation. #define ABSL_BLOCK_TAIL_CALL_OPTIMIZATION() __nop() #else diff --git a/absl/container/fixed_array.h b/absl/container/fixed_array.h index 20bde27285b815b3bb34237b9ccbb233e843537c..58240b499a56138ef431b6381e19351e14fbf866 100644 --- a/absl/container/fixed_array.h +++ b/absl/container/fixed_array.h @@ -120,7 +120,7 @@ class FixedArray { template <typename Iter, EnableIfForwardIterator<Iter> = 0> FixedArray(Iter first, Iter last) : rep_(first, last) {} - // Create the array from an initializer_list. + // Creates the array from an initializer_list. FixedArray(std::initializer_list<T> init_list) : FixedArray(init_list.begin(), init_list.end()) {} diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h index bab5e2175a7fe80a9ab5e5e8cfae913e43081d8b..afb8bcf16497664f49b1c7ba970fe607d208f431 100644 --- a/absl/numeric/int128.h +++ b/absl/numeric/int128.h @@ -46,7 +46,7 @@ namespace absl { // that occurs, existing uses of `uint128` will continue to work using that new // type. // -// Note: code written with this type will continue to compile once `unint128_t` +// Note: code written with this type will continue to compile once `uint128_t` // is introduced, provided the replacement helper functions // `Uint128(Low|High)64()` and `MakeUint128()` are made. // diff --git a/absl/time/clock.cc b/absl/time/clock.cc index 9ffc1c4f91d80f5928c17733cccf471e710d979e..6398170d0d1a36fd84778e636a196842a84985f4 100644 --- a/absl/time/clock.cc +++ b/absl/time/clock.cc @@ -368,7 +368,7 @@ static uint64_t UpdateLastSample( // into the fast past. That causes lots of register spills and reloads that // are unnecessary unless the slow path is taken. // -// TODO(absl-team) Remove this attribute when our compiler is smart enough +// TODO(absl-team): Remove this attribute when our compiler is smart enough // to do the right thing. ABSL_ATTRIBUTE_NOINLINE static int64_t GetCurrentTimeNanosSlowPath() LOCKS_EXCLUDED(lock) { diff --git a/absl/types/optional.h b/absl/types/optional.h index 8b56513fab2e0c507a011d2513b20b4a6a4f8fcc..f1b41ace819553e049a077bd905b7f5517a5e595 100644 --- a/absl/types/optional.h +++ b/absl/types/optional.h @@ -246,7 +246,7 @@ class optional_data_base : public optional_data_dtor_base<T> { } }; -// TODO(absl-team) Add another class using +// TODO(absl-team): Add another class using // std::is_trivially_move_constructible trait when available to match // http://cplusplus.github.io/LWG/lwg-defects.html#2900, for types that // have trivial move but nontrivial copy.