summaryrefslogtreecommitdiff
path: root/absl/base
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/BUILD.bazel7
-rw-r--r--absl/base/attributes.h226
-rw-r--r--absl/base/call_once.h4
-rw-r--r--absl/base/call_once_test.cc4
-rw-r--r--absl/base/config_test.cc1
-rw-r--r--absl/base/dynamic_annotations.h2
-rw-r--r--absl/base/internal/atomic_hook.h2
-rw-r--r--absl/base/internal/endian_test.cc2
-rw-r--r--absl/base/internal/low_level_alloc.cc10
-rw-r--r--absl/base/internal/low_level_alloc.h2
-rw-r--r--absl/base/internal/low_level_alloc_test.cc2
-rw-r--r--absl/base/internal/low_level_scheduling.h2
-rw-r--r--absl/base/internal/malloc_extension.cc3
-rw-r--r--absl/base/internal/malloc_extension.h7
-rw-r--r--absl/base/internal/malloc_hook.cc7
-rw-r--r--absl/base/internal/raw_logging.cc9
-rw-r--r--absl/base/internal/raw_logging.h1
-rw-r--r--absl/base/internal/spinlock.cc2
-rw-r--r--absl/base/internal/spinlock.h6
-rw-r--r--absl/base/internal/spinlock_wait.h1
-rw-r--r--absl/base/internal/sysinfo.cc1
-rw-r--r--absl/base/internal/thread_identity_test.cc1
-rw-r--r--absl/base/internal/unscaledcycleclock.h1
-rw-r--r--absl/base/invoke_test.cc1
-rw-r--r--absl/base/spinlock_test_common.cc2
-rw-r--r--absl/base/throw_delegate_test.cc1
26 files changed, 199 insertions, 108 deletions
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index 87a6d3e6..2e023ef2 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -121,6 +121,7 @@ cc_library(
":config",
":core_headers",
":dynamic_annotations",
+ ":spinlock_wait",
],
)
@@ -192,6 +193,7 @@ cc_library(
deps = [
":base",
":config",
+ ":core_headers",
],
)
@@ -236,6 +238,8 @@ cc_library(
copts = ABSL_TEST_COPTS,
deps = [
":base",
+ ":core_headers",
+ ":spinlock_wait",
"//absl/synchronization",
"@com_google_googletest//:gtest",
],
@@ -249,6 +253,8 @@ cc_test(
copts = ABSL_TEST_COPTS,
deps = [
":base",
+ ":core_headers",
+ ":spinlock_wait",
"//absl/synchronization",
"@com_google_googletest//:gtest_main",
],
@@ -342,6 +348,7 @@ cc_test(
}),
deps = [
":base",
+ ":core_headers",
"//absl/synchronization",
] + select(GUNIT_MAIN_DEPS_SELECTOR),
)
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 5eecdabe..c2155a4e 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -12,39 +12,61 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//
-// Various macros for C++ attributes
+// This header file defines macros for declaring attributes for functions,
+// types, and variables.
+//
+// These macros are used within Abseil and allow the compiler to optimize, where
+// applicable, certain function calls.
+//
// This file is used for both C and C++!
//
// Most macros here are exposing GCC or Clang features, and are stubbed out for
// other compilers.
+//
// GCC attributes documentation:
-// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html
-// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Variable-Attributes.html
-// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Type-Attributes.html
-//
-// Most attributes in this file are already supported by GCC 4.7.
-// However, some of them are not supported in older version of Clang.
-// Thus, we check __has_attribute() first. If the check fails, we check if we
-// are on GCC and assume the attribute exists on GCC (which is verified on GCC
-// 4.7).
-//
-// For sanitizer-related attributes, define the following macros
-// using -D along with the given value for -fsanitize:
-// - ADDRESS_SANITIZER with -fsanitize=address (GCC 4.8+, Clang)
-// - MEMORY_SANITIZER with -fsanitize=memory (Clang)
-// - THREAD_SANITIZER with -fsanitize=thread (GCC 4.8+, Clang)
-// - UNDEFINED_BEHAVIOR_SANITIZER with -fsanitize=undefined (GCC 4.9+, Clang)
-// - CONTROL_FLOW_INTEGRITY with -fsanitize=cfi (Clang)
-// Since these are only supported by GCC and Clang now, we only check for
-// __GNUC__ (GCC or Clang) and the above macros.
+// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html
+// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Variable-Attributes.html
+// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Type-Attributes.html
+//
+// Most attributes in this file are already supported by GCC 4.7. However, some
+// of them are not supported in older version of Clang. Thus, we check
+// `__has_attribute()` first. If the check fails, we check if we are on GCC and
+// assume the attribute exists on GCC (which is verified on GCC 4.7).
+//
+// -----------------------------------------------------------------------------
+// Sanitizer Attributes
+// -----------------------------------------------------------------------------
+//
+// Sanitizer-related attributes are not "defined" in this file (and indeed
+// are not defined as such in any file). To utilize the following
+// sanitizer-related attributes within your builds, define the following macros
+// within your build using a `-D` flag, along with the given value for
+// `-fsanitize`:
+//
+// * `ADDRESS_SANITIZER` + `-fsanitize=address` (Clang, GCC 4.8)
+// * `MEMORY_SANITIZER` + `-fsanitize=memory` (Clang-only)
+// * `THREAD_SANITIZER + `-fsanitize=thread` (Clang, GCC 4.8+)
+// * `UNDEFINED_BEHAVIOR_SANITIZER` + `-fsanitize=undefined` (Clang, GCC 4.9+)
+// * `CONTROL_FLOW_INTEGRITY` + -fsanitize=cfi (Clang-only)
+//
+// Example:
+//
+// // Enable branches in the Abseil code that are tagged for ASan:
+// $ bazel -D ADDRESS_SANITIZER -fsanitize=address *target*
+//
+// Since these macro names are only supported by GCC and Clang, we only check
+// for `__GNUC__` (GCC or Clang) and the above macros.
#ifndef ABSL_BASE_ATTRIBUTES_H_
#define ABSL_BASE_ATTRIBUTES_H_
-// ABSL_HAVE_ATTRIBUTE is a function-like feature checking macro.
-// It's a wrapper around __has_attribute, which is defined by GCC 5+ and Clang.
-// It evaluates to a nonzero constant integer if the attribute is supported
-// or 0 if not.
-// It evaluates to zero if __has_attribute is not defined by the compiler.
+// ABSL_HAVE_ATTRIBUTE
+//
+// A function-like feature checking macro that is a wrapper around
+// `__has_attribute`, which is defined by GCC 5+ and Clang and evaluates to a
+// nonzero constant integer if the attribute is supported or 0 if not.
+//
+// It evaluates to zero if `__has_attribute` is not defined by the compiler.
+//
// GCC: https://gcc.gnu.org/gcc-5/changes.html
// Clang: https://clang.llvm.org/docs/LanguageExtensions.html
#ifdef __has_attribute
@@ -53,11 +75,12 @@
#define ABSL_HAVE_ATTRIBUTE(x) 0
#endif
-// ABSL_HAVE_CPP_ATTRIBUTE is a function-like feature checking macro that
-// accepts C++11 style attributes. It's a wrapper around __has_cpp_attribute,
-// defined by ISO C++ SD-6
+// ABSL_HAVE_CPP_ATTRIBUTE
+//
+// A function-like feature checking macro that accepts C++11 style attributes.
+// It's a wrapper around `__has_cpp_attribute`, defined by ISO C++ SD-6
// (http://en.cppreference.com/w/cpp/experimental/feature_test). If we don't
-// find __has_cpp_attribute, will evaluate to 0.
+// find `__has_cpp_attribute`, will evaluate to 0.
#if defined(__cplusplus) && defined(__has_cpp_attribute)
// NOTE: requiring __cplusplus above should not be necessary, but
// works around https://bugs.llvm.org/show_bug.cgi?id=23435.
@@ -69,15 +92,18 @@
// -----------------------------------------------------------------------------
// Function Attributes
// -----------------------------------------------------------------------------
+//
// GCC: https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
// Clang: https://clang.llvm.org/docs/AttributeReference.html
-// ABSL_PRINTF_ATTRIBUTE, ABSL_SCANF_ATTRIBUTE
-// Tell the compiler to do printf format std::string checking if the
+// ABSL_PRINTF_ATTRIBUTE
+// ABSL_SCANF_ATTRIBUTE
+//
+// Tells the compiler to perform `printf` format std::string checking if the
// compiler supports it; see the 'format' attribute in
// <http://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html>.
//
-// N.B.: As the GCC manual states, "[s]ince non-static C++ methods
+// Note: As the GCC manual states, "[s]ince non-static C++ methods
// have an implicit 'this' argument, the arguments of such methods
// should be counted from two, not one."
#if ABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__))
@@ -90,9 +116,10 @@
#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check)
#endif
-// ABSL_ATTRIBUTE_ALWAYS_INLINE, ABSL_ATTRIBUTE_NOINLINE
-// For functions we want to force inline or not inline.
-// Introduced in gcc 3.1.
+// ABSL_ATTRIBUTE_ALWAYS_INLINE
+// ABSL_ATTRIBUTE_NOINLINE
+//
+// Forces functions to either inline or not inline. Introduced in gcc 3.1.
#if ABSL_HAVE_ATTRIBUTE(always_inline) || \
(defined(__GNUC__) && !defined(__clang__))
#define ABSL_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline))
@@ -109,7 +136,8 @@
#endif
// ABSL_ATTRIBUTE_NO_TAIL_CALL
-// Prevent the compiler from optimizing away stack frames for functions which
+//
+// Prevents the compiler from optimizing away stack frames for functions which
// end in a call to another function.
#if ABSL_HAVE_ATTRIBUTE(disable_tail_calls)
#define ABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 1
@@ -122,8 +150,10 @@
#define ABSL_ATTRIBUTE_NO_TAIL_CALL
#define ABSL_HAVE_ATTRIBUTE_NO_TAIL_CALL 0
#endif
+
// ABSL_ATTRIBUTE_WEAK
-// For weak functions
+//
+// Tags a function as weak for the purposes of compilation and linking.
#if ABSL_HAVE_ATTRIBUTE(weak) || (defined(__GNUC__) && !defined(__clang__))
#undef ABSL_ATTRIBUTE_WEAK
#define ABSL_ATTRIBUTE_WEAK __attribute__((weak))
@@ -132,9 +162,11 @@
#define ABSL_ATTRIBUTE_WEAK
#define ABSL_HAVE_ATTRIBUTE_WEAK 0
#endif
+
// ABSL_ATTRIBUTE_NONNULL
-// Tell the compiler either that a particular function parameter
-// should be a non-null pointer, or that all pointer arguments should
+//
+// Tells the compiler either (a) that a particular function parameter
+// should be a non-null pointer, or (b) that all pointer arguments should
// be non-null.
//
// Note: As the GCC manual states, "[s]ince non-static C++ methods
@@ -142,10 +174,13 @@
// should be counted from two, not one."
//
// Args are indexed starting at 1.
-// For non-static class member functions, the implicit "this" argument
-// is arg 1, and the first explicit argument is arg 2.
-// For static class member functions, there is no implicit "this", and
-// the first explicit argument is arg 1.
+//
+// For non-static class member functions, the implicit `this` argument
+// is arg 1, and the first explicit argument is arg 2. For static class member
+// functions, there is no implicit `this`, and the first explicit argument is
+// arg 1.
+//
+// Example:
//
// /* arg_a cannot be null, but arg_b can */
// void Function(void* arg_a, void* arg_b) ABSL_ATTRIBUTE_NONNULL(1);
@@ -171,8 +206,10 @@
#else
#define ABSL_ATTRIBUTE_NONNULL(...)
#endif
+
// ABSL_ATTRIBUTE_NORETURN
-// Tell the compiler that a given function never returns
+//
+// Tells the compiler that a given function never returns.
#if ABSL_HAVE_ATTRIBUTE(noreturn) || (defined(__GNUC__) && !defined(__clang__))
#define ABSL_ATTRIBUTE_NORETURN __attribute__((noreturn))
#elif defined(_MSC_VER)
@@ -180,8 +217,10 @@
#else
#define ABSL_ATTRIBUTE_NORETURN
#endif
+
// ABSL_ATTRIBUTE_NO_SANITIZE_ADDRESS
-// Tell AddressSanitizer (or other memory testing tools) to ignore a given
+//
+// Tells the AddressSanitizer (or other memory testing tools) to ignore a given
// function. Useful for cases when a function reads random locations on stack,
// calls _exit from a cloned subprocess, deliberately accesses buffer
// out of bounds or does other scary things with memory.
@@ -194,11 +233,12 @@
#endif
// ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY
-// Tell MemorySanitizer to relax the handling of a given function. All "Use of
-// uninitialized value" warnings from such functions will be suppressed, and all
-// values loaded from memory will be considered fully initialized.
-// This is similar to the ADDRESS_SANITIZER attribute above, but deals with
-// initializedness rather than addressability issues.
+//
+// Tells the MemorySanitizer to relax the handling of a given function. All
+// "Use of uninitialized value" warnings from such functions will be suppressed,
+// and all values loaded from memory will be considered fully initialized.
+// This attribute is similar to the ADDRESS_SANITIZER attribute above, but deals
+// with initialized-ness rather than addressability issues.
// NOTE: MemorySanitizer(msan) is supported by Clang but not GCC.
#if defined(__GNUC__) && defined(MEMORY_SANITIZER)
#define ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY __attribute__((no_sanitize_memory))
@@ -207,8 +247,8 @@
#endif
// ABSL_ATTRIBUTE_NO_SANITIZE_THREAD
-// Tell ThreadSanitizer to not instrument a given function.
-// If you are adding this attribute, please cc dynamic-tools@ on the cl.
+//
+// Tells the ThreadSanitizer to not instrument a given function.
// NOTE: GCC supports ThreadSanitizer(tsan) since 4.8.
// https://gcc.gnu.org/gcc-4.8/changes.html
#if defined(__GNUC__) && defined(THREAD_SANITIZER)
@@ -218,7 +258,8 @@
#endif
// ABSL_ATTRIBUTE_NO_SANITIZE_UNDEFINED
-// Tell UndefinedSanitizer to ignore a given function. Useful for cases
+//
+// Tells the UndefinedSanitizer to ignore a given function. Useful for cases
// where certain behavior (eg. devision by zero) is being used intentionally.
// NOTE: GCC supports UndefinedBehaviorSanitizer(ubsan) since 4.9.
// https://gcc.gnu.org/gcc-4.9/changes.html
@@ -231,7 +272,8 @@
#endif
// ABSL_ATTRIBUTE_NO_SANITIZE_CFI
-// Tell ControlFlowIntegrity sanitizer to not instrument a given function.
+//
+// Tells the ControlFlowIntegrity sanitizer to not instrument a given function.
// See https://clang.llvm.org/docs/ControlFlowIntegrity.html for details.
#if defined(__GNUC__) && defined(CONTROL_FLOW_INTEGRITY)
#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI __attribute__((no_sanitize("cfi")))
@@ -239,33 +281,42 @@
#define ABSL_ATTRIBUTE_NO_SANITIZE_CFI
#endif
-// ABSL_ATTRIBUTE_SECTION
-// Labeled sections are not supported on Darwin/iOS.
+// ABSL_HAVE_ATTRIBUTE_SECTION
+//
+// Indicates whether labeled sections are supported. Labeled sections are not
+// supported on Darwin/iOS.
#ifdef ABSL_HAVE_ATTRIBUTE_SECTION
#error ABSL_HAVE_ATTRIBUTE_SECTION cannot be directly set
#elif (ABSL_HAVE_ATTRIBUTE(section) || \
(defined(__GNUC__) && !defined(__clang__))) && \
!defined(__APPLE__)
#define ABSL_HAVE_ATTRIBUTE_SECTION 1
+
+// ABSL_ATTRIBUTE_SECTION
//
-// Tell the compiler/linker to put a given function into a section and define
-// "__start_ ## name" and "__stop_ ## name" symbols to bracket the section.
-// This functionality is supported by GNU linker.
-// Any function with ABSL_ATTRIBUTE_SECTION must not be inlined, or it will
-// be placed into whatever section its caller is placed into.
+// Tells the compiler/linker to put a given function into a section and define
+// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section.
+// This functionality is supported by GNU linker. Any function annotated with
+// `ABSL_ATTRIBUTE_SECTION` must not be inlined, or it will be placed into
+// whatever section its caller is placed into.
//
#ifndef ABSL_ATTRIBUTE_SECTION
#define ABSL_ATTRIBUTE_SECTION(name) \
__attribute__((section(#name))) __attribute__((noinline))
#endif
-// Tell the compiler/linker to put a given variable into a section and define
-// "__start_ ## name" and "__stop_ ## name" symbols to bracket the section.
+
+// ABSL_ATTRIBUTE_SECTION_VARIABLE
+//
+// Tells the compiler/linker to put a given variable into a section and define
+// `__start_ ## name` and `__stop_ ## name` symbols to bracket the section.
// This functionality is supported by GNU linker.
#ifndef ABSL_ATTRIBUTE_SECTION_VARIABLE
#define ABSL_ATTRIBUTE_SECTION_VARIABLE(name) __attribute__((section(#name)))
#endif
+
+// ABSL_DECLARE_ATTRIBUTE_SECTION_VARS
//
-// Weak section declaration to be used as a global declaration
+// A weak section declaration to be used as a global declaration
// for ABSL_ATTRIBUTE_SECTION_START|STOP(name) to compile and link
// even without functions with ABSL_ATTRIBUTE_SECTION(name).
// ABSL_DEFINE_ATTRIBUTE_SECTION should be in the exactly one file; it's
@@ -281,7 +332,9 @@
#define ABSL_DEFINE_ATTRIBUTE_SECTION_VARS(name)
#endif
-// Return void* pointers to start/end of a section of code with
+// ABSL_ATTRIBUTE_SECTION_START
+//
+// Returns `void*` pointers to start/end of a section of code with
// functions having ABSL_ATTRIBUTE_SECTION(name).
// Returns 0 if no such functions exist.
// One must ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) for this to compile and
@@ -306,6 +359,7 @@
#endif // ABSL_ATTRIBUTE_SECTION
// ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC
+//
// Support for aligning the stack on 32-bit x86.
#if ABSL_HAVE_ATTRIBUTE(force_align_arg_pointer) || \
(defined(__GNUC__) && !defined(__clang__))
@@ -326,10 +380,13 @@
#endif
// ABSL_MUST_USE_RESULT
-// Tell the compiler to warn about unused return values for functions declared
+//
+// Tells the compiler to warn about unused return values for functions declared
// with this macro. The macro must appear as the very first part of a function
// declaration or definition:
//
+// Example:
+//
// ABSL_MUST_USE_RESULT Sprocket* AllocateSprocket();
//
// This placement has the broadest compatibility with GCC, Clang, and MSVC, with
@@ -350,10 +407,14 @@
#endif
// ABSL_ATTRIBUTE_HOT, ABSL_ATTRIBUTE_COLD
-// Tell GCC that a function is hot or cold. GCC can use this information to
+//
+// Tells GCC that a function is hot or cold. GCC can use this information to
// improve static analysis, i.e. a conditional branch to a cold function
// is likely to be not-taken.
-// This annotation is used for function declarations, e.g.:
+// This annotation is used for function declarations.
+//
+// Example:
+//
// int foo() ABSL_ATTRIBUTE_HOT;
#if ABSL_HAVE_ATTRIBUTE(hot) || (defined(__GNUC__) && !defined(__clang__))
#define ABSL_ATTRIBUTE_HOT __attribute__((hot))
@@ -382,12 +443,12 @@
//
// These attributes only take effect when the following conditions are met:
//
-// - The file/target is built in at least C++11 mode, with a Clang compiler
-// that supports XRay attributes.
-// - The file/target is built with the -fxray-instrument flag set for the
-// Clang/LLVM compiler.
-// - The function is defined in the translation unit (the compiler honors the
-// attribute in either the definition or the declaration, and must match).
+// * The file/target is built in at least C++11 mode, with a Clang compiler
+// that supports XRay attributes.
+// * The file/target is built with the -fxray-instrument flag set for the
+// Clang/LLVM compiler.
+// * The function is defined in the translation unit (the compiler honors the
+// attribute in either the definition or the declaration, and must match).
//
// There are cases when, even when building with XRay instrumentation, users
// might want to control specifically which functions are instrumented for a
@@ -422,7 +483,8 @@
// -----------------------------------------------------------------------------
// ABSL_ATTRIBUTE_UNUSED
-// Prevent the compiler from complaining about or optimizing away variables
+//
+// Prevents the compiler from complaining about or optimizing away variables
// that appear unused.
#if ABSL_HAVE_ATTRIBUTE(unused) || (defined(__GNUC__) && !defined(__clang__))
#undef ABSL_ATTRIBUTE_UNUSED
@@ -430,8 +492,10 @@
#else
#define ABSL_ATTRIBUTE_UNUSED
#endif
+
// ABSL_ATTRIBUTE_INITIAL_EXEC
-// Tell the compiler to use "initial-exec" mode for a thread-local variable.
+//
+// Tells the compiler to use "initial-exec" mode for a thread-local variable.
// See http://people.redhat.com/drepper/tls.pdf for the gory details.
#if ABSL_HAVE_ATTRIBUTE(tls_model) || (defined(__GNUC__) && !defined(__clang__))
#define ABSL_ATTRIBUTE_INITIAL_EXEC __attribute__((tls_model("initial-exec")))
@@ -440,7 +504,8 @@
#endif
// ABSL_ATTRIBUTE_PACKED
-// Prevent the compiler from padding a structure to natural alignment
+//
+// Prevents the compiler from padding a structure to natural alignment
#if ABSL_HAVE_ATTRIBUTE(packed) || (defined(__GNUC__) && !defined(__clang__))
#define ABSL_ATTRIBUTE_PACKED __attribute__((__packed__))
#else
@@ -448,15 +513,16 @@
#endif
// ABSL_CONST_INIT
-// A variable declaration annotated with the ABSL_CONST_INIT attribute will
+//
+// A variable declaration annotated with the `ABSL_CONST_INIT` attribute will
// not compile (on supported platforms) unless the variable has a constant
// initializer. This is useful for variables with static and thread storage
// duration, because it guarantees that they will not suffer from the so-called
// "static init order fiasco".
//
-// Sample usage:
+// Example:
//
-// ABSL_CONST_INIT static MyType my_var = MakeMyType(...);
+// ABSL_CONST_INIT static MyType my_var = MakeMyType(...);
//
// Note that this attribute is redundant if the variable is declared constexpr.
#if ABSL_HAVE_CPP_ATTRIBUTE(clang::require_constant_initialization)
diff --git a/absl/base/call_once.h b/absl/base/call_once.h
index 478a41c1..5d823a11 100644
--- a/absl/base/call_once.h
+++ b/absl/base/call_once.h
@@ -25,6 +25,7 @@
#ifndef ABSL_BASE_CALL_ONCE_H_
#define ABSL_BASE_CALL_ONCE_H_
+#include <algorithm>
#include <atomic>
#include <cstdint>
#include <type_traits>
@@ -32,7 +33,10 @@
#include "absl/base/internal/invoke.h"
#include "absl/base/internal/low_level_scheduling.h"
#include "absl/base/internal/raw_logging.h"
+#include "absl/base/internal/scheduling_mode.h"
#include "absl/base/internal/spinlock_wait.h"
+#include "absl/base/macros.h"
+#include "absl/base/port.h"
namespace absl {
diff --git a/absl/base/call_once_test.cc b/absl/base/call_once_test.cc
index de235432..cd58ee19 100644
--- a/absl/base/call_once_test.cc
+++ b/absl/base/call_once_test.cc
@@ -14,12 +14,12 @@
#include "absl/base/call_once.h"
-#include <atomic>
#include <thread>
+#include <vector>
+#include "gtest/gtest.h"
#include "absl/base/thread_annotations.h"
#include "absl/synchronization/mutex.h"
-#include "gtest/gtest.h"
namespace absl {
namespace {
diff --git a/absl/base/config_test.cc b/absl/base/config_test.cc
index 578bb810..ab04b447 100644
--- a/absl/base/config_test.cc
+++ b/absl/base/config_test.cc
@@ -16,7 +16,6 @@
#include <cstdint>
-#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace {
diff --git a/absl/base/dynamic_annotations.h b/absl/base/dynamic_annotations.h
index b9c015ba..3b6d6ef4 100644
--- a/absl/base/dynamic_annotations.h
+++ b/absl/base/dynamic_annotations.h
@@ -298,7 +298,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
while still letting the compiler elide the functions from the final build.
TODO(delesley) -- The exclusive lock here ignores writes as well, but
- allows INGORE_READS_AND_WRITES to work properly. */
+ allows IGNORE_READS_AND_WRITES to work properly. */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
static inline void StaticAnnotateIgnoreReadsBegin(const char *file, int line)
diff --git a/absl/base/internal/atomic_hook.h b/absl/base/internal/atomic_hook.h
index 8eee367e..1f9a8102 100644
--- a/absl/base/internal/atomic_hook.h
+++ b/absl/base/internal/atomic_hook.h
@@ -16,8 +16,8 @@
#ifndef ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_
#define ABSL_BASE_INTERNAL_ATOMIC_HOOK_H_
-#include <cassert>
#include <atomic>
+#include <cassert>
#include <utility>
namespace absl {
diff --git a/absl/base/internal/endian_test.cc b/absl/base/internal/endian_test.cc
index 6812214e..f3ff4b39 100644
--- a/absl/base/internal/endian_test.cc
+++ b/absl/base/internal/endian_test.cc
@@ -16,13 +16,11 @@
#include <algorithm>
#include <cstdint>
-#include <cstdio>
#include <limits>
#include <random>
#include <vector>
#include "gtest/gtest.h"
-#include "absl/base/casts.h"
#include "absl/base/config.h"
namespace absl {
diff --git a/absl/base/internal/low_level_alloc.cc b/absl/base/internal/low_level_alloc.cc
index c55201b3..08f89ea9 100644
--- a/absl/base/internal/low_level_alloc.cc
+++ b/absl/base/internal/low_level_alloc.cc
@@ -17,17 +17,19 @@
// This allocator is slow and wasteful of memory;
// it should not be used when performance is key.
-#include "absl/base/config.h"
-
#include "absl/base/internal/low_level_alloc.h"
+#include "absl/base/config.h"
+#include "absl/base/internal/scheduling_mode.h"
+#include "absl/base/macros.h"
+#include "absl/base/thread_annotations.h"
+
// LowLevelAlloc requires that the platform support low-level
// allocation of virtual memory. Platforms lacking this cannot use
// LowLevelAlloc.
#ifndef ABSL_LOW_LEVEL_ALLOC_MISSING
#ifndef _WIN32
-#include <pthread.h>
#include <signal.h>
#include <sys/mman.h>
#include <unistd.h>
@@ -38,8 +40,8 @@
#include <string.h>
#include <algorithm>
#include <atomic>
-#include <cstddef>
#include <cerrno>
+#include <cstddef>
#include <new> // for placement-new
#include "absl/base/dynamic_annotations.h"
diff --git a/absl/base/internal/low_level_alloc.h b/absl/base/internal/low_level_alloc.h
index d6eb813f..f3e8aa57 100644
--- a/absl/base/internal/low_level_alloc.h
+++ b/absl/base/internal/low_level_alloc.h
@@ -24,8 +24,10 @@
// IWYU pragma: private, include "base/low_level_alloc.h"
+#include <sys/types.h>
#include <cstdint>
+#include "absl/base/attributes.h"
#include "absl/base/config.h"
// LowLevelAlloc requires that the platform support low-level
diff --git a/absl/base/internal/low_level_alloc_test.cc b/absl/base/internal/low_level_alloc_test.cc
index 5f60c3d9..2935760d 100644
--- a/absl/base/internal/low_level_alloc_test.cc
+++ b/absl/base/internal/low_level_alloc_test.cc
@@ -14,10 +14,12 @@
#include "absl/base/internal/low_level_alloc.h"
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <thread> // NOLINT(build/c++11)
#include <unordered_map>
+#include <utility>
#include "absl/base/internal/malloc_hook.h"
diff --git a/absl/base/internal/low_level_scheduling.h b/absl/base/internal/low_level_scheduling.h
index b9501076..a01d1c03 100644
--- a/absl/base/internal/low_level_scheduling.h
+++ b/absl/base/internal/low_level_scheduling.h
@@ -30,8 +30,8 @@ extern "C" void __google_enable_rescheduling(bool disable_result);
namespace absl {
namespace base_internal {
-class SpinLock; // To allow use of SchedulingGuard.
class SchedulingHelper; // To allow use of SchedulingGuard.
+class SpinLock; // To allow use of SchedulingGuard.
// SchedulingGuard
// Provides guard semantics that may be used to disable cooperative rescheduling
diff --git a/absl/base/internal/malloc_extension.cc b/absl/base/internal/malloc_extension.cc
index daf4bc32..3da981ce 100644
--- a/absl/base/internal/malloc_extension.cc
+++ b/absl/base/internal/malloc_extension.cc
@@ -15,15 +15,12 @@
#include "absl/base/internal/malloc_extension.h"
#include <assert.h>
-#include <stdint.h>
-#include <stdio.h>
#include <string.h>
#include <atomic>
#include <string>
#include "absl/base/dynamic_annotations.h"
#include "absl/base/internal/malloc_extension_c.h"
-#include "absl/base/port.h"
namespace absl {
namespace base_internal {
diff --git a/absl/base/internal/malloc_extension.h b/absl/base/internal/malloc_extension.h
index dee4116b..46b767ff 100644
--- a/absl/base/internal/malloc_extension.h
+++ b/absl/base/internal/malloc_extension.h
@@ -25,14 +25,15 @@
#ifndef ABSL_BASE_INTERNAL_MALLOC_EXTENSION_H_
#define ABSL_BASE_INTERNAL_MALLOC_EXTENSION_H_
+#include <stddef.h>
+#include <stdint.h>
#include <atomic>
#include <map>
#include <memory>
+#include <string>
#include <vector>
-#include <stddef.h>
-#include <stdint.h>
-#include <string>
+#include "absl/base/attributes.h"
#include "absl/base/macros.h"
#include "absl/base/port.h"
namespace absl {
diff --git a/absl/base/internal/malloc_hook.cc b/absl/base/internal/malloc_hook.cc
index d5d227a5..4f5a0bef 100644
--- a/absl/base/internal/malloc_hook.cc
+++ b/absl/base/internal/malloc_hook.cc
@@ -23,16 +23,17 @@
#undef mremap
#endif
+#include "absl/base/internal/malloc_hook.h"
+
+#include <algorithm>
#include <cstddef>
#include <cstdint>
-#include <algorithm>
#include "absl/base/call_once.h"
-#include "absl/base/casts.h"
-#include "absl/base/internal/malloc_hook.h"
#include "absl/base/internal/malloc_hook_invoke.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/base/internal/spinlock.h"
+#include "absl/base/macros.h"
// __THROW is defined in glibc systems. It means, counter-intuitively,
// "This function will never throw an exception." It's an optional
diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc
index d197d444..c0890614 100644
--- a/absl/base/internal/raw_logging.cc
+++ b/absl/base/internal/raw_logging.cc
@@ -12,8 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include <atomic>
-#include <cassert>
+#include "absl/base/internal/raw_logging.h"
+
+#include <stddef.h>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
@@ -22,8 +23,6 @@
#include "absl/base/config.h"
#include "absl/base/internal/atomic_hook.h"
#include "absl/base/internal/log_severity.h"
-#include "absl/base/internal/raw_logging.h"
-#include "absl/base/port.h"
// We know how to perform low-level writes to stderr in POSIX and Windows. For
// these platforms, we define the token ABSL_LOW_LEVEL_WRITE_SUPPORTED.
@@ -38,6 +37,7 @@
#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || \
defined(__GENCLAVE__)
#include <unistd.h>
+
#define ABSL_HAVE_POSIX_WRITE 1
#define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
#else
@@ -57,6 +57,7 @@
#ifdef _WIN32
#include <io.h>
+
#define ABSL_HAVE_RAW_IO 1
#define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1
#else
diff --git a/absl/base/internal/raw_logging.h b/absl/base/internal/raw_logging.h
index 47cf4373..568d2afc 100644
--- a/absl/base/internal/raw_logging.h
+++ b/absl/base/internal/raw_logging.h
@@ -19,6 +19,7 @@
#ifndef ABSL_BASE_INTERNAL_RAW_LOGGING_H_
#define ABSL_BASE_INTERNAL_RAW_LOGGING_H_
+#include "absl/base/attributes.h"
#include "absl/base/internal/log_severity.h"
#include "absl/base/macros.h"
#include "absl/base/port.h"
diff --git a/absl/base/internal/spinlock.cc b/absl/base/internal/spinlock.cc
index 6257bfce..517668dc 100644
--- a/absl/base/internal/spinlock.cc
+++ b/absl/base/internal/spinlock.cc
@@ -16,8 +16,8 @@
#include <algorithm>
#include <atomic>
+#include <limits>
-#include "absl/base/casts.h"
#include "absl/base/internal/atomic_hook.h"
#include "absl/base/internal/cycleclock.h"
#include "absl/base/internal/spinlock_wait.h"
diff --git a/absl/base/internal/spinlock.h b/absl/base/internal/spinlock.h
index fa64ba65..1f50d745 100644
--- a/absl/base/internal/spinlock.h
+++ b/absl/base/internal/spinlock.h
@@ -30,11 +30,17 @@
#ifndef ABSL_BASE_INTERNAL_SPINLOCK_H_
#define ABSL_BASE_INTERNAL_SPINLOCK_H_
+#include <stdint.h>
+#include <sys/types.h>
#include <atomic>
+#include "absl/base/attributes.h"
#include "absl/base/dynamic_annotations.h"
#include "absl/base/internal/low_level_scheduling.h"
+#include "absl/base/internal/raw_logging.h"
+#include "absl/base/internal/scheduling_mode.h"
#include "absl/base/internal/tsan_mutex_interface.h"
+#include "absl/base/macros.h"
#include "absl/base/port.h"
#include "absl/base/thread_annotations.h"
diff --git a/absl/base/internal/spinlock_wait.h b/absl/base/internal/spinlock_wait.h
index 5432c1ce..6734cc9e 100644
--- a/absl/base/internal/spinlock_wait.h
+++ b/absl/base/internal/spinlock_wait.h
@@ -22,6 +22,7 @@
// places listing in //base:spinlock_wait_users. If you need to use it outside
// of //base, please request permission to be added to that list.
+#include <stdint.h>
#include <atomic>
#include "absl/base/internal/scheduling_mode.h"
diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc
index 11863eab..6a4c0064 100644
--- a/absl/base/internal/sysinfo.cc
+++ b/absl/base/internal/sysinfo.cc
@@ -48,7 +48,6 @@
#include "absl/base/internal/raw_logging.h"
#include "absl/base/internal/spinlock.h"
#include "absl/base/internal/unscaledcycleclock.h"
-#include "absl/base/thread_annotations.h"
namespace absl {
namespace base_internal {
diff --git a/absl/base/internal/thread_identity_test.cc b/absl/base/internal/thread_identity_test.cc
index a2b053d9..7695a091 100644
--- a/absl/base/internal/thread_identity_test.cc
+++ b/absl/base/internal/thread_identity_test.cc
@@ -19,6 +19,7 @@
#include "gtest/gtest.h"
#include "absl/base/internal/spinlock.h"
+#include "absl/base/macros.h"
#include "absl/synchronization/internal/per_thread_sem.h"
#include "absl/synchronization/mutex.h"
diff --git a/absl/base/internal/unscaledcycleclock.h b/absl/base/internal/unscaledcycleclock.h
index ddf6a5e5..049f1cac 100644
--- a/absl/base/internal/unscaledcycleclock.h
+++ b/absl/base/internal/unscaledcycleclock.h
@@ -91,6 +91,7 @@ class UnscaledCycleClockWrapperForGetCurrentTime;
namespace base_internal {
class CycleClock;
class UnscaledCycleClockWrapperForInitializeFrequency;
+
class UnscaledCycleClock {
private:
UnscaledCycleClock() = delete;
diff --git a/absl/base/invoke_test.cc b/absl/base/invoke_test.cc
index 2bbfc477..466bf114 100644
--- a/absl/base/invoke_test.cc
+++ b/absl/base/invoke_test.cc
@@ -17,6 +17,7 @@
#include <functional>
#include <memory>
#include <string>
+#include <utility>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
diff --git a/absl/base/spinlock_test_common.cc b/absl/base/spinlock_test_common.cc
index b1212eaf..6918603c 100644
--- a/absl/base/spinlock_test_common.cc
+++ b/absl/base/spinlock_test_common.cc
@@ -24,8 +24,10 @@
#include "gtest/gtest.h"
#include "absl/base/internal/low_level_scheduling.h"
+#include "absl/base/internal/scheduling_mode.h"
#include "absl/base/internal/spinlock.h"
#include "absl/base/internal/sysinfo.h"
+#include "absl/base/macros.h"
#include "absl/synchronization/blocking_counter.h"
#include "absl/synchronization/notification.h"
diff --git a/absl/base/throw_delegate_test.cc b/absl/base/throw_delegate_test.cc
index f9494452..0f15df04 100644
--- a/absl/base/throw_delegate_test.cc
+++ b/absl/base/throw_delegate_test.cc
@@ -18,7 +18,6 @@
#include <new>
#include <stdexcept>
-#include "gmock/gmock.h"
#include "gtest/gtest.h"
namespace {