diff options
Diffstat (limited to 'absl/base')
-rw-r--r-- | absl/base/BUILD.bazel | 2 | ||||
-rw-r--r-- | absl/base/CMakeLists.txt | 2 | ||||
-rw-r--r-- | absl/base/internal/atomic_hook.h | 2 | ||||
-rw-r--r-- | absl/base/internal/raw_logging.cc | 4 | ||||
-rw-r--r-- | absl/base/internal/sysinfo.cc | 26 | ||||
-rw-r--r-- | absl/base/macros.h | 10 |
6 files changed, 26 insertions, 20 deletions
diff --git a/absl/base/BUILD.bazel b/absl/base/BUILD.bazel index f6b210f41e31..f8eb8aeb3b9c 100644 --- a/absl/base/BUILD.bazel +++ b/absl/base/BUILD.bazel @@ -193,7 +193,7 @@ cc_library( copts = ABSL_DEFAULT_COPTS, linkopts = select({ "//absl:windows": [ - "-DEFAULTLIB:shlwapi.lib", + "-DEFAULTLIB:advapi32.lib", ], "//conditions:default": ["-pthread"], }) + ABSL_DEFAULT_LINKOPTS, diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt index 9b0174d80efe..c521f32d1cab 100644 --- a/absl/base/CMakeLists.txt +++ b/absl/base/CMakeLists.txt @@ -176,7 +176,7 @@ absl_cc_library( LINKOPTS ${ABSL_DEFAULT_LINKOPTS} $<$<BOOL:${LIBRT}>:${LIBRT}> - $<$<BOOL:${MINGW}>:"shlwapi"> + $<$<BOOL:${MINGW}>:"advapi32"> DEPS absl::atomic_hook absl::base_internal diff --git a/absl/base/internal/atomic_hook.h b/absl/base/internal/atomic_hook.h index 09f763d0742b..6df956a6ab66 100644 --- a/absl/base/internal/atomic_hook.h +++ b/absl/base/internal/atomic_hook.h @@ -63,7 +63,7 @@ class AtomicHook<ReturnType (*)(Args...)> { explicit constexpr AtomicHook(FnPtr default_fn) : hook_(default_fn), default_fn_(default_fn) {} #else - // On MSVC, this function sometimes executes after dynamic initiazliation =(. + // On MSVC, this function sometimes executes after dynamic initialization =(. // If a non-zero `hook_` has been installed by a dynamic initializer, we want // to preserve it. If not, `hook_` will be zero initialized and we have no // need to set it to `kUninitialized`. diff --git a/absl/base/internal/raw_logging.cc b/absl/base/internal/raw_logging.cc index 878fe6c6c2cc..d20bf34ef538 100644 --- a/absl/base/internal/raw_logging.cc +++ b/absl/base/internal/raw_logging.cc @@ -37,9 +37,9 @@ // this, consider moving both to config.h instead. #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ defined(__Fuchsia__) || defined(__native_client__) || \ - defined(__EMSCRIPTEN__) -#include <unistd.h> + defined(__EMSCRIPTEN__) || defined(__ASYLO__) +#include <unistd.h> #define ABSL_HAVE_POSIX_WRITE 1 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1 diff --git a/absl/base/internal/sysinfo.cc b/absl/base/internal/sysinfo.cc index 93039bf23f13..68d4266b70cc 100644 --- a/absl/base/internal/sysinfo.cc +++ b/absl/base/internal/sysinfo.cc @@ -17,7 +17,6 @@ #include "absl/base/attributes.h" #ifdef _WIN32 -#include <shlwapi.h> #include <windows.h> #else #include <fcntl.h> @@ -76,14 +75,23 @@ static int GetNumCPUs() { #if defined(_WIN32) static double GetNominalCPUFrequency() { - DWORD data; - DWORD data_size = sizeof(data); - #pragma comment(lib, "shlwapi.lib") // For SHGetValue(). - if (SUCCEEDED( - SHGetValueA(HKEY_LOCAL_MACHINE, - "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - "~MHz", nullptr, &data, &data_size))) { - return data * 1e6; // Value is MHz. +#pragma comment(lib, "advapi32.lib") // For Reg* functions. + HKEY key; + // Use the Reg* functions rather than the SH functions because shlwapi.dll + // pulls in gdi32.dll which makes process destruction much more costly. + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, + "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0, + KEY_READ, &key) == ERROR_SUCCESS) { + DWORD type = 0; + DWORD data = 0; + DWORD data_size = sizeof(data); + auto result = RegQueryValueExA(key, "~MHz", 0, &type, + reinterpret_cast<LPBYTE>(&data), &data_size); + RegCloseKey(key); + if (result == ERROR_SUCCESS && type == REG_DWORD && + data_size == sizeof(data)) { + return data * 1e6; // Value is MHz. + } } return 1.0; } diff --git a/absl/base/macros.h b/absl/base/macros.h index d481288f35f9..d414dcace38e 100644 --- a/absl/base/macros.h +++ b/absl/base/macros.h @@ -31,6 +31,7 @@ #include <cassert> #include <cstddef> +#include "absl/base/attributes.h" #include "absl/base/optimization.h" #include "absl/base/port.h" @@ -176,12 +177,9 @@ enum LinkerInitialized { // ABSL_BAD_CALL_IF(c <= -1 || c > 255, // "'c' must have the value of an unsigned char or EOF"); // #endif // ABSL_BAD_CALL_IF - -#if defined(__clang__) -# if __has_attribute(enable_if) -# define ABSL_BAD_CALL_IF(expr, msg) \ - __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) -# endif +#if ABSL_HAVE_ATTRIBUTE(enable_if) +#define ABSL_BAD_CALL_IF(expr, msg) \ + __attribute__((enable_if(expr, "Bad call trap"), unavailable(msg))) #endif // ABSL_ASSERT() |