Commit 6c7de165 by Abseil Team Committed by Shaindel Schwartz

Project import generated by Copybara.

GitOrigin-RevId: d89dba27
Change-Id: I0eae80578a93a580820bc90d42e6b42faf7fde0a
parent e5be8053
# Long Term Support (LTS) Branches
This repository contains periodic snapshots of the Abseil codebase that are
Long Term Support (LTS) branches. An LTS branch allows you to use a known
version of Abseil without interfering with other projects which may also, in
turn, use Abseil. (For more information about our releases, see the
[Abseil Release Management](https://abseil.io/about/releases) guide.)
## LTS Branches
The following lists LTS branches and the dates on which they have been released:
* [LTS Branch June 20, 2018](https://github.com/abseil/abseil-cpp/tree/lts_2018_06_20/)
workspace(name = "com_google_absl") workspace(name = "com_google_absl")
# Bazel toolchains # Bazel toolchains
http_archive( http_archive(
name = "bazel_toolchains", name = "bazel_toolchains",
urls = [ urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/f8847f64e6950e8ab9fde1c0aba768550b0d9ab2.tar.gz", "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/archive/287b64e0a211fb7c23b74695f8d5f5205b61f4eb.tar.gz",
"https://github.com/bazelbuild/bazel-toolchains/archive/f8847f64e6950e8ab9fde1c0aba768550b0d9ab2.tar.gz", "https://github.com/bazelbuild/bazel-toolchains/archive/287b64e0a211fb7c23b74695f8d5f5205b61f4eb.tar.gz",
], ],
strip_prefix = "bazel-toolchains-f8847f64e6950e8ab9fde1c0aba768550b0d9ab2", strip_prefix = "bazel-toolchains-287b64e0a211fb7c23b74695f8d5f5205b61f4eb",
sha256 = "794366f51fea224b3656a0b0f8f1518e739748646523a572fcd3d68614a0e670", sha256 = "aca8ac6afd7745027ee4a43032b51a725a61a75a30f02cc58681ee87e4dcdf4b",
) )
# GoogleTest/GoogleMock framework. Used by most unit-tests. # GoogleTest/GoogleMock framework. Used by most unit-tests.
...@@ -15,6 +15,7 @@ http_archive( ...@@ -15,6 +15,7 @@ http_archive(
name = "com_google_googletest", name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/4e4df226fc197c0dda6e37f5c8c3845ca1e73a49.zip"], urls = ["https://github.com/google/googletest/archive/4e4df226fc197c0dda6e37f5c8c3845ca1e73a49.zip"],
strip_prefix = "googletest-4e4df226fc197c0dda6e37f5c8c3845ca1e73a49", strip_prefix = "googletest-4e4df226fc197c0dda6e37f5c8c3845ca1e73a49",
sha256 = "d4179caf54410968d1fff0b869e7d74803dd30209ee6645ccf1ca65ab6cf5e5a",
) )
# Google benchmark. # Google benchmark.
...@@ -22,6 +23,7 @@ http_archive( ...@@ -22,6 +23,7 @@ http_archive(
name = "com_github_google_benchmark", name = "com_github_google_benchmark",
urls = ["https://github.com/google/benchmark/archive/16703ff83c1ae6d53e5155df3bb3ab0bc96083be.zip"], urls = ["https://github.com/google/benchmark/archive/16703ff83c1ae6d53e5155df3bb3ab0bc96083be.zip"],
strip_prefix = "benchmark-16703ff83c1ae6d53e5155df3bb3ab0bc96083be", strip_prefix = "benchmark-16703ff83c1ae6d53e5155df3bb3ab0bc96083be",
sha256 = "59f918c8ccd4d74b6ac43484467b500f1d64b40cc1010daa055375b322a43ba3",
) )
# RE2 regular-expression framework. Used by some unit-tests. # RE2 regular-expression framework. Used by some unit-tests.
...@@ -29,4 +31,5 @@ http_archive( ...@@ -29,4 +31,5 @@ http_archive(
name = "com_googlesource_code_re2", name = "com_googlesource_code_re2",
urls = ["https://github.com/google/re2/archive/6cf8ccd82dbaab2668e9b13596c68183c9ecd13f.zip"], urls = ["https://github.com/google/re2/archive/6cf8ccd82dbaab2668e9b13596c68183c9ecd13f.zip"],
strip_prefix = "re2-6cf8ccd82dbaab2668e9b13596c68183c9ecd13f", strip_prefix = "re2-6cf8ccd82dbaab2668e9b13596c68183c9ecd13f",
sha256 = "279a852219dbfc504501775596089d30e9c0b29664ce4128b0ac4c841471a16a",
) )
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <type_traits> #include <type_traits>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace algorithm_internal { namespace algorithm_internal {
...@@ -145,6 +146,7 @@ ForwardIterator rotate(ForwardIterator first, ForwardIterator middle, ...@@ -145,6 +146,7 @@ ForwardIterator rotate(ForwardIterator first, ForwardIterator middle,
ForwardIterator>()); ForwardIterator>());
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_ALGORITHM_ALGORITHM_H_ #endif // ABSL_ALGORITHM_ALGORITHM_H_
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace container_algorithm_internal { namespace container_algorithm_internal {
...@@ -1637,6 +1638,7 @@ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first, ...@@ -1637,6 +1638,7 @@ OutputIt c_partial_sum(const InputSequence& input, OutputIt output_first,
output_first, std::forward<BinaryOp>(op)); output_first, std::forward<BinaryOp>(op));
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_ALGORITHM_CONTAINER_H_ #endif // ABSL_ALGORITHM_CONTAINER_H_
...@@ -371,11 +371,6 @@ cc_test( ...@@ -371,11 +371,6 @@ cc_test(
size = "small", size = "small",
srcs = ["internal/sysinfo_test.cc"], srcs = ["internal/sysinfo_test.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
tags = [
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
],
deps = [ deps = [
":base", ":base",
"//absl/synchronization", "//absl/synchronization",
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "absl/base/macros.h" #include "absl/base/macros.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace { namespace {
template <int N> template <int N>
...@@ -104,4 +105,5 @@ TEST(BitCast, Double) { ...@@ -104,4 +105,5 @@ TEST(BitCast, Double) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
class once_flag; class once_flag;
...@@ -211,6 +212,7 @@ void call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) { ...@@ -211,6 +212,7 @@ void call_once(absl::once_flag& flag, Callable&& fn, Args&&... args) {
} }
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_CALL_ONCE_H_ #endif // ABSL_BASE_CALL_ONCE_H_
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace { namespace {
absl::once_flag once; absl::once_flag once;
...@@ -99,4 +100,5 @@ TEST(CallOnceTest, ExecutionCount) { ...@@ -99,4 +100,5 @@ TEST(CallOnceTest, ExecutionCount) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "absl/base/internal/identity.h" #include "absl/base/internal/identity.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// implicit_cast() // implicit_cast()
// //
...@@ -135,6 +136,7 @@ inline Dest bit_cast(const Source& source) { ...@@ -135,6 +136,7 @@ inline Dest bit_cast(const Source& source) {
return dest; return dest;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_CASTS_H_ #endif // ABSL_BASE_CASTS_H_
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "gtest/gtest.h" #include "gtest/gtest.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
namespace { namespace {
...@@ -59,4 +60,5 @@ TEST(InlineVariableTest, FunPtrType) { ...@@ -59,4 +60,5 @@ TEST(InlineVariableTest, FunPtrType) {
} // namespace } // namespace
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "absl/base/internal/inline_variable_testing.h" #include "absl/base/internal/inline_variable_testing.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
const Foo& get_foo_a() { return inline_variable_foo; } const Foo& get_foo_a() { return inline_variable_foo; }
...@@ -22,4 +23,5 @@ const Foo& get_foo_a() { return inline_variable_foo; } ...@@ -22,4 +23,5 @@ const Foo& get_foo_a() { return inline_variable_foo; }
const int& get_int_a() { return inline_variable_int; } const int& get_int_a() { return inline_variable_int; }
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "absl/base/internal/inline_variable_testing.h" #include "absl/base/internal/inline_variable_testing.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
const Foo& get_foo_b() { return inline_variable_foo; } const Foo& get_foo_b() { return inline_variable_foo; }
...@@ -22,4 +23,5 @@ const Foo& get_foo_b() { return inline_variable_foo; } ...@@ -22,4 +23,5 @@ const Foo& get_foo_b() { return inline_variable_foo; }
const int& get_int_b() { return inline_variable_int; } const int& get_int_b() { return inline_variable_int; }
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
template <typename T> template <typename T>
...@@ -160,6 +161,7 @@ class AtomicHook<ReturnType (*)(Args...)> { ...@@ -160,6 +161,7 @@ class AtomicHook<ReturnType (*)(Args...)> {
#undef ABSL_HAVE_WORKING_ATOMIC_POINTER #undef ABSL_HAVE_WORKING_ATOMIC_POINTER
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_ #endif // ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "absl/base/internal/unscaledcycleclock.h" #include "absl/base/internal/unscaledcycleclock.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
#if ABSL_USE_UNSCALED_CYCLECLOCK #if ABSL_USE_UNSCALED_CYCLECLOCK
...@@ -78,4 +79,5 @@ double CycleClock::Frequency() { ...@@ -78,4 +79,5 @@ double CycleClock::Frequency() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <cstdint> #include <cstdint>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -72,6 +73,7 @@ class CycleClock { ...@@ -72,6 +73,7 @@ class CycleClock {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_ #endif // ABSL_BASE_INTERNAL_CYCLECLOCK_H_
...@@ -62,6 +62,7 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t); ...@@ -62,6 +62,7 @@ extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
#endif // __BIONIC__ #endif // __BIONIC__
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// Platform specific logic extracted from // Platform specific logic extracted from
...@@ -122,6 +123,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -122,6 +123,7 @@ inline int DirectMunmap(void* start, size_t length) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#else // !__linux__ #else // !__linux__
...@@ -130,6 +132,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -130,6 +132,7 @@ inline int DirectMunmap(void* start, size_t length) {
// actual mmap()/munmap() methods. // actual mmap()/munmap() methods.
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd, inline void* DirectMmap(void* start, size_t length, int prot, int flags, int fd,
...@@ -142,6 +145,7 @@ inline int DirectMunmap(void* start, size_t length) { ...@@ -142,6 +145,7 @@ inline int DirectMunmap(void* start, size_t length) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // __linux__ #endif // __linux__
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// Use compiler byte-swapping intrinsics if they are available. 32-bit // Use compiler byte-swapping intrinsics if they are available. 32-bit
// and 64-bit versions are available in Clang and GCC as of GCC 4.3.0. // and 64-bit versions are available in Clang and GCC as of GCC 4.3.0.
...@@ -264,6 +265,7 @@ inline void Store64(void *p, uint64_t v) { ...@@ -264,6 +265,7 @@ inline void Store64(void *p, uint64_t v) {
} // namespace big_endian } // namespace big_endian
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_ENDIAN_H_ #endif // ABSL_BASE_INTERNAL_ENDIAN_H_
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "absl/base/config.h" #include "absl/base/config.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace { namespace {
const uint64_t kInitialNumber{0x0123456789abcdef}; const uint64_t kInitialNumber{0x0123456789abcdef};
...@@ -276,4 +277,5 @@ TEST(EndianessTest, big_endian) { ...@@ -276,4 +277,5 @@ TEST(EndianessTest, big_endian) {
} }
} // namespace } // namespace
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <cstdint> #include <cstdint>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// Arbitrary value with high bits set. Xor'ing with it is unlikely // Arbitrary value with high bits set. Xor'ing with it is unlikely
...@@ -42,6 +43,7 @@ inline T* UnhidePtr(uintptr_t hidden) { ...@@ -42,6 +43,7 @@ inline T* UnhidePtr(uintptr_t hidden) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_ #endif // ABSL_BASE_INTERNAL_HIDE_PTR_H_
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define ABSL_BASE_INTERNAL_IDENTITY_H_ #define ABSL_BASE_INTERNAL_IDENTITY_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace internal { namespace internal {
template <typename T> template <typename T>
...@@ -27,7 +28,8 @@ struct identity { ...@@ -27,7 +28,8 @@ struct identity {
template <typename T> template <typename T>
using identity_t = typename identity<T>::type; using identity_t = typename identity<T>::type;
} // namespace internal } // namespace internal
} // namespace absl } // inline namespace lts_2018_06_20
} // namespace absl
#endif // ABSL_BASE_INTERNAL_IDENTITY_H_ #endif // ABSL_BASE_INTERNAL_IDENTITY_H_
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "absl/base/internal/inline_variable.h" #include "absl/base/internal/inline_variable.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace inline_variable_testing_internal { namespace inline_variable_testing_internal {
struct Foo { struct Foo {
...@@ -39,6 +40,7 @@ const int& get_int_a(); ...@@ -39,6 +40,7 @@ const int& get_int_a();
const int& get_int_b(); const int& get_int_b();
} // namespace inline_variable_testing_internal } // namespace inline_variable_testing_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_ #endif // ABSL_BASE_INLINE_VARIABLE_TESTING_H_
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
// top of this file for the API documentation. // top of this file for the API documentation.
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// The five classes below each implement one of the clauses from the definition // The five classes below each implement one of the clauses from the definition
...@@ -183,6 +184,7 @@ InvokeT<F, Args...> Invoke(F&& f, Args&&... args) { ...@@ -183,6 +184,7 @@ InvokeT<F, Args...> Invoke(F&& f, Args&&... args) {
std::forward<Args>(args)...); std::forward<Args>(args)...);
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_INVOKE_H_ #endif // ABSL_BASE_INTERNAL_INVOKE_H_
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#endif // __APPLE__ #endif // __APPLE__
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// A first-fit allocator with amortized logarithmic free() time. // A first-fit allocator with amortized logarithmic free() time.
...@@ -599,6 +600,7 @@ void *LowLevelAlloc::AllocWithArena(size_t request, Arena *arena) { ...@@ -599,6 +600,7 @@ void *LowLevelAlloc::AllocWithArena(size_t request, Arena *arena) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_LOW_LEVEL_ALLOC_MISSING #endif // ABSL_LOW_LEVEL_ALLOC_MISSING
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
class LowLevelAlloc { class LowLevelAlloc {
...@@ -115,5 +116,6 @@ class LowLevelAlloc { ...@@ -115,5 +116,6 @@ class LowLevelAlloc {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_ #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_ALLOC_H_
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <utility> #include <utility>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -148,6 +149,7 @@ static struct BeforeMain { ...@@ -148,6 +149,7 @@ static struct BeforeMain {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
......
...@@ -28,6 +28,7 @@ extern "C" bool __google_disable_rescheduling(void); ...@@ -28,6 +28,7 @@ extern "C" bool __google_disable_rescheduling(void);
extern "C" void __google_enable_rescheduling(bool disable_result); extern "C" void __google_enable_rescheduling(bool disable_result);
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
class SchedulingHelper; // To allow use of SchedulingGuard. class SchedulingHelper; // To allow use of SchedulingGuard.
...@@ -100,5 +101,6 @@ inline void SchedulingGuard::EnableRescheduling(bool /* disable_result */) { ...@@ -100,5 +101,6 @@ inline void SchedulingGuard::EnableRescheduling(bool /* disable_result */) {
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_ #endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
...@@ -181,6 +181,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line, ...@@ -181,6 +181,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line,
} // namespace } // namespace
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace raw_logging_internal { namespace raw_logging_internal {
void SafeWriteToStderr(const char *s, size_t len) { void SafeWriteToStderr(const char *s, size_t len) {
#if defined(ABSL_HAVE_SYSCALL_WRITE) #if defined(ABSL_HAVE_SYSCALL_WRITE)
...@@ -215,4 +216,5 @@ bool RawLoggingFullySupported() { ...@@ -215,4 +216,5 @@ bool RawLoggingFullySupported() {
} }
} // namespace raw_logging_internal } // namespace raw_logging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
::absl::NormalizeLogSeverity(severity) ::absl::NormalizeLogSeverity(severity)
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace raw_logging_internal { namespace raw_logging_internal {
// Helper function to implement ABSL_RAW_LOG // Helper function to implement ABSL_RAW_LOG
...@@ -132,6 +133,7 @@ using AbortHook = void (*)(const char* file, int line, const char* buf_start, ...@@ -132,6 +133,7 @@ using AbortHook = void (*)(const char* file, int line, const char* buf_start,
const char* prefix_end, const char* buf_end); const char* prefix_end, const char* buf_end);
} // namespace raw_logging_internal } // namespace raw_logging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_ #endif // ABSL_BASE_INTERNAL_RAW_LOGGING_H_
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #define ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// Used to describe how a thread may be scheduled. Typically associated with // Used to describe how a thread may be scheduled. Typically associated with
...@@ -49,6 +50,7 @@ enum SchedulingMode { ...@@ -49,6 +50,7 @@ enum SchedulingMode {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_ #endif // ABSL_BASE_INTERNAL_SCHEDULING_MODE_H_
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
// holder to acquire the lock. There may be outstanding waiter(s). // holder to acquire the lock. There may be outstanding waiter(s).
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
ABSL_CONST_INIT static base_internal::AtomicHook<void (*)(const void *lock, ABSL_CONST_INIT static base_internal::AtomicHook<void (*)(const void *lock,
...@@ -225,4 +226,5 @@ uint64_t SpinLock::DecodeWaitCycles(uint32_t lock_value) { ...@@ -225,4 +226,5 @@ uint64_t SpinLock::DecodeWaitCycles(uint32_t lock_value) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include "absl/base/thread_annotations.h" #include "absl/base/thread_annotations.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
class LOCKABLE SpinLock { class LOCKABLE SpinLock {
...@@ -234,6 +235,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value, ...@@ -234,6 +235,7 @@ inline uint32_t SpinLock::TryLockInternal(uint32_t lock_value,
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SPINLOCK_H_ #endif // ABSL_BASE_INTERNAL_SPINLOCK_H_
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// See spinlock_wait.h for spec. // See spinlock_wait.h for spec.
...@@ -76,4 +77,5 @@ int SpinLockSuggestedDelayNS(int loop) { ...@@ -76,4 +77,5 @@ int SpinLockSuggestedDelayNS(int loop) {
} }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "absl/base/internal/scheduling_mode.h" #include "absl/base/internal/scheduling_mode.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// SpinLockWait() waits until it can perform one of several transitions from // SpinLockWait() waits until it can perform one of several transitions from
...@@ -62,6 +63,7 @@ void SpinLockDelay(std::atomic<uint32_t> *w, uint32_t value, int loop, ...@@ -62,6 +63,7 @@ void SpinLockDelay(std::atomic<uint32_t> *w, uint32_t value, int loop,
int SpinLockSuggestedDelayNS(int loop); int SpinLockSuggestedDelayNS(int loop);
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
// In some build configurations we pass --detect-odr-violations to the // In some build configurations we pass --detect-odr-violations to the
...@@ -84,7 +86,7 @@ inline void absl::base_internal::SpinLockWake(std::atomic<uint32_t> *w, ...@@ -84,7 +86,7 @@ inline void absl::base_internal::SpinLockWake(std::atomic<uint32_t> *w,
inline void absl::base_internal::SpinLockDelay( inline void absl::base_internal::SpinLockDelay(
std::atomic<uint32_t> *w, uint32_t value, int loop, std::atomic<uint32_t> *w, uint32_t value, int loop,
base_internal::SchedulingMode scheduling_mode) { absl::base_internal::SchedulingMode scheduling_mode) {
AbslInternalSpinLockDelay(w, value, loop, scheduling_mode); AbslInternalSpinLockDelay(w, value, loop, scheduling_mode);
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "absl/base/internal/unscaledcycleclock.h" #include "absl/base/internal/unscaledcycleclock.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
static once_flag init_system_info_once; static once_flag init_system_info_once;
...@@ -401,4 +402,5 @@ pid_t GetTID() { ...@@ -401,4 +402,5 @@ pid_t GetTID() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// Nominal core processor cycles per second of each processor. This is _not_ // Nominal core processor cycles per second of each processor. This is _not_
...@@ -58,6 +59,7 @@ using pid_t = DWORD; ...@@ -58,6 +59,7 @@ using pid_t = DWORD;
pid_t GetTID(); pid_t GetTID();
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_SYSINFO_H_ #endif // ABSL_BASE_INTERNAL_SYSINFO_H_
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -95,4 +96,5 @@ TEST(SysinfoTest, LinuxGetTID) { ...@@ -95,4 +96,5 @@ TEST(SysinfoTest, LinuxGetTID) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "absl/base/internal/spinlock.h" #include "absl/base/internal/spinlock.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
#if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11 #if ABSL_THREAD_IDENTITY_MODE != ABSL_THREAD_IDENTITY_MODE_USE_CPP11
...@@ -120,4 +121,5 @@ ThreadIdentity* CurrentThreadIdentityIfPresent() { ...@@ -120,4 +121,5 @@ ThreadIdentity* CurrentThreadIdentityIfPresent() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "absl/base/internal/per_thread_tls.h" #include "absl/base/internal/per_thread_tls.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
struct SynchLocksHeld; struct SynchLocksHeld;
struct SynchWaitParams; struct SynchWaitParams;
...@@ -236,5 +237,6 @@ inline ThreadIdentity* CurrentThreadIdentityIfPresent() { ...@@ -236,5 +237,6 @@ inline ThreadIdentity* CurrentThreadIdentityIfPresent() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_ #endif // ABSL_BASE_INTERNAL_THREAD_IDENTITY_H_
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "absl/synchronization/mutex.h" #include "absl/synchronization/mutex.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -123,4 +124,5 @@ TEST(ThreadIdentityTest, ReusedThreadIdentityMutexTest) { ...@@ -123,4 +124,5 @@ TEST(ThreadIdentityTest, ReusedThreadIdentityMutexTest) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -103,4 +104,5 @@ void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); } ...@@ -103,4 +104,5 @@ void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); }
void ThrowStdBadAlloc() { Throw(std::bad_alloc()); } void ThrowStdBadAlloc() { Throw(std::bad_alloc()); }
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include <string> #include <string>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// Helper functions that allow throwing exceptions consistently from anywhere. // Helper functions that allow throwing exceptions consistently from anywhere.
...@@ -66,6 +67,7 @@ namespace base_internal { ...@@ -66,6 +67,7 @@ namespace base_internal {
// [[noreturn]] void ThrowStdBadArrayNewLength(); // [[noreturn]] void ThrowStdBadArrayNewLength();
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_ #endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_
...@@ -65,6 +65,7 @@ void __sanitizer_unaligned_store64(void *p, uint64_t v); ...@@ -65,6 +65,7 @@ void __sanitizer_unaligned_store64(void *p, uint64_t v);
} // extern "C" } // extern "C"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
inline uint16_t UnalignedLoad16(const void *p) { inline uint16_t UnalignedLoad16(const void *p) {
return __sanitizer_unaligned_load16(p); return __sanitizer_unaligned_load16(p);
...@@ -90,6 +91,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { ...@@ -90,6 +91,7 @@ inline void UnalignedStore64(void *p, uint64_t v) {
__sanitizer_unaligned_store64(p, v); __sanitizer_unaligned_store64(p, v);
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) (absl::UnalignedLoad16(_p)) #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) (absl::UnalignedLoad16(_p))
...@@ -158,6 +160,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { ...@@ -158,6 +160,7 @@ inline void UnalignedStore64(void *p, uint64_t v) {
// so we do that. // so we do that.
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace internal { namespace internal {
struct Unaligned16Struct { struct Unaligned16Struct {
...@@ -171,6 +174,7 @@ struct Unaligned32Struct { ...@@ -171,6 +174,7 @@ struct Unaligned32Struct {
} ABSL_ATTRIBUTE_PACKED; } ABSL_ATTRIBUTE_PACKED;
} // namespace internal } // namespace internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \ #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) \
...@@ -186,6 +190,7 @@ struct Unaligned32Struct { ...@@ -186,6 +190,7 @@ struct Unaligned32Struct {
(_val)) (_val))
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
inline uint64_t UnalignedLoad64(const void *p) { inline uint64_t UnalignedLoad64(const void *p) {
uint64_t t; uint64_t t;
...@@ -195,6 +200,7 @@ inline uint64_t UnalignedLoad64(const void *p) { ...@@ -195,6 +200,7 @@ inline uint64_t UnalignedLoad64(const void *p) {
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) (absl::UnalignedLoad64(_p)) #define ABSL_INTERNAL_UNALIGNED_LOAD64(_p) (absl::UnalignedLoad64(_p))
...@@ -211,6 +217,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } ...@@ -211,6 +217,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
// unaligned loads and stores. // unaligned loads and stores.
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
inline uint16_t UnalignedLoad16(const void *p) { inline uint16_t UnalignedLoad16(const void *p) {
uint16_t t; uint16_t t;
...@@ -236,6 +243,7 @@ inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); } ...@@ -236,6 +243,7 @@ inline void UnalignedStore32(void *p, uint32_t v) { memcpy(p, &v, sizeof v); }
inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); } inline void UnalignedStore64(void *p, uint64_t v) { memcpy(p, &v, sizeof v); }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) (absl::UnalignedLoad16(_p)) #define ABSL_INTERNAL_UNALIGNED_LOAD16(_p) (absl::UnalignedLoad16(_p))
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "absl/base/internal/sysinfo.h" #include "absl/base/internal/sysinfo.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
#if defined(__i386__) #if defined(__i386__)
...@@ -96,6 +97,7 @@ double UnscaledCycleClock::Frequency() { ...@@ -96,6 +97,7 @@ double UnscaledCycleClock::Frequency() {
#endif #endif
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_USE_UNSCALED_CYCLECLOCK #endif // ABSL_USE_UNSCALED_CYCLECLOCK
...@@ -84,6 +84,7 @@ ...@@ -84,6 +84,7 @@
#define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY #define ABSL_INTERNAL_UNSCALED_CYCLECLOCK_FREQUENCY_IS_CPU_FREQUENCY
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace time_internal { namespace time_internal {
class UnscaledCycleClockWrapperForGetCurrentTime; class UnscaledCycleClockWrapperForGetCurrentTime;
} // namespace time_internal } // namespace time_internal
...@@ -113,6 +114,7 @@ class UnscaledCycleClock { ...@@ -113,6 +114,7 @@ class UnscaledCycleClock {
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_USE_UNSCALED_CYCLECLOCK #endif // ABSL_USE_UNSCALED_CYCLECLOCK
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "absl/strings/str_cat.h" #include "absl/strings/str_cat.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
namespace { namespace {
...@@ -197,4 +198,5 @@ TEST(InvokeTest, SfinaeFriendly) { ...@@ -197,4 +198,5 @@ TEST(InvokeTest, SfinaeFriendly) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "absl/base/attributes.h" #include "absl/base/attributes.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// Four severity levels are defined. Logging APIs should terminate the program // Four severity levels are defined. Logging APIs should terminate the program
// when a message is logged at severity `kFatal`; the other levels have no // when a message is logged at severity `kFatal`; the other levels have no
...@@ -62,6 +63,7 @@ constexpr absl::LogSeverity NormalizeLogSeverity(int s) { ...@@ -62,6 +63,7 @@ constexpr absl::LogSeverity NormalizeLogSeverity(int s) {
return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s)); return NormalizeLogSeverity(static_cast<absl::LogSeverity>(s));
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ #endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
...@@ -43,12 +43,14 @@ ...@@ -43,12 +43,14 @@
(sizeof(::absl::macros_internal::ArraySizeHelper(array))) (sizeof(::absl::macros_internal::ArraySizeHelper(array)))
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace macros_internal { namespace macros_internal {
// Note: this internal template function declaration is used by ABSL_ARRAYSIZE. // Note: this internal template function declaration is used by ABSL_ARRAYSIZE.
// The function doesn't need a definition, as we only use its type. // The function doesn't need a definition, as we only use its type.
template <typename T, size_t N> template <typename T, size_t N>
auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N];
} // namespace macros_internal } // namespace macros_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
// kLinkerInitialized // kLinkerInitialized
...@@ -72,11 +74,13 @@ auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N]; ...@@ -72,11 +74,13 @@ auto ArraySizeHelper(const T (&array)[N]) -> char (&)[N];
// // Invocation // // Invocation
// static MyClass my_global(absl::base_internal::kLinkerInitialized); // static MyClass my_global(absl::base_internal::kLinkerInitialized);
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
enum LinkerInitialized { enum LinkerInitialized {
kLinkerInitialized = 0, kLinkerInitialized = 0,
}; };
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
// ABSL_FALLTHROUGH_INTENDED // ABSL_FALLTHROUGH_INTENDED
...@@ -194,8 +198,9 @@ enum LinkerInitialized { ...@@ -194,8 +198,9 @@ enum LinkerInitialized {
#if defined(NDEBUG) #if defined(NDEBUG)
#define ABSL_ASSERT(expr) (false ? (void)(expr) : (void)0) #define ABSL_ASSERT(expr) (false ? (void)(expr) : (void)0)
#else #else
#define ABSL_ASSERT(expr) \ #define ABSL_ASSERT(expr) \
(ABSL_PREDICT_TRUE((expr)) ? (void)0 : [] { assert(false && #expr); }()) (ABSL_PREDICT_TRUE((expr)) ? (void)0 \
: [] { assert(false && #expr); }()) // NOLINT
#endif #endif
#endif // ABSL_BASE_MACROS_H_ #endif // ABSL_BASE_MACROS_H_
...@@ -36,6 +36,7 @@ constexpr int32_t kNumThreads = 10; ...@@ -36,6 +36,7 @@ constexpr int32_t kNumThreads = 10;
constexpr int32_t kIters = 1000; constexpr int32_t kIters = 1000;
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace base_internal { namespace base_internal {
// This is defined outside of anonymous namespace so that it can be // This is defined outside of anonymous namespace so that it can be
...@@ -263,4 +264,5 @@ TEST(SpinLockWithThreads, DoesNotDeadlock) { ...@@ -263,4 +264,5 @@ TEST(SpinLockWithThreads, DoesNotDeadlock) {
} // namespace } // namespace
} // namespace base_internal } // namespace base_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1); constexpr static auto kFixedArrayUseDefault = static_cast<size_t>(-1);
...@@ -494,5 +495,6 @@ constexpr size_t FixedArray<T, N>::inline_elements; ...@@ -494,5 +495,6 @@ constexpr size_t FixedArray<T, N>::inline_elements;
template <typename T, size_t N> template <typename T, size_t N>
constexpr size_t FixedArray<T, N>::kInlineBytesDefault; constexpr size_t FixedArray<T, N>::kInlineBytesDefault;
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_CONTAINER_FIXED_ARRAY_H_ #endif // ABSL_CONTAINER_FIXED_ARRAY_H_
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// InlinedVector // InlinedVector
...@@ -1379,6 +1380,7 @@ auto InlinedVector<T, N, A>::InsertWithRange(const_iterator position, ...@@ -1379,6 +1380,7 @@ auto InlinedVector<T, N, A>::InsertWithRange(const_iterator position,
return it_pair.first; return it_pair.first;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_CONTAINER_INLINED_VECTOR_H_ #endif // ABSL_CONTAINER_INLINED_VECTOR_H_
...@@ -63,18 +63,34 @@ void BM_StdVectorFill(benchmark::State& state) { ...@@ -63,18 +63,34 @@ void BM_StdVectorFill(benchmark::State& state) {
} }
BENCHMARK(BM_StdVectorFill)->Range(0, 1024); BENCHMARK(BM_StdVectorFill)->Range(0, 1024);
// The purpose of the next two benchmarks is to verify that
// absl::InlinedVector is efficient when moving is more efficent than
// copying. To do so, we use strings that are larger than the short
// std::string optimization.
bool StringRepresentedInline(std::string s) { bool StringRepresentedInline(std::string s) {
const char* chars = s.data(); const char* chars = s.data();
std::string s1 = std::move(s); std::string s1 = std::move(s);
return s1.data() != chars; return s1.data() != chars;
} }
int GetNonShortStringOptimizationSize() {
for (int i = 24; i <= 192; i *= 2) {
if (!StringRepresentedInline(std::string(i, 'A'))) {
return i;
}
}
ABSL_RAW_LOG(
FATAL,
"Failed to find a std::string larger than the short std::string optimization");
return -1;
}
void BM_InlinedVectorFillString(benchmark::State& state) { void BM_InlinedVectorFillString(benchmark::State& state) {
const int len = state.range(0); const int len = state.range(0);
std::string strings[4] = {"a quite long string", const int no_sso = GetNonShortStringOptimizationSize();
"another long string", std::string strings[4] = {std::string(no_sso, 'A'), std::string(no_sso, 'B'),
"012345678901234567", std::string(no_sso, 'C'), std::string(no_sso, 'D')};
"to cause allocation"};
for (auto _ : state) { for (auto _ : state) {
absl::InlinedVector<std::string, 8> v; absl::InlinedVector<std::string, 8> v;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
...@@ -87,10 +103,10 @@ BENCHMARK(BM_InlinedVectorFillString)->Range(0, 1024); ...@@ -87,10 +103,10 @@ BENCHMARK(BM_InlinedVectorFillString)->Range(0, 1024);
void BM_StdVectorFillString(benchmark::State& state) { void BM_StdVectorFillString(benchmark::State& state) {
const int len = state.range(0); const int len = state.range(0);
std::string strings[4] = {"a quite long string", const int no_sso = GetNonShortStringOptimizationSize();
"another long string", std::string strings[4] = {std::string(no_sso, 'A'), std::string(no_sso, 'B'),
"012345678901234567", std::string(no_sso, 'C'), std::string(no_sso, 'D')};
"to cause allocation"};
for (auto _ : state) { for (auto _ : state) {
std::vector<std::string> v; std::vector<std::string> v;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
...@@ -98,11 +114,6 @@ void BM_StdVectorFillString(benchmark::State& state) { ...@@ -98,11 +114,6 @@ void BM_StdVectorFillString(benchmark::State& state) {
} }
} }
state.SetItemsProcessed(static_cast<int64_t>(state.iterations()) * len); state.SetItemsProcessed(static_cast<int64_t>(state.iterations()) * len);
// The purpose of the benchmark is to verify that inlined vector is
// efficient when moving is more efficent than copying. To do so, we
// use strings that are larger than the small std::string optimization.
ABSL_RAW_CHECK(!StringRepresentedInline(strings[0]),
"benchmarked with strings that are too small");
} }
BENCHMARK(BM_StdVectorFillString)->Range(0, 1024); BENCHMARK(BM_StdVectorFillString)->Range(0, 1024);
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "absl/container/internal/test_instance_tracker.h" #include "absl/container/internal/test_instance_tracker.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace test_internal { namespace test_internal {
int BaseCountedInstance::num_instances_ = 0; int BaseCountedInstance::num_instances_ = 0;
int BaseCountedInstance::num_live_instances_ = 0; int BaseCountedInstance::num_live_instances_ = 0;
...@@ -23,4 +24,5 @@ int BaseCountedInstance::num_copies_ = 0; ...@@ -23,4 +24,5 @@ int BaseCountedInstance::num_copies_ = 0;
int BaseCountedInstance::num_swaps_ = 0; int BaseCountedInstance::num_swaps_ = 0;
} // namespace test_internal } // namespace test_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <ostream> #include <ostream>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace test_internal { namespace test_internal {
// A type that counts number of occurences of the type, the live occurrences of // A type that counts number of occurences of the type, the live occurrences of
...@@ -215,6 +216,7 @@ class MovableOnlyInstance : public BaseCountedInstance { ...@@ -215,6 +216,7 @@ class MovableOnlyInstance : public BaseCountedInstance {
}; };
} // namespace test_internal } // namespace test_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_CONTAINER_INTERNAL_TEST_INSTANCE_TRACKER_H_ #endif // ABSL_CONTAINER_INTERNAL_TEST_INSTANCE_TRACKER_H_
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
ABSL_CONST_INIT static FailureSignalHandlerOptions fsh_options; ABSL_CONST_INIT static FailureSignalHandlerOptions fsh_options;
...@@ -353,4 +354,5 @@ void InstallFailureSignalHandler(const FailureSignalHandlerOptions& options) { ...@@ -353,4 +354,5 @@ void InstallFailureSignalHandler(const FailureSignalHandlerOptions& options) {
} }
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#define ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ #define ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// FailureSignalHandlerOptions // FailureSignalHandlerOptions
// //
...@@ -112,6 +113,7 @@ namespace debugging_internal { ...@@ -112,6 +113,7 @@ namespace debugging_internal {
const char* FailureSignalToString(int signo); const char* FailureSignalToString(int signo);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_ #endif // ABSL_DEBUGGING_FAILURE_SIGNAL_HANDLER_H_
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#if !defined(__linux__) || defined(__ANDROID__) #if !defined(__linux__) || defined(__ANDROID__)
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// On platforms other than Linux, just return true. // On platforms other than Linux, just return true.
bool AddressIsReadable(const void* /* addr */) { return true; } bool AddressIsReadable(const void* /* addr */) { return true; }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#else #else
...@@ -40,6 +42,7 @@ bool AddressIsReadable(const void* /* addr */) { return true; } ...@@ -40,6 +42,7 @@ bool AddressIsReadable(const void* /* addr */) { return true; }
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Pack a pid and two file descriptors into a 64-bit word, // Pack a pid and two file descriptors into a 64-bit word,
...@@ -128,6 +131,7 @@ bool AddressIsReadable(const void *addr) { ...@@ -128,6 +131,7 @@ bool AddressIsReadable(const void *addr) {
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif #endif
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#define ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ #define ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Return whether the byte at *addr is readable, without faulting. // Return whether the byte at *addr is readable, without faulting.
...@@ -24,6 +25,7 @@ namespace debugging_internal { ...@@ -24,6 +25,7 @@ namespace debugging_internal {
bool AddressIsReadable(const void *addr); bool AddressIsReadable(const void *addr);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_ #endif // ABSL_DEBUGGING_INTERNAL_ADDRESS_IS_READABLE_H_
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <limits> #include <limits>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
typedef struct { typedef struct {
...@@ -1859,4 +1860,5 @@ bool Demangle(const char *mangled, char *out, int out_size) { ...@@ -1859,4 +1860,5 @@ bool Demangle(const char *mangled, char *out, int out_size) {
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
#define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ #define ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Demangle `mangled`. On success, return true and write the // Demangle `mangled`. On success, return true and write the
...@@ -62,6 +63,7 @@ namespace debugging_internal { ...@@ -62,6 +63,7 @@ namespace debugging_internal {
bool Demangle(const char *mangled, char *out, int out_size); bool Demangle(const char *mangled, char *out, int out_size);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_ #endif // ABSL_DEBUGGING_INTERNAL_DEMANGLE_H_
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
namespace { namespace {
...@@ -188,4 +189,5 @@ TEST(DemangleRegression, DeeplyNestedArrayType) { ...@@ -188,4 +189,5 @@ TEST(DemangleRegression, DeeplyNestedArrayType) {
} // namespace } // namespace
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#define VERSYM_VERSION 0x7fff #define VERSYM_VERSION 0x7fff
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
namespace { namespace {
...@@ -375,6 +376,7 @@ void ElfMemImage::SymbolIterator::Update(int increment) { ...@@ -375,6 +376,7 @@ void ElfMemImage::SymbolIterator::Update(int increment) {
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_HAVE_ELF_MEM_IMAGE #endif // ABSL_HAVE_ELF_MEM_IMAGE
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <link.h> // for ElfW #include <link.h> // for ElfW
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// An in-memory ELF image (may not exist on disk). // An in-memory ELF image (may not exist on disk).
...@@ -123,6 +124,7 @@ class ElfMemImage { ...@@ -123,6 +124,7 @@ class ElfMemImage {
}; };
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_HAVE_ELF_MEM_IMAGE #endif // ABSL_HAVE_ELF_MEM_IMAGE
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "absl/debugging/symbolize.h" #include "absl/debugging/symbolize.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Returns the program counter from signal context, nullptr if // Returns the program counter from signal context, nullptr if
...@@ -146,4 +147,5 @@ void DumpPCAndFrameSizesAndStackTrace( ...@@ -146,4 +147,5 @@ void DumpPCAndFrameSizesAndStackTrace(
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ #define ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Returns the program counter from signal context, or nullptr if // Returns the program counter from signal context, or nullptr if
...@@ -33,6 +34,7 @@ void DumpPCAndFrameSizesAndStackTrace( ...@@ -33,6 +34,7 @@ void DumpPCAndFrameSizesAndStackTrace(
void (*writerfn)(const char*, void*), void* writerfn_arg); void (*writerfn)(const char*, void*), void* writerfn_arg);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_ #endif // ABSL_DEBUGGING_INTERNAL_EXAMINE_STACK_H_
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
namespace { namespace {
...@@ -167,6 +168,7 @@ int GetSignalHandlerStackConsumption(void (*signal_handler)(int)) { ...@@ -167,6 +168,7 @@ int GetSignalHandlerStackConsumption(void (*signal_handler)(int)) {
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1 #define ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION 1
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Returns the stack consumption in bytes for the code exercised by // Returns the stack consumption in bytes for the code exercised by
...@@ -38,6 +39,7 @@ namespace debugging_internal { ...@@ -38,6 +39,7 @@ namespace debugging_internal {
int GetSignalHandlerStackConsumption(void (*signal_handler)(int)); int GetSignalHandlerStackConsumption(void (*signal_handler)(int));
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
namespace { namespace {
...@@ -43,6 +44,7 @@ TEST(SignalHandlerStackConsumptionTest, MeasuresStackConsumption) { ...@@ -43,6 +44,7 @@ TEST(SignalHandlerStackConsumptionTest, MeasuresStackConsumption) {
} // namespace } // namespace
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION #endif // ABSL_INTERNAL_HAVE_DEBUGGING_STACK_CONSUMPTION
...@@ -180,11 +180,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, ...@@ -180,11 +180,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return true; return true;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_AARCH64_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_AARCH64_INL_H_
...@@ -113,11 +113,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, ...@@ -113,11 +113,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return false; return false;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_ARM_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_ARM_INL_H_
...@@ -49,11 +49,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, ...@@ -49,11 +49,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return true; return true;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_GENERIC_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_GENERIC_INL_H_
...@@ -233,11 +233,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, ...@@ -233,11 +233,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return true; return true;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_POWERPC_INL_H_
...@@ -12,11 +12,13 @@ static int UnwindImpl(void** /* result */, int* /* sizes */, ...@@ -12,11 +12,13 @@ static int UnwindImpl(void** /* result */, int* /* sizes */,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return false; return false;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_UNIMPLEMENTED_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_UNIMPLEMENTED_INL_H_
...@@ -73,11 +73,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count, ...@@ -73,11 +73,13 @@ static int UnwindImpl(void** result, int* sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return false; return false;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_WIN32_INL_H_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_WIN32_INL_H_
...@@ -327,11 +327,13 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count, ...@@ -327,11 +327,13 @@ static int UnwindImpl(void **result, int *sizes, int max_depth, int skip_count,
} }
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
bool StackTraceWorksForTest() { bool StackTraceWorksForTest() {
return true; return true;
} }
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_ #endif // ABSL_DEBUGGING_INTERNAL_STACKTRACE_X86_INL_INC_
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <string> #include <string>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// Iterates over all sections, invoking callback on each with the section name // Iterates over all sections, invoking callback on each with the section name
...@@ -52,11 +53,13 @@ bool GetSectionHeaderByName(int fd, const char *name, size_t name_len, ...@@ -52,11 +53,13 @@ bool GetSectionHeaderByName(int fd, const char *name, size_t name_len,
ElfW(Shdr) *out); ElfW(Shdr) *out);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE #endif // ABSL_INTERNAL_HAVE_ELF_SYMBOLIZE
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
struct SymbolDecoratorArgs { struct SymbolDecoratorArgs {
...@@ -118,6 +121,7 @@ bool GetFileMappingHint(const void** start, ...@@ -118,6 +121,7 @@ bool GetFileMappingHint(const void** start,
const char** filename); const char** filename);
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_INTERNAL_SYMBOLIZE_H_ #endif // ABSL_DEBUGGING_INTERNAL_SYMBOLIZE_H_
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
ABSL_CONST_INIT ABSL_CONST_INIT
...@@ -187,6 +188,7 @@ static class VDSOInitHelper { ...@@ -187,6 +188,7 @@ static class VDSOInitHelper {
} vdso_init_helper; } vdso_init_helper;
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_HAVE_VDSO_SUPPORT #endif // ABSL_HAVE_VDSO_SUPPORT
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
// NOTE: this class may be used from within tcmalloc, and can not // NOTE: this class may be used from within tcmalloc, and can not
...@@ -149,6 +150,7 @@ class VDSOSupport { ...@@ -149,6 +150,7 @@ class VDSOSupport {
int GetCPU(); int GetCPU();
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_HAVE_ELF_MEM_IMAGE #endif // ABSL_HAVE_ELF_MEM_IMAGE
......
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
#ifndef LEAK_SANITIZER #ifndef LEAK_SANITIZER
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
bool HaveLeakSanitizer() { return false; } bool HaveLeakSanitizer() { return false; }
void DoIgnoreLeak(const void*) { } void DoIgnoreLeak(const void*) { }
void RegisterLivePointers(const void*, size_t) { } void RegisterLivePointers(const void*, size_t) { }
void UnRegisterLivePointers(const void*, size_t) { } void UnRegisterLivePointers(const void*, size_t) { }
LeakCheckDisabler::LeakCheckDisabler() { } LeakCheckDisabler::LeakCheckDisabler() { }
LeakCheckDisabler::~LeakCheckDisabler() { } LeakCheckDisabler::~LeakCheckDisabler() { }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#else #else
...@@ -33,6 +35,7 @@ LeakCheckDisabler::~LeakCheckDisabler() { } ...@@ -33,6 +35,7 @@ LeakCheckDisabler::~LeakCheckDisabler() { }
#include <sanitizer/lsan_interface.h> #include <sanitizer/lsan_interface.h>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
bool HaveLeakSanitizer() { return true; } bool HaveLeakSanitizer() { return true; }
void DoIgnoreLeak(const void* ptr) { __lsan_ignore_object(ptr); } void DoIgnoreLeak(const void* ptr) { __lsan_ignore_object(ptr); }
void RegisterLivePointers(const void* ptr, size_t size) { void RegisterLivePointers(const void* ptr, size_t size) {
...@@ -43,6 +46,7 @@ void UnRegisterLivePointers(const void* ptr, size_t size) { ...@@ -43,6 +46,7 @@ void UnRegisterLivePointers(const void* ptr, size_t size) {
} }
LeakCheckDisabler::LeakCheckDisabler() { __lsan_disable(); } LeakCheckDisabler::LeakCheckDisabler() { __lsan_disable(); }
LeakCheckDisabler::~LeakCheckDisabler() { __lsan_enable(); } LeakCheckDisabler::~LeakCheckDisabler() { __lsan_enable(); }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // LEAK_SANITIZER #endif // LEAK_SANITIZER
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <cstddef> #include <cstddef>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// HaveLeakSanitizer() // HaveLeakSanitizer()
// //
...@@ -104,6 +105,7 @@ void RegisterLivePointers(const void* ptr, size_t size); ...@@ -104,6 +105,7 @@ void RegisterLivePointers(const void* ptr, size_t size);
// `RegisterLivePointers()`, enabling leak checking of those pointers. // `RegisterLivePointers()`, enabling leak checking of those pointers.
void UnRegisterLivePointers(const void* ptr, size_t size); void UnRegisterLivePointers(const void* ptr, size_t size);
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_LEAK_CHECK_H_ #endif // ABSL_DEBUGGING_LEAK_CHECK_H_
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#endif #endif
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace { namespace {
typedef int (*Unwinder)(void**, int*, int, int, const void*, int*); typedef int (*Unwinder)(void**, int*, int, int, const void*, int*);
...@@ -130,4 +131,5 @@ int DefaultStackUnwinder(void** pcs, int* sizes, int depth, int skip, ...@@ -130,4 +131,5 @@ int DefaultStackUnwinder(void** pcs, int* sizes, int depth, int skip,
return n; return n;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#define ABSL_DEBUGGING_STACKTRACE_H_ #define ABSL_DEBUGGING_STACKTRACE_H_
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// GetStackFrames() // GetStackFrames()
// //
...@@ -220,6 +221,7 @@ namespace debugging_internal { ...@@ -220,6 +221,7 @@ namespace debugging_internal {
// working. // working.
extern bool StackTraceWorksForTest(); extern bool StackTraceWorksForTest();
} // namespace debugging_internal } // namespace debugging_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_STACKTRACE_H_ #endif // ABSL_DEBUGGING_STACKTRACE_H_
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include "absl/debugging/internal/symbolize.h" #include "absl/debugging/internal/symbolize.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// InitializeSymbolizer() // InitializeSymbolizer()
// //
...@@ -92,6 +93,7 @@ void InitializeSymbolizer(const char* argv0); ...@@ -92,6 +93,7 @@ void InitializeSymbolizer(const char* argv0);
// } // }
bool Symbolize(const void *pc, char *out, int out_size); bool Symbolize(const void *pc, char *out, int out_size);
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_DEBUGGING_SYMBOLIZE_H_ #endif // ABSL_DEBUGGING_SYMBOLIZE_H_
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#include "absl/debugging/internal/vdso_support.h" #include "absl/debugging/internal/vdso_support.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// Value of argv[0]. Used by MaybeInitializeObjFile(). // Value of argv[0]. Used by MaybeInitializeObjFile().
static char *argv0_value = nullptr; static char *argv0_value = nullptr;
...@@ -1470,4 +1471,5 @@ bool Symbolize(const void *pc, char *out, int out_size) { ...@@ -1470,4 +1471,5 @@ bool Symbolize(const void *pc, char *out, int out_size) {
return ok; return ok;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace debugging_internal { namespace debugging_internal {
...@@ -32,4 +33,5 @@ bool RegisterFileMappingHint(const void *, const void *, uint64_t, const char *) ...@@ -32,4 +33,5 @@ bool RegisterFileMappingHint(const void *, const void *, uint64_t, const char *)
void InitializeSymbolizer(const char*) {} void InitializeSymbolizer(const char*) {}
bool Symbolize(const void *, char *, int) { return false; } bool Symbolize(const void *, char *, int) { return false; }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
static HANDLE process = NULL; static HANDLE process = NULL;
...@@ -71,4 +72,5 @@ bool Symbolize(const void *pc, char *out, int out_size) { ...@@ -71,4 +72,5 @@ bool Symbolize(const void *pc, char *out, int out_size) {
return true; return true;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -18,6 +18,7 @@ load( ...@@ -18,6 +18,7 @@ load(
"//absl:copts.bzl", "//absl:copts.bzl",
"ABSL_DEFAULT_COPTS", "ABSL_DEFAULT_COPTS",
"ABSL_TEST_COPTS", "ABSL_TEST_COPTS",
"ABSL_EXCEPTIONS_FLAG",
) )
package(default_visibility = ["//visibility:public"]) package(default_visibility = ["//visibility:public"])
...@@ -45,3 +46,16 @@ cc_test( ...@@ -45,3 +46,16 @@ cc_test(
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
], ],
) )
cc_test(
name = "memory_exception_safety_test",
srcs = [
"memory_exception_safety_test.cc",
],
copts = ABSL_TEST_COPTS + ABSL_EXCEPTIONS_FLAG,
deps = [
":memory",
"//absl/base:exception_safety_testing",
"@com_google_googletest//:gtest_main",
],
)
...@@ -49,4 +49,23 @@ absl_test( ...@@ -49,4 +49,23 @@ absl_test(
) )
# test memory_exception_safety_test
set(MEMORY_EXCEPTION_SAFETY_TEST_SRC "memory_exception_safety_test.cc")
set(MEMORY_EXCEPTION_SAFETY_TEST_PUBLIC_LIBRARIES
absl::memory
absl_base_internal_exception_safety_testing
)
absl_test(
TARGET
memory_exception_safety_test
SOURCES
${MEMORY_EXCEPTION_SAFETY_TEST_SRC}
PUBLIC_LIBRARIES
${MEMORY_EXCEPTION_SAFETY_TEST_PUBLIC_LIBRARIES}
PRIVATE_COMPILE_FLAGS
${ABSL_EXCEPTIONS_FLAG}
)
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "absl/meta/type_traits.h" #include "absl/meta/type_traits.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Function Template: WrapUnique() // Function Template: WrapUnique()
...@@ -636,6 +637,7 @@ struct default_allocator_is_nothrow : std::true_type {}; ...@@ -636,6 +637,7 @@ struct default_allocator_is_nothrow : std::true_type {};
struct default_allocator_is_nothrow : std::false_type {}; struct default_allocator_is_nothrow : std::false_type {};
#endif #endif
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_MEMORY_MEMORY_H_ #endif // ABSL_MEMORY_MEMORY_H_
// Copyright 2018 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/memory/memory.h"
#include "gtest/gtest.h"
#include "absl/base/internal/exception_safety_testing.h"
namespace absl {
inline namespace lts_2018_06_20 {
namespace {
using Thrower = ::testing::ThrowingValue<>;
TEST(MakeUnique, CheckForLeaks) {
constexpr int kValue = 321;
constexpr size_t kLength = 10;
auto tester = testing::MakeExceptionSafetyTester()
.WithInitialValue(Thrower(kValue))
// Ensures make_unique does not modify the input. The real
// test, though, is ConstructorTracker checking for leaks.
.WithInvariants(testing::strong_guarantee);
EXPECT_TRUE(tester.Test([](Thrower* thrower) {
static_cast<void>(absl::make_unique<Thrower>(*thrower));
}));
EXPECT_TRUE(tester.Test([](Thrower* thrower) {
static_cast<void>(absl::make_unique<Thrower>(std::move(*thrower)));
}));
// Test T[n] overload
EXPECT_TRUE(tester.Test([&](Thrower*) {
static_cast<void>(absl::make_unique<Thrower[]>(kLength));
}));
}
} // namespace
} // inline namespace lts_2018_06_20
} // namespace absl
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "absl/base/config.h" #include "absl/base/config.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace type_traits_internal { namespace type_traits_internal {
template <typename... Ts> template <typename... Ts>
...@@ -368,5 +369,6 @@ struct IsHashEnabled ...@@ -368,5 +369,6 @@ struct IsHashEnabled
IsHashable<Key>> {}; IsHashable<Key>> {};
} // namespace type_traits_internal } // namespace type_traits_internal
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_META_TYPE_TRAITS_H_ #endif // ABSL_META_TYPE_TRAITS_H_
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <type_traits> #include <type_traits>
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
const uint128 kuint128max = MakeUint128(std::numeric_limits<uint64_t>::max(), const uint128 kuint128max = MakeUint128(std::numeric_limits<uint64_t>::max(),
std::numeric_limits<uint64_t>::max()); std::numeric_limits<uint64_t>::max());
...@@ -222,4 +223,5 @@ std::ostream& operator<<(std::ostream& os, uint128 v) { ...@@ -222,4 +223,5 @@ std::ostream& operator<<(std::ostream& os, uint128 v) {
return os << rep; return os << rep;
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "absl/base/port.h" #include "absl/base/port.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
// uint128 // uint128
...@@ -651,6 +652,7 @@ inline uint128& uint128::operator--() { ...@@ -651,6 +652,7 @@ inline uint128& uint128::operator--() {
#include "absl/numeric/int128_no_intrinsic.inc" #include "absl/numeric/int128_no_intrinsic.inc"
#endif // ABSL_HAVE_INTRINSIC_INT128 #endif // ABSL_HAVE_INTRINSIC_INT128
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_NUMERIC_INT128_H_ #endif // ABSL_NUMERIC_INT128_H_
...@@ -32,7 +32,12 @@ cc_library( ...@@ -32,7 +32,12 @@ cc_library(
name = "strings", name = "strings",
srcs = [ srcs = [
"ascii.cc", "ascii.cc",
"charconv.cc",
"escaping.cc", "escaping.cc",
"internal/charconv_bigint.cc",
"internal/charconv_bigint.h",
"internal/charconv_parse.cc",
"internal/charconv_parse.h",
"internal/memutil.cc", "internal/memutil.cc",
"internal/memutil.h", "internal/memutil.h",
"internal/stl_type_traits.h", "internal/stl_type_traits.h",
...@@ -48,6 +53,7 @@ cc_library( ...@@ -48,6 +53,7 @@ cc_library(
], ],
hdrs = [ hdrs = [
"ascii.h", "ascii.h",
"charconv.h",
"escaping.h", "escaping.h",
"match.h", "match.h",
"numbers.h", "numbers.h",
...@@ -144,11 +150,6 @@ cc_test( ...@@ -144,11 +150,6 @@ cc_test(
size = "small", size = "small",
srcs = ["ascii_test.cc"], srcs = ["ascii_test.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
tags = [
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
],
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
deps = [ deps = [
":strings", ":strings",
...@@ -398,12 +399,6 @@ cc_test( ...@@ -398,12 +399,6 @@ cc_test(
"numbers_test.cc", "numbers_test.cc",
], ],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
tags = [
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
"no_test_loonix",
],
visibility = ["//visibility:private"], visibility = ["//visibility:private"],
deps = [ deps = [
":strings", ":strings",
...@@ -429,11 +424,6 @@ cc_test( ...@@ -429,11 +424,6 @@ cc_test(
name = "char_map_test", name = "char_map_test",
srcs = ["internal/char_map_test.cc"], srcs = ["internal/char_map_test.cc"],
copts = ABSL_TEST_COPTS, copts = ABSL_TEST_COPTS,
tags = [
"no_test_android_arm",
"no_test_android_arm64",
"no_test_android_x86",
],
deps = [ deps = [
":internal", ":internal",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",
...@@ -450,3 +440,55 @@ cc_test( ...@@ -450,3 +440,55 @@ cc_test(
"@com_github_google_benchmark//:benchmark_main", "@com_github_google_benchmark//:benchmark_main",
], ],
) )
cc_test(
name = "charconv_test",
srcs = ["charconv_test.cc"],
copts = ABSL_TEST_COPTS,
deps = [
":strings",
"//absl/base",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "charconv_parse_test",
srcs = [
"internal/charconv_parse.h",
"internal/charconv_parse_test.cc",
],
copts = ABSL_TEST_COPTS,
deps = [
":strings",
"//absl/base",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "charconv_bigint_test",
srcs = [
"internal/charconv_bigint.h",
"internal/charconv_bigint_test.cc",
"internal/charconv_parse.h",
],
copts = ABSL_TEST_COPTS,
deps = [
":strings",
"//absl/base",
"@com_google_googletest//:gtest_main",
],
)
cc_test(
name = "charconv_benchmark",
srcs = [
"charconv_benchmark.cc",
],
deps = [
":strings",
"//absl/base",
"@com_github_google_benchmark//:benchmark_main",
],
)
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
list(APPEND STRINGS_PUBLIC_HEADERS list(APPEND STRINGS_PUBLIC_HEADERS
"ascii.h" "ascii.h"
"charconv.h"
"escaping.h" "escaping.h"
"match.h" "match.h"
"numbers.h" "numbers.h"
...@@ -33,6 +34,8 @@ list(APPEND STRINGS_PUBLIC_HEADERS ...@@ -33,6 +34,8 @@ list(APPEND STRINGS_PUBLIC_HEADERS
list(APPEND STRINGS_INTERNAL_HEADERS list(APPEND STRINGS_INTERNAL_HEADERS
"internal/bits.h" "internal/bits.h"
"internal/char_map.h" "internal/char_map.h"
"internal/charconv_bigint.h"
"internal/charconv_parse.h"
"internal/memutil.h" "internal/memutil.h"
"internal/ostringstream.h" "internal/ostringstream.h"
"internal/resize_uninitialized.h" "internal/resize_uninitialized.h"
...@@ -47,7 +50,10 @@ list(APPEND STRINGS_INTERNAL_HEADERS ...@@ -47,7 +50,10 @@ list(APPEND STRINGS_INTERNAL_HEADERS
# add string library # add string library
list(APPEND STRINGS_SRC list(APPEND STRINGS_SRC
"ascii.cc" "ascii.cc"
"charconv.cc"
"escaping.cc" "escaping.cc"
"internal/charconv_bigint.cc"
"internal/charconv_parse.cc"
"internal/memutil.cc" "internal/memutil.cc"
"internal/memutil.h" "internal/memutil.h"
"internal/utf8.cc" "internal/utf8.cc"
...@@ -301,5 +307,43 @@ absl_test( ...@@ -301,5 +307,43 @@ absl_test(
) )
# test charconv_test
set(CHARCONV_TEST_SRC "charconv_test.cc")
set(CHARCONV_TEST_PUBLIC_LIBRARIES absl::strings)
absl_test(
TARGET
charconv_test
SOURCES
${CHARCONV_TEST_SRC}
PUBLIC_LIBRARIES
${CHARCONV_TEST_PUBLIC_LIBRARIES}
)
# test charconv_parse_test
set(CHARCONV_PARSE_TEST_SRC "internal/charconv_parse_test.cc")
set(CHARCONV_PARSE_TEST_PUBLIC_LIBRARIES absl::strings)
absl_test(
TARGET
charconv_parse_test
SOURCES
${CHARCONV_PARSE_TEST_SRC}
PUBLIC_LIBRARIES
${CHARCONV_PARSE_TEST_PUBLIC_LIBRARIES}
)
# test charconv_bigint_test
set(CHARCONV_BIGINT_TEST_SRC "internal/charconv_bigint_test.cc")
set(CHARCONV_BIGINT_TEST_PUBLIC_LIBRARIES absl::strings)
absl_test(
TARGET
charconv_bigint_test
SOURCES
${CHARCONV_BIGINT_TEST_SRC}
PUBLIC_LIBRARIES
${CHARCONV_BIGINT_TEST_PUBLIC_LIBRARIES}
)
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "absl/strings/ascii.h" #include "absl/strings/ascii.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace ascii_internal { namespace ascii_internal {
// # Table generated by this Python code (bit 0x02 is currently unused): // # Table generated by this Python code (bit 0x02 is currently unused):
...@@ -195,4 +196,5 @@ void RemoveExtraAsciiWhitespace(std::string* str) { ...@@ -195,4 +196,5 @@ void RemoveExtraAsciiWhitespace(std::string* str) {
str->erase(output_it - &(*str)[0]); str->erase(output_it - &(*str)[0]);
} }
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
namespace absl { namespace absl {
inline namespace lts_2018_06_20 {
namespace ascii_internal { namespace ascii_internal {
// Declaration for an array of bitfields holding character information. // Declaration for an array of bitfields holding character information.
...@@ -234,6 +235,7 @@ inline void StripAsciiWhitespace(std::string* str) { ...@@ -234,6 +235,7 @@ inline void StripAsciiWhitespace(std::string* str) {
// Removes leading, trailing, and consecutive internal whitespace. // Removes leading, trailing, and consecutive internal whitespace.
void RemoveExtraAsciiWhitespace(std::string*); void RemoveExtraAsciiWhitespace(std::string*);
} // inline namespace lts_2018_06_20
} // namespace absl } // namespace absl
#endif // ABSL_STRINGS_ASCII_H_ #endif // ABSL_STRINGS_ASCII_H_
// Copyright 2018 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef ABSL_STRINGS_CHARCONV_H_
#define ABSL_STRINGS_CHARCONV_H_
#include <system_error> // NOLINT(build/c++11)
namespace absl {
inline namespace lts_2018_06_20 {
// Workalike compatibilty version of std::chars_format from C++17.
//
// This is an bitfield enumerator which can be passed to absl::from_chars to
// configure the std::string-to-float conversion.
enum class chars_format {
scientific = 1,
fixed = 2,
hex = 4,
general = fixed | scientific,
};
// The return result of a std::string-to-number conversion.
//
// `ec` will be set to `invalid_argument` if a well-formed number was not found
// at the start of the input range, `result_out_of_range` if a well-formed
// number was found, but it was out of the representable range of the requested
// type, or to std::errc() otherwise.
//
// If a well-formed number was found, `ptr` is set to one past the sequence of
// characters that were successfully parsed. If none was found, `ptr` is set
// to the `first` argument to from_chars.
struct from_chars_result {
const char* ptr;
std::errc ec;
};
// Workalike compatibilty version of std::from_chars from C++17. Currently
// this only supports the `double` and `float` types.
//
// This interface incorporates the proposed resolutions for library issues
// DR 3800 and DR 3801. If these are adopted with different wording,
// Abseil's behavior will change to match the standard. (The behavior most
// likely to change is for DR 3801, which says what `value` will be set to in
// the case of overflow and underflow. Code that wants to avoid possible
// breaking changes in this area should not depend on `value` when the returned
// from_chars_result indicates a range error.)
//
// Searches the range [first, last) for the longest matching pattern beginning
// at `first` that represents a floating point number. If one is found, store
// the result in `value`.
//
// The matching pattern format is almost the same as that of strtod(), except
// that C locale is not respected, and an initial '+' character in the input
// range will never be matched.
//
// If `fmt` is set, it must be one of the enumerator values of the chars_format.
// (This is despite the fact that chars_format is a bitmask type.) If set to
// `scientific`, a matching number must contain an exponent. If set to `fixed`,
// then an exponent will never match. (For example, the std::string "1e5" will be
// parsed as "1".) If set to `hex`, then a hexadecimal float is parsed in the
// format that strtod() accepts, except that a "0x" prefix is NOT matched.
// (In particular, in `hex` mode, the input "0xff" results in the largest
// matching pattern "0".)
absl::from_chars_result from_chars(const char* first, const char* last,
double& value, // NOLINT
chars_format fmt = chars_format::general);
absl::from_chars_result from_chars(const char* first, const char* last,
float& value, // NOLINT
chars_format fmt = chars_format::general);
// std::chars_format is specified as a bitmask type, which means the following
// operations must be provided:
inline constexpr chars_format operator&(chars_format lhs, chars_format rhs) {
return static_cast<chars_format>(static_cast<int>(lhs) &
static_cast<int>(rhs));
}
inline constexpr chars_format operator|(chars_format lhs, chars_format rhs) {
return static_cast<chars_format>(static_cast<int>(lhs) |
static_cast<int>(rhs));
}
inline constexpr chars_format operator^(chars_format lhs, chars_format rhs) {
return static_cast<chars_format>(static_cast<int>(lhs) ^
static_cast<int>(rhs));
}
inline constexpr chars_format operator~(chars_format arg) {
return static_cast<chars_format>(~static_cast<int>(arg));
}
inline chars_format& operator&=(chars_format& lhs, chars_format rhs) {
lhs = lhs & rhs;
return lhs;
}
inline chars_format& operator|=(chars_format& lhs, chars_format rhs) {
lhs = lhs | rhs;
return lhs;
}
inline chars_format& operator^=(chars_format& lhs, chars_format rhs) {
lhs = lhs ^ rhs;
return lhs;
}
} // inline namespace lts_2018_06_20
} // namespace absl
#endif // ABSL_STRINGS_CHARCONV_H_
// Copyright 2018 The Abseil Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "absl/strings/charconv.h"
#include <cstdlib>
#include <cstring>
#include <string>
#include "benchmark/benchmark.h"
namespace {
void BM_Strtod_Pi(benchmark::State& state) {
const char* pi = "3.14159";
for (auto s : state) {
benchmark::DoNotOptimize(pi);
benchmark::DoNotOptimize(strtod(pi, nullptr));
}
}
BENCHMARK(BM_Strtod_Pi);
void BM_Absl_Pi(benchmark::State& state) {
const char* pi = "3.14159";
const char* pi_end = pi + strlen(pi);
for (auto s : state) {
benchmark::DoNotOptimize(pi);
double v;
absl::from_chars(pi, pi_end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_Pi);
void BM_Strtod_Pi_float(benchmark::State& state) {
const char* pi = "3.14159";
for (auto s : state) {
benchmark::DoNotOptimize(pi);
benchmark::DoNotOptimize(strtof(pi, nullptr));
}
}
BENCHMARK(BM_Strtod_Pi_float);
void BM_Absl_Pi_float(benchmark::State& state) {
const char* pi = "3.14159";
const char* pi_end = pi + strlen(pi);
for (auto s : state) {
benchmark::DoNotOptimize(pi);
float v;
absl::from_chars(pi, pi_end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_Pi_float);
void BM_Strtod_HardLarge(benchmark::State& state) {
const char* num = "272104041512242479.e200";
for (auto s : state) {
benchmark::DoNotOptimize(num);
benchmark::DoNotOptimize(strtod(num, nullptr));
}
}
BENCHMARK(BM_Strtod_HardLarge);
void BM_Absl_HardLarge(benchmark::State& state) {
const char* numstr = "272104041512242479.e200";
const char* numstr_end = numstr + strlen(numstr);
for (auto s : state) {
benchmark::DoNotOptimize(numstr);
double v;
absl::from_chars(numstr, numstr_end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_HardLarge);
void BM_Strtod_HardSmall(benchmark::State& state) {
const char* num = "94080055902682397.e-242";
for (auto s : state) {
benchmark::DoNotOptimize(num);
benchmark::DoNotOptimize(strtod(num, nullptr));
}
}
BENCHMARK(BM_Strtod_HardSmall);
void BM_Absl_HardSmall(benchmark::State& state) {
const char* numstr = "94080055902682397.e-242";
const char* numstr_end = numstr + strlen(numstr);
for (auto s : state) {
benchmark::DoNotOptimize(numstr);
double v;
absl::from_chars(numstr, numstr_end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_HardSmall);
void BM_Strtod_HugeMantissa(benchmark::State& state) {
std::string huge(200, '3');
const char* num = huge.c_str();
for (auto s : state) {
benchmark::DoNotOptimize(num);
benchmark::DoNotOptimize(strtod(num, nullptr));
}
}
BENCHMARK(BM_Strtod_HugeMantissa);
void BM_Absl_HugeMantissa(benchmark::State& state) {
std::string huge(200, '3');
const char* num = huge.c_str();
const char* num_end = num + 200;
for (auto s : state) {
benchmark::DoNotOptimize(num);
double v;
absl::from_chars(num, num_end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_HugeMantissa);
std::string MakeHardCase(int length) {
// The number 1.1521...e-297 is exactly halfway between 12345 * 2**-1000 and
// the next larger representable number. The digits of this number are in
// the std::string below.
const std::string digits =
"1."
"152113937042223790993097181572444900347587985074226836242307364987727724"
"831384300183638649152607195040591791364113930628852279348613864894524591"
"272746490313676832900762939595690019745859128071117417798540258114233761"
"012939937017879509401007964861774960297319002612457273148497158989073482"
"171377406078223015359818300988676687994537274548940612510414856761641652"
"513434981938564294004070500716200446656421722229202383105446378511678258"
"370570631774499359748259931676320916632111681001853983492795053244971606"
"922718923011680846577744433974087653954904214152517799883551075537146316"
"168973685866425605046988661997658648354773076621610279716804960009043764"
"038392994055171112475093876476783502487512538082706095923790634572014823"
"78877699375152587890625" +
std::string(5000, '0');
// generate the hard cases on either side for the given length.
// Lengths between 3 and 1000 are reasonable.
return digits.substr(0, length) + "1e-297";
}
void BM_Strtod_Big_And_Difficult(benchmark::State& state) {
std::string testcase = MakeHardCase(state.range(0));
const char* begin = testcase.c_str();
for (auto s : state) {
benchmark::DoNotOptimize(begin);
benchmark::DoNotOptimize(strtod(begin, nullptr));
}
}
BENCHMARK(BM_Strtod_Big_And_Difficult)->Range(3, 5000);
void BM_Absl_Big_And_Difficult(benchmark::State& state) {
std::string testcase = MakeHardCase(state.range(0));
const char* begin = testcase.c_str();
const char* end = begin + testcase.size();
for (auto s : state) {
benchmark::DoNotOptimize(begin);
double v;
absl::from_chars(begin, end, v);
benchmark::DoNotOptimize(v);
}
}
BENCHMARK(BM_Absl_Big_And_Difficult)->Range(3, 5000);
} // namespace
// ------------------------------------------------------------------------
// Benchmark Time CPU Iterations
// ------------------------------------------------------------------------
// BM_Strtod_Pi 96 ns 96 ns 6337454
// BM_Absl_Pi 35 ns 35 ns 20031996
// BM_Strtod_Pi_float 91 ns 91 ns 7745851
// BM_Absl_Pi_float 35 ns 35 ns 20430298
// BM_Strtod_HardLarge 133 ns 133 ns 5288341
// BM_Absl_HardLarge 181 ns 181 ns 3855615
// BM_Strtod_HardSmall 279 ns 279 ns 2517243
// BM_Absl_HardSmall 287 ns 287 ns 2458744
// BM_Strtod_HugeMantissa 433 ns 433 ns 1604293
// BM_Absl_HugeMantissa 160 ns 160 ns 4403671
// BM_Strtod_Big_And_Difficult/3 236 ns 236 ns 2942496
// BM_Strtod_Big_And_Difficult/8 232 ns 232 ns 2983796
// BM_Strtod_Big_And_Difficult/64 437 ns 437 ns 1591951
// BM_Strtod_Big_And_Difficult/512 1738 ns 1738 ns 402519
// BM_Strtod_Big_And_Difficult/4096 3943 ns 3943 ns 176128
// BM_Strtod_Big_And_Difficult/5000 4397 ns 4397 ns 157878
// BM_Absl_Big_And_Difficult/3 39 ns 39 ns 17799583
// BM_Absl_Big_And_Difficult/8 43 ns 43 ns 16096859
// BM_Absl_Big_And_Difficult/64 550 ns 550 ns 1259717
// BM_Absl_Big_And_Difficult/512 4167 ns 4167 ns 171414
// BM_Absl_Big_And_Difficult/4096 9160 ns 9159 ns 76297
// BM_Absl_Big_And_Difficult/5000 9738 ns 9738 ns 70140
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