Skip to content

Commit 2885029

Browse files
authored
Update abseil-cpp to a new upstream (#754)
Update to bf7fc9986e20f664958fc227547fd8d2fdcf863e
1 parent cd17b85 commit 2885029

File tree

15 files changed

+488
-180
lines changed

15 files changed

+488
-180
lines changed

Firestore/third_party/abseil-cpp/CMakeLists.txt

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ include(AbseilHelpers)
2626

2727

2828
# config options
29-
set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)")
29+
if (MSVC)
30+
# /wd4005 macro-redefinition
31+
# /wd4068 unknown pragma
32+
# /wd4244 conversion from 'type1' to 'type2'
33+
# /wd4267 conversion from 'size_t' to 'type2'
34+
# /wd4800 force value to bool 'true' or 'false' (performance warning)
35+
add_compile_options(/W3 /WX /wd4005 /wd4068 /wd4244 /wd4267 /wd4800)
36+
add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS)
37+
else()
38+
set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)")
39+
endif()
3040

3141

3242

@@ -48,32 +58,34 @@ list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
4858
set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}")
4959
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ")
5060

61+
# -fexceptions
62+
set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
5163

5264
# find dependencies
5365
## pthread
5466
find_package(Threads REQUIRED)
5567

68+
if(NOT ABSL_CCTZ_TARGET)
69+
set(ABSL_CCTZ_TARGET cctz)
70+
endif()
71+
5672
# commented: used only for standalone test
5773
#add_subdirectory(cctz)
5874
#add_subdirectory(googletest)
75+
check_target(${ABSL_CCTZ_TARGET})
5976

6077
## check targets
61-
check_target(cctz)
62-
check_target(gtest)
63-
check_target(gtest_main)
64-
check_target(gmock)
65-
66-
# -fexceptions
67-
set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}")
68-
69-
# fix stuff
70-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FIX_MSVC} ${CMAKE_CXX_FLAGS}")
71-
72-
list(APPEND ABSL_TEST_COMMON_LIBRARIES
73-
gtest_main
74-
gtest
75-
gmock
76-
${CMAKE_THREAD_LIBS_INIT}
77-
)
78+
if(BUILD_TESTING)
79+
check_target(gtest)
80+
check_target(gtest_main)
81+
check_target(gmock)
82+
83+
list(APPEND ABSL_TEST_COMMON_LIBRARIES
84+
gtest_main
85+
gtest
86+
gmock
87+
${CMAKE_THREAD_LIBS_INIT}
88+
)
89+
endif()
7890

7991
add_subdirectory(absl)

Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ list(APPEND BASE_PUBLIC_HEADERS
2020
"casts.h"
2121
"config.h"
2222
"dynamic_annotations.h"
23+
"log_severity.h"
2324
"macros.h"
2425
"optimization.h"
2526
"policy_checks.h"
@@ -33,17 +34,18 @@ list(APPEND BASE_INTERNAL_HEADERS
3334
"internal/cycleclock.h"
3435
"internal/endian.h"
3536
"internal/exception_testing.h"
37+
"internal/exception_safety_testing.h"
3638
"internal/identity.h"
3739
"internal/invoke.h"
38-
"internal/log_severity.h"
40+
"internal/inline_variable.h"
3941
"internal/low_level_alloc.h"
4042
"internal/low_level_scheduling.h"
41-
"internal/malloc_extension_c.h"
4243
"internal/malloc_extension.h"
4344
"internal/malloc_hook_c.h"
4445
"internal/malloc_hook.h"
4546
"internal/malloc_hook_invoke.h"
4647
"internal/per_thread_tls.h"
48+
"internal/pretty_function.h"
4749
"internal/raw_logging.h"
4850
"internal/scheduling_mode.h"
4951
"internal/spinlock.h"
@@ -58,7 +60,7 @@ list(APPEND BASE_INTERNAL_HEADERS
5860

5961

6062
# absl_base main library
61-
list(APPEND BASE_SRC
63+
list(APPEND BASE_SRC
6264
"internal/cycleclock.cc"
6365
"internal/raw_logging.cc"
6466
"internal/spinlock.cc"
@@ -114,6 +116,28 @@ absl_library(
114116
throw_delegate
115117
)
116118

119+
if(BUILD_TESTING)
120+
# exception-safety testing library
121+
set(EXCEPTION_SAFETY_TESTING_SRC "internal/exception_safety_testing.cc")
122+
set(EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES
123+
${ABSL_TEST_COMMON_LIBRARIES}
124+
absl::base
125+
absl::memory
126+
absl::meta
127+
absl::strings
128+
absl::types
129+
)
130+
131+
absl_library(
132+
TARGET
133+
absl_base_internal_exception_safety_testing
134+
SOURCES
135+
${EXCEPTION_SAFETY_TESTING_SRC}
136+
PUBLIC_LIBRARIES
137+
${EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES}
138+
)
139+
endif()
140+
117141

118142
# dynamic_annotations library
119143
set(DYNAMIC_ANNOTATIONS_SRC "dynamic_annotations.cc")
@@ -212,6 +236,26 @@ absl_test(
212236
)
213237

214238

239+
# test inline_variable_test
240+
list(APPEND INLINE_VARIABLE_TEST_SRC
241+
"internal/inline_variable_testing.h"
242+
"inline_variable_test.cc"
243+
"inline_variable_test_a.cc"
244+
"inline_variable_test_b.cc"
245+
)
246+
247+
set(INLINE_VARIABLE_TEST_PUBLIC_LIBRARIES absl::base)
248+
249+
absl_test(
250+
TARGET
251+
inline_variable_test
252+
SOURCES
253+
${INLINE_VARIABLE_TEST_SRC}
254+
PUBLIC_LIBRARIES
255+
${INLINE_VARIABLE_TEST_PUBLIC_LIBRARIES}
256+
)
257+
258+
215259
# test spinlock_test_common
216260
set(SPINLOCK_TEST_COMMON_SRC "spinlock_test_common.cc")
217261
set(SPINLOCK_TEST_COMMON_PUBLIC_LIBRARIES absl::base absl::synchronization)
@@ -319,6 +363,20 @@ absl_test(
319363
${THREAD_IDENTITY_TEST_PUBLIC_LIBRARIES}
320364
)
321365

366+
#test exceptions_safety_testing_test
367+
set(EXCEPTION_SAFETY_TESTING_TEST_SRC "exception_safety_testing_test.cc")
368+
set(EXCEPTION_SAFETY_TESTING_TEST_PUBLIC_LIBRARIES absl::base absl::memory absl::meta absl::strings absl::optional)
369+
370+
absl_test(
371+
TARGET
372+
absl_exception_safety_testing_test
373+
SOURCES
374+
${EXCEPTION_SAFETY_TESTING_TEST_SRC}
375+
PUBLIC_LIBRARIES
376+
${EXCEPTION_SAFETY_TESTING_TEST_PUBLIC_LIBRARIES}
377+
PRIVATE_COMPILE_FLAGS
378+
${ABSL_EXCEPTIONS_FLAG}
379+
)
322380

323381
# test absl_malloc_extension_system_malloc_test
324382
set(MALLOC_EXTENSION_SYSTEM_MALLOC_TEST_SRC "internal/malloc_extension_test.cc")

Firestore/third_party/abseil-cpp/absl/base/attributes.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@
281281
#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI
282282
#endif
283283

284+
// ABSL_ATTRIBUTE_RETURNS_NONNULL
285+
//
286+
// Tells the compiler that a particular function never returns a null pointer.
287+
#if ABSL_HAVE_ATTRIBUTE(returns_nonnull) || \
288+
(defined(__GNUC__) && \
289+
(__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && \
290+
!defined(__clang__))
291+
#define ABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull))
292+
#else
293+
#define ABSL_ATTRIBUTE_RETURNS_NONNULL
294+
#endif
295+
284296
// ABSL_HAVE_ATTRIBUTE_SECTION
285297
//
286298
// Indicates whether labeled sections are supported. Labeled sections are not
@@ -305,6 +317,7 @@
305317
__attribute__((section(#name))) __attribute__((noinline))
306318
#endif
307319

320+
308321
// ABSL_ATTRIBUTE_SECTION_VARIABLE
309322
//
310323
// Tells the compiler/linker to put a given variable into a section and define
@@ -344,6 +357,7 @@
344357
(reinterpret_cast<void *>(__start_##name))
345358
#define ABSL_ATTRIBUTE_SECTION_STOP(name) \
346359
(reinterpret_cast<void *>(__stop_##name))
360+
347361
#else // !ABSL_HAVE_ATTRIBUTE_SECTION
348362

349363
#define ABSL_HAVE_ATTRIBUTE_SECTION 0
@@ -356,6 +370,7 @@
356370
#define ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name)
357371
#define ABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast<void *>(0))
358372
#define ABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast<void *>(0))
373+
359374
#endif // ABSL_ATTRIBUTE_SECTION
360375

361376
// ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC

Firestore/third_party/abseil-cpp/absl/base/config.h

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@
138138
// supported.
139139
#ifdef ABSL_HAVE_THREAD_LOCAL
140140
#error ABSL_HAVE_THREAD_LOCAL cannot be directly set
141-
#elif !defined(__apple_build_version__) || \
142-
((__apple_build_version__ >= 8000042) && \
143-
!(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0))
141+
#elif (!defined(__apple_build_version__) || \
142+
(__apple_build_version__ >= 8000042)) && \
143+
!(defined(__APPLE__) && TARGET_OS_IPHONE && \
144+
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)
144145
// Notes: Xcode's clang did not support `thread_local` until version
145146
// 8, and even then not for all iOS < 9.0.
146147
#define ABSL_HAVE_THREAD_LOCAL 1
@@ -181,21 +182,21 @@
181182
// __SIZEOF_INT128__ but not all versions actually support __int128.
182183
#ifdef ABSL_HAVE_INTRINSIC_INT128
183184
#error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set
184-
#elif (defined(__clang__) && defined(__SIZEOF_INT128__) && \
185-
!defined(__aarch64__)) || \
186-
(defined(__CUDACC__) && defined(__SIZEOF_INT128__) && \
187-
__CUDACC_VER_MAJOR__ >= 9) || \
188-
(!defined(__clang__) && !defined(__CUDACC__) && defined(__GNUC__) && \
189-
defined(__SIZEOF_INT128__))
185+
#elif defined(__SIZEOF_INT128__)
186+
#if (defined(__clang__) && !defined(__aarch64__)) || \
187+
(defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \
188+
(!defined(__clang__) && !defined(__CUDACC__) && defined(__GNUC__))
190189
#define ABSL_HAVE_INTRINSIC_INT128 1
190+
#elif defined(__CUDACC__)
191191
// __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a
192-
// std::string explaining that it has been removed starting with CUDA 9. We can't
193-
// compare both variants in a single boolean expression because there is no
194-
// short-circuiting in the preprocessor.
195-
#elif defined(__CUDACC__) && defined(__SIZEOF_INT128__) && \
196-
__CUDACC_VER__ >= 7000
192+
// std::string explaining that it has been removed starting with CUDA 9. We use
193+
// nested #ifs because there is no short-circuiting in the preprocessor.
194+
// NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined.
195+
#if __CUDACC_VER__ >= 70000
197196
#define ABSL_HAVE_INTRINSIC_INT128 1
198-
#endif
197+
#endif // __CUDACC_VER__ >= 70000
198+
#endif // defined(__CUDACC__)
199+
#endif // ABSL_HAVE_INTRINSIC_INT128
199200

200201
// ABSL_HAVE_EXCEPTIONS
201202
//
@@ -243,7 +244,7 @@
243244
// Windows _WIN32
244245
// NaCL __native_client__
245246
// AsmJS __asmjs__
246-
// Fuschia __Fuchsia__
247+
// Fuchsia __Fuchsia__
247248
//
248249
// Note that since Android defines both __ANDROID__ and __linux__, one
249250
// may probe for either Linux or Android by simply testing for __linux__.
@@ -254,8 +255,9 @@
254255
// POSIX.1-2001.
255256
#ifdef ABSL_HAVE_MMAP
256257
#error ABSL_HAVE_MMAP cannot be directly set
257-
#elif defined(__linux__) || defined(__APPLE__) || defined(__ros__) || \
258-
defined(__native_client__) || defined(__asmjs__) || defined(__Fuchsia__)
258+
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
259+
defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \
260+
defined(__Fuchsia__)
259261
#define ABSL_HAVE_MMAP 1
260262
#endif
261263

@@ -265,7 +267,8 @@
265267
// functions as defined in POSIX.1-2001.
266268
#ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM
267269
#error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set
268-
#elif defined(__linux__) || defined(__APPLE__) || defined(__ros__)
270+
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
271+
defined(__ros__)
269272
#define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1
270273
#endif
271274

Firestore/third_party/abseil-cpp/absl/base/internal/endian.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#elif defined(__APPLE__)
2323
// Mac OS X / Darwin features
2424
#include <libkern/OSByteOrder.h>
25+
#elif defined(__FreeBSD__)
26+
#include <sys/endian.h>
2527
#elif defined(__GLIBC__)
2628
#include <byteswap.h> // IWYU pragma: export
2729
#endif

Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
#include "absl/base/config.h"
2424
#include "absl/base/internal/atomic_hook.h"
25-
#include "absl/base/internal/log_severity.h"
25+
#include "absl/base/log_severity.h"
2626

2727
// We know how to perform low-level writes to stderr in POSIX and Windows. For
2828
// these platforms, we define the token ABSL_LOW_LEVEL_WRITE_SUPPORTED.
@@ -34,7 +34,8 @@
3434
//
3535
// This preprocessor token is also defined in raw_io.cc. If you need to copy
3636
// this, consider moving both to config.h instead.
37-
#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__)
37+
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \
38+
defined(__Fuchsia__)
3839
#include <unistd.h>
3940

4041

@@ -47,7 +48,7 @@
4748
// ABSL_HAVE_SYSCALL_WRITE is defined when the platform provides the syscall
4849
// syscall(SYS_write, /*int*/ fd, /*char* */ buf, /*size_t*/ len);
4950
// for low level operations that want to avoid libc.
50-
#if defined(__linux__) && !defined(__ANDROID__)
51+
#if (defined(__linux__) || defined(__FreeBSD__)) && !defined(__ANDROID__)
5152
#include <sys/syscall.h>
5253
#define ABSL_HAVE_SYSCALL_WRITE 1
5354
#define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1

Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define ABSL_BASE_INTERNAL_RAW_LOGGING_H_
2121

2222
#include "absl/base/attributes.h"
23-
#include "absl/base/internal/log_severity.h"
23+
#include "absl/base/log_severity.h"
2424
#include "absl/base/macros.h"
2525
#include "absl/base/port.h"
2626

Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ inline void UnalignedStore64(void *p, uint64_t v) {
142142
// and 32-bit values (not 64-bit); older versions either raise a fatal signal,
143143
// do an unaligned read and rotate the words around a bit, or do the reads very
144144
// slowly (trip through kernel mode). There's no simple #define that says just
145-
// ARMv7 or higher, so we have to filter away all ARMv5 and ARMv6
145+
// "ARMv7 or higher", so we have to filter away all ARMv5 and ARMv6
146146
// sub-architectures. Newer gcc (>= 4.6) set an __ARM_FEATURE_ALIGNED #define,
147147
// so in time, maybe we can move on to that.
148148
//

Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h renamed to Firestore/third_party/abseil-cpp/absl/base/log_severity.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
1717
#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
1818

19+
#include <array>
20+
1921
#include "absl/base/attributes.h"
2022

2123
namespace absl {
@@ -27,6 +29,13 @@ enum class LogSeverity : int {
2729
kFatal = 3,
2830
};
2931

32+
// Returns an iterable of all standard `absl::LogSeverity` values, ordered from
33+
// least to most severe.
34+
constexpr std::array<absl::LogSeverity, 4> LogSeverities() {
35+
return {{absl::LogSeverity::kInfo, absl::LogSeverity::kWarning,
36+
absl::LogSeverity::kError, absl::LogSeverity::kFatal}};
37+
}
38+
3039
constexpr const char* LogSeverityName(absl::LogSeverity s) {
3140
return s == absl::LogSeverity::kInfo
3241
? "INFO"
@@ -37,7 +46,7 @@ constexpr const char* LogSeverityName(absl::LogSeverity s) {
3746
: s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
3847
}
3948

40-
// Note that out-of-range large severities normalize to kError, not kFatal.
49+
// Note that out-of-range severities normalize to kInfo or kError, never kFatal.
4150
constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) {
4251
return s < absl::LogSeverity::kInfo
4352
? absl::LogSeverity::kInfo

0 commit comments

Comments
 (0)