Commit 28c9ae3f authored by Mirko Bonadei's avatar Mirko Bonadei Committed by Commit Bot

Roll abseil_revision 930fbec75b..3c8b5d7587

Change Log:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+log/930fbec75b..3c8b5d7587
Full diff:
https://chromium.googlesource.com/external/github.com/abseil/abseil-cpp/+/930fbec75b..3c8b5d7587

No changes required to .def files.

Bug: None
Change-Id: I9ec81aafc9986662f47ebd0425d0984fcb95ce9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2401465Reviewed-by: default avatarDanil Chapovalov <danilchap@chromium.org>
Commit-Queue: Mirko Bonadei <mbonadei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#805678}
parent 1067ee44
...@@ -4,7 +4,7 @@ URL: https://github.com/abseil/abseil-cpp ...@@ -4,7 +4,7 @@ URL: https://github.com/abseil/abseil-cpp
License: Apache 2.0 License: Apache 2.0
License File: LICENSE License File: LICENSE
Version: 0 Version: 0
Revision: 930fbec75b452af8bb8c796f5bb754e953e29cf5 Revision: 3c8b5d7587dc8ecf730ce9996c89e156e408c3ed
Security Critical: yes Security Critical: yes
Description: Description:
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "absl/base/internal/strerror.h" #include "absl/base/internal/strerror.h"
#include <array>
#include <cerrno> #include <cerrno>
#include <cstddef> #include <cstddef>
#include <cstdio> #include <cstdio>
...@@ -21,13 +22,13 @@ ...@@ -21,13 +22,13 @@
#include <string> #include <string>
#include <type_traits> #include <type_traits>
#include "absl/base/attributes.h"
#include "absl/base/internal/errno_saver.h" #include "absl/base/internal/errno_saver.h"
namespace absl { namespace absl {
ABSL_NAMESPACE_BEGIN ABSL_NAMESPACE_BEGIN
namespace base_internal { namespace base_internal {
namespace { namespace {
const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) { const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) {
#if defined(_WIN32) #if defined(_WIN32)
int rc = strerror_s(buf, buflen, errnum); int rc = strerror_s(buf, buflen, errnum);
...@@ -35,15 +36,6 @@ const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) { ...@@ -35,15 +36,6 @@ const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) {
if (rc == 0 && strncmp(buf, "Unknown error", buflen) == 0) *buf = '\0'; if (rc == 0 && strncmp(buf, "Unknown error", buflen) == 0) *buf = '\0';
return buf; return buf;
#else #else
#if defined(__GLIBC__) || defined(__APPLE__)
// Use the BSD sys_errlist API provided by GNU glibc and others to
// avoid any need to copy the message into the local buffer first.
if (0 <= errnum && errnum < sys_nerr) {
if (const char* p = sys_errlist[errnum]) {
return p;
}
}
#endif
// The type of `ret` is platform-specific; both of these branches must compile // The type of `ret` is platform-specific; both of these branches must compile
// either way but only one will execute on any given platform: // either way but only one will execute on any given platform:
auto ret = strerror_r(errnum, buf, buflen); auto ret = strerror_r(errnum, buf, buflen);
...@@ -57,9 +49,8 @@ const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) { ...@@ -57,9 +49,8 @@ const char* StrErrorAdaptor(int errnum, char* buf, size_t buflen) {
} }
#endif #endif
} }
} // namespace
std::string StrError(int errnum) { std::string StrErrorInternal(int errnum) {
absl::base_internal::ErrnoSaver errno_saver; absl::base_internal::ErrnoSaver errno_saver;
char buf[100]; char buf[100];
const char* str = StrErrorAdaptor(errnum, buf, sizeof buf); const char* str = StrErrorAdaptor(errnum, buf, sizeof buf);
...@@ -70,6 +61,28 @@ std::string StrError(int errnum) { ...@@ -70,6 +61,28 @@ std::string StrError(int errnum) {
return str; return str;
} }
// kSysNerr is the number of errors from a recent glibc. `StrError()` falls back
// to `StrErrorAdaptor()` if the value is larger than this.
constexpr int kSysNerr = 135;
std::array<std::string, kSysNerr>* NewStrErrorTable() {
auto* table = new std::array<std::string, kSysNerr>;
for (int i = 0; i < static_cast<int>(table->size()); ++i) {
(*table)[i] = StrErrorInternal(i);
}
return table;
}
} // namespace
std::string StrError(int errnum) {
static const auto* table = NewStrErrorTable();
if (errnum >= 0 && errnum < static_cast<int>(table->size())) {
return (*table)[errnum];
}
return StrErrorInternal(errnum);
}
} // namespace base_internal } // namespace base_internal
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
...@@ -20,15 +20,6 @@ ...@@ -20,15 +20,6 @@
#include "benchmark/benchmark.h" #include "benchmark/benchmark.h"
namespace { namespace {
#if defined(__GLIBC__) || defined(__APPLE__)
void BM_SysErrList(benchmark::State& state) {
for (auto _ : state) {
benchmark::DoNotOptimize(std::string(sys_errlist[ERANGE]));
}
}
BENCHMARK(BM_SysErrList);
#endif
void BM_AbslStrError(benchmark::State& state) { void BM_AbslStrError(benchmark::State& state) {
for (auto _ : state) { for (auto _ : state) {
benchmark::DoNotOptimize(absl::base_internal::StrError(ERANGE)); benchmark::DoNotOptimize(absl::base_internal::StrError(ERANGE));
......
This diff is collapsed.
...@@ -57,6 +57,10 @@ class KernelTimeout { ...@@ -57,6 +57,10 @@ class KernelTimeout {
bool has_timeout() const { return ns_ != 0; } bool has_timeout() const { return ns_ != 0; }
// Convert to parameter for sem_timedwait/futex/similar. Only for approved
// users. Do not call if !has_timeout.
struct timespec MakeAbsTimespec();
private: private:
// internal rep, not user visible: ns after unix epoch. // internal rep, not user visible: ns after unix epoch.
// zero = no timeout. // zero = no timeout.
...@@ -82,34 +86,6 @@ class KernelTimeout { ...@@ -82,34 +86,6 @@ class KernelTimeout {
return x; return x;
} }
// Convert to parameter for sem_timedwait/futex/similar. Only for approved
// users. Do not call if !has_timeout.
struct timespec MakeAbsTimespec() {
int64_t n = ns_;
static const int64_t kNanosPerSecond = 1000 * 1000 * 1000;
if (n == 0) {
ABSL_RAW_LOG(
ERROR,
"Tried to create a timespec from a non-timeout; never do this.");
// But we'll try to continue sanely. no-timeout ~= saturated timeout.
n = (std::numeric_limits<int64_t>::max)();
}
// Kernel APIs validate timespecs as being at or after the epoch,
// despite the kernel time type being signed. However, no one can
// tell the difference between a timeout at or before the epoch (since
// all such timeouts have expired!)
if (n < 0) n = 0;
struct timespec abstime;
int64_t seconds = (std::min)(n / kNanosPerSecond,
int64_t{(std::numeric_limits<time_t>::max)()});
abstime.tv_sec = static_cast<time_t>(seconds);
abstime.tv_nsec =
static_cast<decltype(abstime.tv_nsec)>(n % kNanosPerSecond);
return abstime;
}
#ifdef _WIN32 #ifdef _WIN32
// Converts to milliseconds from now, or INFINITE when // Converts to milliseconds from now, or INFINITE when
// !has_timeout(). For use by SleepConditionVariableSRW on // !has_timeout(). For use by SleepConditionVariableSRW on
...@@ -148,6 +124,30 @@ class KernelTimeout { ...@@ -148,6 +124,30 @@ class KernelTimeout {
friend class Waiter; friend class Waiter;
}; };
inline struct timespec KernelTimeout::MakeAbsTimespec() {
int64_t n = ns_;
static const int64_t kNanosPerSecond = 1000 * 1000 * 1000;
if (n == 0) {
ABSL_RAW_LOG(
ERROR, "Tried to create a timespec from a non-timeout; never do this.");
// But we'll try to continue sanely. no-timeout ~= saturated timeout.
n = (std::numeric_limits<int64_t>::max)();
}
// Kernel APIs validate timespecs as being at or after the epoch,
// despite the kernel time type being signed. However, no one can
// tell the difference between a timeout at or before the epoch (since
// all such timeouts have expired!)
if (n < 0) n = 0;
struct timespec abstime;
int64_t seconds = (std::min)(n / kNanosPerSecond,
int64_t{(std::numeric_limits<time_t>::max)()});
abstime.tv_sec = static_cast<time_t>(seconds);
abstime.tv_nsec = static_cast<decltype(abstime.tv_nsec)>(n % kNanosPerSecond);
return abstime;
}
} // namespace synchronization_internal } // namespace synchronization_internal
ABSL_NAMESPACE_END ABSL_NAMESPACE_END
} // namespace absl } // namespace absl
......
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