Export of internal Abseil changes

--
ef2bf829c333f378ecc12f3259e3187cdb75a3d5 by Abseil Team <absl-team@google.com>:

debugging: fix the VDSO symbol name used for unwinding on RISC-V Linux

The name listed in `man vdso` is incorrect. Instead, use the name from `linux-5.16/arch/riscv/kernel/vdso/rt_sigreturn.S`

PiperOrigin-RevId: 439654174
Change-Id: Ib39d066f416681720068e806e828a2c76a14a532

--
43dfad824afd36cfc3e5049b4fea71a2bccb066c by Benjamin Barenblat <bbaren@google.com>:

Check printf format strings in str_format_convert_test

Add ABSL_PRINTF_ATTRIBUTE to appropriate functions in
strings/internal/str_format/convert_test. Correct
TypedFormatConvertTest.Char, which was accidentally passing values of
types larger than int to StrPrint.

PiperOrigin-RevId: 439388148
Change-Id: I6cde4e8e0c6455064138192430f07f4c990be0bc

--
f84b4ab2c3b070c8af0c82742ac7a8a4bf443bca by Derek Mauro <dmauro@google.com>:

Use __builtin_memcmp in the absl::string_view implementation
starting with MSVC 16.9, where it first appeared

This enables more constexpr operations

PiperOrigin-RevId: 439317316
Change-Id: Iaf1ce76b60901d4b2d5b96be5900c56572f57b15
GitOrigin-RevId: ef2bf829c333f378ecc12f3259e3187cdb75a3d5
pull/1157/head
Abseil Team 3 years ago committed by dinord
parent 6f43f5bb39
commit 9fed77a6fe
  1. 2
      absl/debugging/internal/stacktrace_riscv-inl.inc
  2. 1
      absl/strings/BUILD.bazel
  3. 1
      absl/strings/CMakeLists.txt
  4. 34
      absl/strings/internal/str_format/convert_test.cc
  5. 5
      absl/strings/string_view.h

@ -56,7 +56,7 @@ static const unsigned char *GetKernelRtSigreturnAddress() {
absl::debugging_internal::VDSOSupport::SymbolInfo symbol_info; absl::debugging_internal::VDSOSupport::SymbolInfo symbol_info;
// Symbol versioning pulled from arch/riscv/kernel/vdso/vdso.lds at v5.10. // Symbol versioning pulled from arch/riscv/kernel/vdso/vdso.lds at v5.10.
auto lookup = [&](int type) { auto lookup = [&](int type) {
return vdso.LookupSymbol("__kernel_rt_sigreturn", "LINUX_4.15", type, return vdso.LookupSymbol("__vdso_rt_sigreturn", "LINUX_4.15", type,
&symbol_info); &symbol_info);
}; };
if ((!lookup(STT_FUNC) && !lookup(STT_NOTYPE)) || if ((!lookup(STT_FUNC) && !lookup(STT_NOTYPE)) ||

@ -1191,6 +1191,7 @@ cc_test(
deps = [ deps = [
":str_format_internal", ":str_format_internal",
":strings", ":strings",
"//absl/base:core_headers",
"//absl/base:raw_logging_internal", "//absl/base:raw_logging_internal",
"//absl/types:optional", "//absl/types:optional",
"@com_google_googletest//:gtest_main", "@com_google_googletest//:gtest_main",

@ -494,6 +494,7 @@ absl_cc_test(
DEPS DEPS
absl::strings absl::strings
absl::str_format_internal absl::str_format_internal
absl::core_headers
absl::raw_logging_internal absl::raw_logging_internal
absl::int128 absl::int128
GTest::gmock_main GTest::gmock_main

@ -24,6 +24,7 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "absl/base/attributes.h"
#include "absl/base/internal/raw_logging.h" #include "absl/base/internal/raw_logging.h"
#include "absl/strings/internal/str_format/bind.h" #include "absl/strings/internal/str_format/bind.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
@ -124,6 +125,7 @@ void StrAppendV(std::string *dst, const char *format, va_list ap) {
delete[] buf; delete[] buf;
} }
void StrAppend(std::string *, const char *, ...) ABSL_PRINTF_ATTRIBUTE(2, 3);
void StrAppend(std::string *out, const char *format, ...) { void StrAppend(std::string *out, const char *format, ...) {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
@ -131,6 +133,7 @@ void StrAppend(std::string *out, const char *format, ...) {
va_end(ap); va_end(ap);
} }
std::string StrPrint(const char *, ...) ABSL_PRINTF_ATTRIBUTE(1, 2);
std::string StrPrint(const char *format, ...) { std::string StrPrint(const char *format, ...) {
va_list ap; va_list ap;
va_start(ap, format); va_start(ap, format);
@ -455,21 +458,32 @@ TYPED_TEST_P(TypedFormatConvertTest, AllIntsWithFlags) {
} }
TYPED_TEST_P(TypedFormatConvertTest, Char) { TYPED_TEST_P(TypedFormatConvertTest, Char) {
// Pass a bunch of values of type TypeParam to both FormatPack and libc's
// vsnprintf("%c", ...) (wrapped in StrPrint) to make sure we get the same
// value.
typedef TypeParam T; typedef TypeParam T;
using remove_volatile_t = typename std::remove_volatile<T>::type; using remove_volatile_t = typename std::remove_volatile<T>::type;
static const T kMin = std::numeric_limits<remove_volatile_t>::min(); std::vector<remove_volatile_t> vals = {
static const T kMax = std::numeric_limits<remove_volatile_t>::max(); remove_volatile_t(1), remove_volatile_t(2), remove_volatile_t(10), //
T kVals[] = { remove_volatile_t(-1), remove_volatile_t(-2), remove_volatile_t(-10), //
remove_volatile_t(1), remove_volatile_t(2), remove_volatile_t(10), remove_volatile_t(0),
remove_volatile_t(-1), remove_volatile_t(-2), remove_volatile_t(-10),
remove_volatile_t(0),
kMin + remove_volatile_t(1), kMin,
kMax - remove_volatile_t(1), kMax
}; };
for (const T &c : kVals) {
// We'd like to test values near std::numeric_limits::min() and
// std::numeric_limits::max(), too, but vsnprintf("%c", ...) can't handle
// anything larger than an int. Add in the most extreme values we can without
// exceeding that range.
static const T kMin =
static_cast<remove_volatile_t>(std::numeric_limits<int>::min());
static const T kMax =
static_cast<remove_volatile_t>(std::numeric_limits<int>::max());
vals.insert(vals.end(), {kMin + 1, kMin, kMax - 1, kMax});
for (const T c : vals) {
const FormatArgImpl args[] = {FormatArgImpl(c)}; const FormatArgImpl args[] = {FormatArgImpl(c)};
UntypedFormatSpecImpl format("%c"); UntypedFormatSpecImpl format("%c");
EXPECT_EQ(StrPrint("%c", c), FormatPack(format, absl::MakeSpan(args))); EXPECT_EQ(StrPrint("%c", static_cast<int>(c)),
FormatPack(format, absl::MakeSpan(args)));
} }
} }

@ -55,8 +55,9 @@ ABSL_NAMESPACE_END
#else // ABSL_USES_STD_STRING_VIEW #else // ABSL_USES_STD_STRING_VIEW
#if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \ #if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \
(defined(__GNUC__) && !defined(__clang__)) (defined(__GNUC__) && !defined(__clang__)) || \
(defined(_MSC_VER) && _MSC_VER >= 1928)
#define ABSL_INTERNAL_STRING_VIEW_MEMCMP __builtin_memcmp #define ABSL_INTERNAL_STRING_VIEW_MEMCMP __builtin_memcmp
#else // ABSL_HAVE_BUILTIN(__builtin_memcmp) #else // ABSL_HAVE_BUILTIN(__builtin_memcmp)
#define ABSL_INTERNAL_STRING_VIEW_MEMCMP memcmp #define ABSL_INTERNAL_STRING_VIEW_MEMCMP memcmp

Loading…
Cancel
Save