about summary refs log tree commit diff
path: root/absl/base
diff options
context:
space:
mode:
Diffstat (limited to 'absl/base')
-rw-r--r--absl/base/BUILD.bazel4
-rw-r--r--absl/base/CMakeLists.txt8
-rw-r--r--absl/base/attributes.h6
-rw-r--r--absl/base/call_once.h13
-rw-r--r--absl/base/policy_checks.h10
5 files changed, 24 insertions, 17 deletions
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel
index 6fc712d968f3..7e234bc66779 100644
--- a/absl/base/BUILD.bazel
+++ b/absl/base/BUILD.bazel
@@ -192,7 +192,9 @@ cc_library(
     ],
     copts = ABSL_DEFAULT_COPTS,
     linkopts = select({
-        "//absl:windows": [],
+        "//absl:windows": [
+            "-DEFAULTLIB:shlwapi.lib",
+        ],
         "//conditions:default": ["-pthread"],
     }) + ABSL_DEFAULT_LINKOPTS,
     deps = [
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt
index 9550cdb2db49..7ab6955e2176 100644
--- a/absl/base/CMakeLists.txt
+++ b/absl/base/CMakeLists.txt
@@ -14,6 +14,8 @@
 # limitations under the License.
 #
 
+find_library(LIBRT rt)
+
 absl_cc_library(
   NAME
     atomic_hook
@@ -163,16 +165,18 @@ absl_cc_library(
     "internal/thread_identity.h"
     "internal/tsan_mutex_interface.h"
     "internal/unscaledcycleclock.h"
-    "log_severity.h"
   SRCS
     "internal/cycleclock.cc"
     "internal/spinlock.cc"
     "internal/sysinfo.cc"
     "internal/thread_identity.cc"
     "internal/unscaledcycleclock.cc"
-    "log_severity.cc"
   COPTS
     ${ABSL_DEFAULT_COPTS}
+  LINKOPTS
+    ${ABSL_DEFAULT_LINKOPTS}
+    $<$<BOOL:${LIBRT}>:${LIBRT}>
+    $<$<BOOL:${MINGW}>:"shlwapi">
   DEPS
     absl::atomic_hook
     absl::base_internal
diff --git a/absl/base/attributes.h b/absl/base/attributes.h
index 7b7656a859b8..acd1c5269829 100644
--- a/absl/base/attributes.h
+++ b/absl/base/attributes.h
@@ -158,9 +158,11 @@
 // Weak attributes currently do not work properly in LLVM's Windows backend,
 // so disable them there. See https://bugs.llvm.org/show_bug.cgi?id=37598
 // for further information.
-#if (ABSL_HAVE_ATTRIBUTE(weak) || \
+// The MinGW compiler doesn't complain about the weak attribute until the link
+// step, presumably because Windows doesn't use ELF binaries.
+#if (ABSL_HAVE_ATTRIBUTE(weak) ||                   \
      (defined(__GNUC__) && !defined(__clang__))) && \
-    !(defined(__llvm__) && defined(_WIN32))
+    !(defined(__llvm__) && defined(_WIN32)) && !defined(__MINGW32__)
 #undef ABSL_ATTRIBUTE_WEAK
 #define ABSL_ATTRIBUTE_WEAK __attribute__((weak))
 #define ABSL_HAVE_ATTRIBUTE_WEAK 1
diff --git a/absl/base/call_once.h b/absl/base/call_once.h
index 4aa6360cffc5..e1614e517a8d 100644
--- a/absl/base/call_once.h
+++ b/absl/base/call_once.h
@@ -148,7 +148,7 @@ void CallOnceImpl(std::atomic<uint32_t>* control,
                   Args&&... args) {
 #ifndef NDEBUG
   {
-    uint32_t old_control = control->load(std::memory_order_acquire);
+    uint32_t old_control = control->load(std::memory_order_relaxed);
     if (old_control != kOnceInit &&
         old_control != kOnceRunning &&
         old_control != kOnceWaiter &&
@@ -166,14 +166,23 @@ void CallOnceImpl(std::atomic<uint32_t>* control,
   // Must do this before potentially modifying control word's state.
   base_internal::SchedulingHelper maybe_disable_scheduling(scheduling_mode);
   // Short circuit the simplest case to avoid procedure call overhead.
+  // The base_internal::SpinLockWait() call returns either kOnceInit or
+  // kOnceDone. If it returns kOnceDone, it must have loaded the control word
+  // with std::memory_order_acquire and seen a value of kOnceDone.
   uint32_t old_control = kOnceInit;
   if (control->compare_exchange_strong(old_control, kOnceRunning,
-                                       std::memory_order_acquire,
                                        std::memory_order_relaxed) ||
       base_internal::SpinLockWait(control, ABSL_ARRAYSIZE(trans), trans,
                                   scheduling_mode) == kOnceInit) {
     base_internal::Invoke(std::forward<Callable>(fn),
                           std::forward<Args>(args)...);
+    // The call to SpinLockWake below is an optimization, because the waiter
+    // in SpinLockWait is waiting with a short timeout. The atomic load/store
+    // sequence is slightly faster than an atomic exchange:
+    //   old_control = control->exchange(base_internal::kOnceDone,
+    //                                   std::memory_order_release);
+    // We opt for a slightly faster case when there are no waiters, in spite
+    // of longer tail latency when there are waiters.
     old_control = control->load(std::memory_order_relaxed);
     control->store(base_internal::kOnceDone, std::memory_order_release);
     if (old_control == base_internal::kOnceWaiter) {
diff --git a/absl/base/policy_checks.h b/absl/base/policy_checks.h
index 699fb1a2e0fc..4dfa49e54ac2 100644
--- a/absl/base/policy_checks.h
+++ b/absl/base/policy_checks.h
@@ -82,16 +82,6 @@
 // Standard Library Check
 // -----------------------------------------------------------------------------
 
-// We have chosen glibc 2.12 as the minimum as it was tagged for release
-// in May, 2010 and includes some functionality used in Google software
-// (for instance pthread_setname_np):
-// https://sourceware.org/ml/libc-alpha/2010-05/msg00000.html
-#if defined(__GLIBC__) && defined(__GLIBC_PREREQ)
-#if !__GLIBC_PREREQ(2, 12)
-#error "Minimum required version of glibc is 2.12."
-#endif
-#endif
-
 #if defined(_STLPORT_VERSION)
 #error "STLPort is not supported."
 #endif