Skip to content

Commit 1ce4cec

Browse files
Abseil Teamsuertreus
authored andcommitted
Export of internal Abseil changes
-- 1801102e11205861bc063e067e9fd4754b625c5a by Derek Mauro <[email protected]>: Internal change PiperOrigin-RevId: 398562681 -- 485008445725d4013f60f4b2876f84b6b47932ec by Jorg Brown <[email protected]>: Replace calls to std::isinf with comparison against max(). PiperOrigin-RevId: 398534255 -- 9b99d074d39ad677cf92f99549d22bb73f504f8f by Saleem Abdulrasool <[email protected]>: debugging: add support for non-glibc targets for debugging This relaxes the ELF mem_image handling and subsequently enables the VDSO support for non-glibc targets. The primary need for the restriction was the use of the `__GLIBC_PREREQ` macro. If it is undefined, assume that the glibc pre-requisite is unavailable. This allows building the debugging_internal target on musl targets. PiperOrigin-RevId: 398499050 -- 3cc3630ef2226ae1981a944573f0f9c27a527ebf by Abseil Team <[email protected]>: Replace usages of `auto` with proper typedefs. PiperOrigin-RevId: 398479551 GitOrigin-RevId: 1801102e11205861bc063e067e9fd4754b625c5a Change-Id: Ib13e8612d1b263b9c1ae7f56a9f394b24c3add2e
1 parent f3a4274 commit 1ce4cec

File tree

5 files changed

+35
-21
lines changed

5 files changed

+35
-21
lines changed

absl/container/internal/inlined_vector.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ template <typename A>
9898
void DestroyElements(NoTypeDeduction<A>& allocator, Pointer<A> destroy_first,
9999
SizeType<A> destroy_size) {
100100
if (destroy_first != nullptr) {
101-
for (auto i = destroy_size; i != 0;) {
101+
for (SizeType<A> i = destroy_size; i != 0;) {
102102
--i;
103103
AllocatorTraits<A>::destroy(allocator, destroy_first + i);
104104
}
@@ -492,7 +492,7 @@ void Storage<T, N, A>::DestroyContents() {
492492

493493
template <typename T, size_t N, typename A>
494494
void Storage<T, N, A>::InitFrom(const Storage& other) {
495-
const auto n = other.GetSize();
495+
const SizeType<A> n = other.GetSize();
496496
assert(n > 0); // Empty sources handled handled in caller.
497497
ConstPointer<A> src;
498498
Pointer<A> dst;
@@ -598,9 +598,9 @@ template <typename ValueAdapter>
598598
auto Storage<T, N, A>::Resize(ValueAdapter values, SizeType<A> new_size)
599599
-> void {
600600
StorageView<A> storage_view = MakeStorageView();
601-
auto* const base = storage_view.data;
601+
Pointer<A> const base = storage_view.data;
602602
const SizeType<A> size = storage_view.size;
603-
auto& alloc = GetAllocator();
603+
A& alloc = GetAllocator();
604604
if (new_size <= size) {
605605
// Destroy extra old elements.
606606
DestroyElements<A>(alloc, base + new_size, size - new_size);
@@ -732,7 +732,7 @@ template <typename T, size_t N, typename A>
732732
template <typename... Args>
733733
auto Storage<T, N, A>::EmplaceBack(Args&&... args) -> Reference<A> {
734734
StorageView<A> storage_view = MakeStorageView();
735-
const auto n = storage_view.size;
735+
const SizeType<A> n = storage_view.size;
736736
if (ABSL_PREDICT_TRUE(n != storage_view.capacity)) {
737737
// Fast path; new element fits.
738738
Pointer<A> last_ptr = storage_view.data + n;

absl/debugging/internal/elf_mem_image.cc

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <string.h>
2323
#include <cassert>
2424
#include <cstddef>
25+
#include "absl/base/config.h"
2526
#include "absl/base/internal/raw_logging.h"
2627

2728
// From binutils/include/elf/common.h (this doesn't appear to be documented
@@ -43,11 +44,11 @@ namespace debugging_internal {
4344

4445
namespace {
4546

46-
#if __WORDSIZE == 32
47+
#if __SIZEOF_POINTER__ == 4
4748
const int kElfClass = ELFCLASS32;
4849
int ElfBind(const ElfW(Sym) *symbol) { return ELF32_ST_BIND(symbol->st_info); }
4950
int ElfType(const ElfW(Sym) *symbol) { return ELF32_ST_TYPE(symbol->st_info); }
50-
#elif __WORDSIZE == 64
51+
#elif __SIZEOF_POINTER__ == 8
5152
const int kElfClass = ELFCLASS64;
5253
int ElfBind(const ElfW(Sym) *symbol) { return ELF64_ST_BIND(symbol->st_info); }
5354
int ElfType(const ElfW(Sym) *symbol) { return ELF64_ST_TYPE(symbol->st_info); }
@@ -175,17 +176,17 @@ void ElfMemImage::Init(const void *base) {
175176
}
176177
switch (base_as_char[EI_DATA]) {
177178
case ELFDATA2LSB: {
178-
if (__LITTLE_ENDIAN != __BYTE_ORDER) {
179-
assert(false);
180-
return;
181-
}
179+
#ifndef ABSL_IS_LITTLE_ENDIAN
180+
assert(false);
181+
return;
182+
#endif
182183
break;
183184
}
184185
case ELFDATA2MSB: {
185-
if (__BIG_ENDIAN != __BYTE_ORDER) {
186-
assert(false);
187-
return;
188-
}
186+
#ifndef ABSL_IS_BIG_ENDIAN
187+
assert(false);
188+
return;
189+
#endif
189190
break;
190191
}
191192
default: {

absl/debugging/internal/elf_mem_image.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#error ABSL_HAVE_ELF_MEM_IMAGE cannot be directly set
3232
#endif
3333

34-
#if defined(__ELF__) && defined(__GLIBC__) && !defined(__native_client__) && \
35-
!defined(__asmjs__) && !defined(__wasm__)
34+
#if defined(__ELF__) && !defined(__native_client__) && !defined(__asmjs__) && \
35+
!defined(__wasm__)
3636
#define ABSL_HAVE_ELF_MEM_IMAGE 1
3737
#endif
3838

absl/debugging/internal/vdso_support.cc

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,25 @@
2020

2121
#ifdef ABSL_HAVE_VDSO_SUPPORT // defined in vdso_support.h
2222

23+
#if !defined(__has_include)
24+
#define __has_include(header) 0
25+
#endif
26+
2327
#include <errno.h>
2428
#include <fcntl.h>
29+
#if __has_include(<syscall.h>)
30+
#include <syscall.h>
31+
#elif __has_include(<sys/syscall.h>)
2532
#include <sys/syscall.h>
33+
#endif
2634
#include <unistd.h>
2735

28-
#if __GLIBC_PREREQ(2, 16) // GLIBC-2.16 implements getauxval.
36+
#if defined(__GLIBC__) && \
37+
(__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16))
38+
#define ABSL_HAVE_GETAUXVAL
39+
#endif
40+
41+
#ifdef ABSL_HAVE_GETAUXVAL
2942
#include <sys/auxv.h>
3043
#endif
3144

@@ -65,7 +78,7 @@ VDSOSupport::VDSOSupport()
6578
// the operation should be idempotent.
6679
const void *VDSOSupport::Init() {
6780
const auto kInvalidBase = debugging_internal::ElfMemImage::kInvalidBase;
68-
#if __GLIBC_PREREQ(2, 16)
81+
#ifdef ABSL_HAVE_GETAUXVAL
6982
if (vdso_base_.load(std::memory_order_relaxed) == kInvalidBase) {
7083
errno = 0;
7184
const void *const sysinfo_ehdr =
@@ -74,7 +87,7 @@ const void *VDSOSupport::Init() {
7487
vdso_base_.store(sysinfo_ehdr, std::memory_order_relaxed);
7588
}
7689
}
77-
#endif // __GLIBC_PREREQ(2, 16)
90+
#endif // ABSL_HAVE_GETAUXVAL
7891
if (vdso_base_.load(std::memory_order_relaxed) == kInvalidBase) {
7992
int fd = open("/proc/self/auxv", O_RDONLY);
8093
if (fd == -1) {

absl/strings/numbers.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ size_t numbers_internal::SixDigitsToBuffer(double d, char* const buffer) {
505505
*out++ = '-';
506506
d = -d;
507507
}
508-
if (std::isinf(d)) {
508+
if (d > std::numeric_limits<double>::max()) {
509509
strcpy(out, "inf"); // NOLINT(runtime/printf)
510510
return out + 3 - buffer;
511511
}

0 commit comments

Comments
 (0)