346 Commits

Author SHA1 Message Date
Anuraag Agrawal
79f3dec06e PR #1509: Allow building when targeting WASI
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1509

WASI is similar to emscripten, providing a syscall layer to WebAssembly focused on server side applications. There are some config knobs that are in place to allow building the repo for emscripten which also need to support wasi (as built with LLVM). Aside from that, there are still some features it supports less than escripten, for example related to signals, causing the build to be even more limited for it.
Merge ec9fa08160 into 861e53c8f0

Merging this change closes #1509

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1509 from anuraaga:wasi-sdk-build ec9fa08160
PiperOrigin-RevId: 557166498
Change-Id: Ic51149d8b092fd888c9a5c383275257fc8ff4232
2023-08-15 10:04:02 -07:00
Ryan Schmidt
5b3b0ed81c PR #1500: Define MAP_ANONYMOUS if not defined
Included are additional automated edits by clang-format on import.

Merge d74896699f into 22091f4c0d

Merging this change closes #1500

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1500 from ryandesign:MAP_ANONYMOUS d74896699f
PiperOrigin-RevId: 552922776
Change-Id: I96a0395cb5e7156d7c7a889491c5d0b4cf755819
2023-08-01 14:27:32 -07:00
Abseil Team
be85b347a8 Add Support for mmap on Qualcomm Hexagon DSP targets.
PiperOrigin-RevId: 548709037
Change-Id: I6eb03553299265660aa0abc180ae0f197a416ba4
2023-07-17 09:08:06 -07:00
Abseil Team
c16a2f4320 Use new emscripten_errn to avoid copying strings.
PiperOrigin-RevId: 547895328
Change-Id: If5da952604415fa6ed2402052f80add6c4b7dfb3
2023-07-13 13:05:57 -07:00
Abseil Team
93ef827f61 Rename absl::NonNull to absl::Nonnull.
The current spelling is inconsistent with standard casing rules: "nonnull" is a single word, not two.

PiperOrigin-RevId: 546034114
Change-Id: I04e5a204f4a74ebaa76031dd0b0874ca9cfa902c
2023-07-06 10:50:35 -07:00
Abseil Team
f3ea24d72e Rolls back use of emscripten_errn as some implementations may not be compatible.
PiperOrigin-RevId: 544677169
Change-Id: I98874c5c8d1c9a057958b63e2b3c4fdd5daccd39
2023-06-30 09:33:26 -07:00
Abseil Team
d9a01008ab Use new emscripten_errn to avoid copying strings.
PiperOrigin-RevId: 544461113
Change-Id: Iafbd6daf2d03ae18a49ea449315ee7cd6a0e615e
2023-06-29 14:21:05 -07:00
Abseil Team
4eaff9e61e Support Qualcomm Hexagon DSP targets.
PiperOrigin-RevId: 544438364
Change-Id: I22d461f2d0aa8638a0e640eebecdc7e5e2b49ea3
2023-06-29 12:59:30 -07:00
Abseil Team
cffa80b913 absl: reformat Mutex-related files
Reformat Mutex-related files so that incremental formatting changes
don't distract during review of logical changes.
These files are subtle and any unnecessary diffs make reviews harder.

No changes besides running clang-format.

PiperOrigin-RevId: 541981737
Change-Id: I41cccb7a97158c78d17adaff6fe553c2c9c2b9ed
2023-06-20 10:54:11 -07:00
Abseil Team
5668c20e02 Add Nullability annotations to Abseil.
PiperOrigin-RevId: 541915097
Change-Id: I7ebfbafc36db38b59b30ab5b312cd7e22082a805
2023-06-20 07:30:11 -07:00
Abseil Team
04e0dcae14 Rename AsyncSignalSafeWriteToStderr to AsyncSignalSafeWriteError.
It no longer strictly writes to stderr, since Emscripten/WebAssembly now use _emscripten_err which might be replaced by something that is not the same as stderr by the host.

PiperOrigin-RevId: 540655336
Change-Id: Icc2a430a0db53a1282ef5558e9f3648db67e972c
2023-06-15 12:19:02 -07:00
Abseil Team
4a82a1f469 For web assembly, implement raw logging as direct JS console logging.
This bypasses the need for filesystem APIs just for stderr access.

PiperOrigin-RevId: 540367155
Change-Id: Ib91dadac28cb5c8e571407b5dfa60c3e65539c95
2023-06-14 13:42:23 -07:00
Derek Mauro
4500c2fada DirectMmap: Use off_t instead of off64_t for the offset parameter
off_t is best for portability. Its size varies with the platform.
off64_t is non-standard, but is present in glibc and some BSDs.
It also matches the signature specified in the manual.
https://man7.org/linux/man-pages/man2/mmap.2.html

This is a re-spin of #1349, but correctly casts the type to the type
expected by the kernel for mmap2.
https://man7.org/linux/man-pages/man2/mmap2.2.html

Fixes #1473

PiperOrigin-RevId: 539656313
Change-Id: I7a30dd9d3eb6af03a99da0d93d721a86f6521b25
2023-06-12 08:12:42 -07:00
Abseil Team
66eae02ea7 Implement GetTID for NACL platform.
in NACL pthread_self() returns a pointer that isn't directly convertible to arithmetic type.

PiperOrigin-RevId: 539023020
Change-Id: I3745ec5565f3a99ccb1d9df12c27a80e57ca4755
2023-06-09 02:28:32 -07:00
Copybara-Service
181480b1d0 Merge pull request #1458 from juergbi:aix
PiperOrigin-RevId: 538488164
Change-Id: I680dcbc2f27dca3beba416b3cd0a55943751cf4c
2023-06-07 08:00:48 -07:00
Abseil Team
6f72305f95 Switch from perror to ABSL_INTERNAL_LOG.
Motivation is for WebAssembly to avoid perror which in turn requires file system emulation.

PiperOrigin-RevId: 536737294
Change-Id: I5177064c9451fb630ec5e9d0c0a0679fabd98afa
2023-05-31 09:32:32 -07:00
Andy Getzendanner
88cc63ef73 Implement a better GetTID on Apple platforms, and a better fallback too.
The fallback isn't totally portable, even within POSIX, but we can special case any future platforms where it's not just like this change does for Apple.

PiperOrigin-RevId: 535324103
Change-Id: Ib628925c4946b6c112373678fe37e9bb44259090
2023-05-25 11:32:45 -07:00
Andy Getzendanner
4e4b48faad Note that AsyncSignalSafeWriteToStderr preserves errno, and inline one use of it into a lambda.
PiperOrigin-RevId: 535245982
Change-Id: I816f60c8b6476536df6836500f01c9a3ad88ddd4
2023-05-25 07:10:52 -07:00
Jürg Billeter
44606a0df5 absl/base: Fix build on AIX
The AIX assembler doesn't support numeric labels. Use a relative jump
instead to fix

    Assembler:
    /tmp/ccw16WCt.s: line 25: Error In Syntax
2023-05-24 09:27:14 +02:00
Vertexwahn
421a74dce4 Fix some spelling mistakes 2023-04-24 21:25:50 +02:00
Martijn Vels
fb0debf583 Add ABSL_RAW_DLOG and ABSL_RAW_DCHECK macros
PiperOrigin-RevId: 525241200
Change-Id: I8d1536cb813da8b80a978340343b0243a49928f7
2023-04-18 13:48:58 -07:00
Abseil Team
3a46229c3c Name anonymous memory allocations on Linux.
Use Linux's prctl(PR_SET_VMA) system call to name memory arenas being
allocated using mmap(MAP_ANONYMOUS).

This change allows Abseil's memory arena(s) to be distinguished from
other uses of anonymous memory within a process, which in turn helps
investigations into the memory usage of applications.

The change adds a new prctl() system call to the code paths that call
mmap(). This is not expected to add significant overhead to applications.

The call to prctl(PR_SET_VMA, ...) can fail if the Linux kernel in use was
not configured with the CONFIG_ANON_VMA_NAME kernel option.  This should
be OK since the naming memory regions is primarily a debugging aid.

PiperOrigin-RevId: 523687348
Change-Id: Ie404e5eeef0a6da53330b3a56149c4f3bc6bf5c7
2023-04-12 06:55:11 -07:00
Derek Mauro
276f88cb77 Add an implementation of Waiter that uses std::mutex/std::condition_variable
This implementation may at some point become the default on some
platforms.  Currently not all platforms have widespread support for
both real absolute timeouts or real relative timeouts (here "real"
means without converting to the other timeout type which is the only
one supported by the underlying APIs). In this case we can defer to
their standard library to implement correct support.

This is not currently the default on any platform

Note: The size of WaiterState had to increase to fit the new implementation
PiperOrigin-RevId: 518266646
Change-Id: I7f246646a960d6e1b155f9de0bf2f681c5d3d245
2023-03-21 07:31:48 -07:00
Wiktor Garbacz
efeb95f449 Add ABSL_UNREACHABLE() to ABSL_RAW_LOG when severity is FATAL
Also makes `ABSL_INTERNAL_LOG(LEVEL(x), "oops")` not call unreachable (even when x == kFatal) for consistency.

PiperOrigin-RevId: 517894304
Change-Id: I798b1032d126330ace1e2b48edd8fc547a2ad2f8
2023-03-20 01:11:31 -07:00
Dave MacLachlan
5df3ac3b29 Add note about using CurrentThreadIdentityIfPresent() on darwin based platforms.
PiperOrigin-RevId: 515353041
Change-Id: I2c88022d50a3351f70d09a2d63020470889752d9
2023-03-09 09:11:33 -08:00
Devin Jeanpierre
02f4b99976 Delete the Throw() function from absl::base_internal.
This was originally added in order to centralize the ifdefs, in cl/164484905. However, cl/337142938 undid this aspect of the change, because it broke on Android. What is left is vestigial: `Throw()` can be deleted at no loss, with a warning that should discourage us from ever reintroducing it.

PiperOrigin-RevId: 513391041
Change-Id: I1608a2007eb26ee95df07f3b4b1672c034743832
2023-03-01 17:57:39 -08:00
Rose
fd02f6a4bd Prefer C++ notation over C
nullptr instead of 0 and nothing instead of void for function arguments is preferred.
2023-02-16 12:34:51 -05:00
Martijn Vels
75d2525117 Replace absl::base_internal::Prefetch* calls with absl::Prefetch* calls
PiperOrigin-RevId: 505184961
Change-Id: I64482558a76abda6896bec4b2d323833b6cd7edf
2023-01-27 12:37:47 -08:00
Abseil Team
f9e2a524e5 Rollback of PR #1349: direct_mmap: Use off_t on linux...
PiperOrigin-RevId: 501014555
Change-Id: Ie204d307a4e537935a04c0f23bb13532e3c84bc8
2023-01-10 09:25:09 -08:00
Copybara-Service
e160c5f534 Merge pull request #1349 from kraj:remove-off64_t
PiperOrigin-RevId: 500300819
Change-Id: Iacff97071d158843d687c811b0d78d4ddeba9039
2023-01-06 18:28:05 -08:00
Khem Raj
45fdade6c0 direct_mmap: Use off_t on linux
off64_t is not provided without defining _LARGEFILE64_SOURCE on musl
this define is not defined automatically like glibc where it gets
defined when _GNU_SOURCE is defined. Using off_t makes it portable
across musl/glibc and for using 64bit off_t on glibc 32bit systems
-D_FILE_OFFSET_BITS=64 can be defined during build via CXXFLAGS

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2022-12-28 18:28:18 -08:00
Abseil Team
7b8de741d3 Add a comment about the layout of the fields in ThreadIdentity
PiperOrigin-RevId: 498179140
Change-Id: Ie18b68e6313817b4f41fec6b10dd878436431730
2022-12-28 07:32:00 -08:00
Derek Mauro
3d646b0885 Replace ABSL_INTERNAL_UNREACHABLE with ABSL_UNREACHABLE()
PiperOrigin-RevId: 497197704
Change-Id: I3865a874e04f6f55a1ab374b03451535a86bc5a3
2022-12-22 10:47:41 -08:00
Derek Mauro
6acb60c161 Removes the legacy spellings of the thread annotation macros/functions
by default.

The compatibility macro `ABSL_LEGACY_THREAD_ANNOTATIONS` can be
defined on the compile command-line to temporarily restore these
spellings. All of the thread annotation macros are available under
ABSL_ prefixed spellings in `absl/base/thread_annotations.h`. The
compatibility macro and the legacy spellings will be removed in the
future.

See https://github.com/google/fuzztest/issues/41

PiperOrigin-RevId: 478498273
Change-Id: I120ad6480d031642bf95a11bf72ab883d9161810
2022-10-03 07:27:12 -07:00
Abseil Team
80cbb52f4d absl::base_internal::ReadLongFromFile should use O_CLOEXEC and handle interrupts to read
PiperOrigin-RevId: 477547252
Change-Id: Icc94290511b5071d15584d59dcd9cf6ad7319e2b
2022-09-28 14:07:04 -07:00
Abseil Team
df19c20996 Split configuration related to cycle clock into separate headers
PiperOrigin-RevId: 477043101
Change-Id: I009ea39ad61e7e78cdac51afc57a8ad5b4d8aa2d
2022-09-26 18:44:06 -07:00
Abseil Team
5a547f8bbd Fix "unsafe narrowing" warnings in absl, 8/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on .cc files in */internal/.)

Bug: chromium:1292951
PiperOrigin-RevId: 473868797
Change-Id: Ibe0b76e33f9e001d59862beaac54fb47bacd39b2
2022-09-12 16:05:39 -07:00
Derek Mauro
fa108c444f Rollback of fix "unsafe narrowing" warnings in absl, 8/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on .cc files in */internal/.)

Bug: chromium:1292951
PiperOrigin-RevId: 471561809
Change-Id: I7abd6d83706f5ca135f1ce3458192a498a6280b9
2022-09-01 10:09:08 -07:00
Abseil Team
847fa56a54 Fix "unsafe narrowing" warnings in absl, 8/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on .cc files in */internal/.)

Bug: chromium:1292951
PiperOrigin-RevId: 471549854
Change-Id: Id685d0e4666212926f4e001b8ef4930b6a33a4cc
2022-09-01 09:19:53 -07:00
Abseil Team
72ec15a317 Fixed header guards to match style guide conventions.
PiperOrigin-RevId: 471292183
Change-Id: Ic124d671dd3b0ae819f741885abb046cbf7e1add
2022-08-31 10:40:23 -07:00
Abseil Team
c18bb21578 spinlock.h: Clean up includes
1. Removes unused includes
2. Replaces <stdint.h> with <cstdint>

PiperOrigin-RevId: 469705016
Change-Id: Ic32871be93d01436f5538c44321faad7bd2e4511
2022-08-24 06:02:48 -07:00
Abseil Team
16af2bbcb9 Fix "unsafe narrowing" warnings in absl, 2/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on .cc files in dirs a-h.)

Bug: chromium:1292951
PiperOrigin-RevId: 464541951
Change-Id: If23b63ccea8e9b730159ff1c7288e9300a40b6bd
2022-08-01 08:30:25 -07:00
Abseil Team
7f51ef5ed2 Fix "unsafe narrowing" warnings in absl, 1/n.
Addresses failures with the following, in some files:
-Wshorten-64-to-32
-Wimplicit-int-conversion
-Wsign-compare
-Wsign-conversion
-Wtautological-unsigned-zero-compare

(This specific CL focuses on .h and win32 .inc files.)

Bug: chromium:1292951
PiperOrigin-RevId: 463835431
Change-Id: If8e5f7f651d5cd96035e23e4623bdb08a7fedabe
2022-07-28 07:46:07 -07:00
Andy Getzendanner
2c489bb5f0 Renamespace absl::raw_logging_internal to absl::raw_log_internal to match (upcoming) non-raw logging namespace.
PiperOrigin-RevId: 462213222
Change-Id: I3b9371097b368d55cc86b6106d6dec24ce122762
2022-07-20 13:11:43 -07:00
Fabrice Fontaine
53a90f079a PR #1197: absl/base/internal/direct_mmap.h: fix musl build on mips
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1197

Fix the following musl build failure on mips:

```
In file included from /nvmedata/autobuild/instance-15/output-1/build/libabseil-cpp-20211102.0/absl/base/internal/low_level_alloc.cc:26:
/nvmedata/autobuild/instance-15/output-1/build/libabseil-cpp-20211102.0/absl/base/internal/direct_mmap.h:49:10: fatal error: sgidefs.h: No such file or directory
   49 | #include <sgidefs.h>
      |          ^~~~~~~~~~~
```

Fixes:
 - http://autobuild.buildroot.org/results/3fa027e602bacb22316fb5d9b233baa0b0f0e845

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Merge c9b5b5c547 into a184bab83f

Merging this change closes #1197

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1197 from ffontaine:master c9b5b5c547
PiperOrigin-RevId: 455467767
Change-Id: I1905f7d70e914288bc1524a52adce3476a779fd8
2022-06-16 14:29:34 -07:00
Dino Radakovic
c3c49150cc absl/base/internal/invoke: Ignore bogus warnings on GCC >= 11
PiperOrigin-RevId: 455463553
Change-Id: Ifa6c238556339dd4e36715ac040ca048f2f84a9a
2022-06-16 14:09:51 -07:00
Dino Radakovic
db60907587 absl/base/internal/invoke.h: Use ABSL_INTERNAL_CPLUSPLUS_LANG for language version guard
PiperOrigin-RevId: 453970585
Change-Id: Iac23eb88ea676efc822f001020b1cc2c255dbbc1
2022-06-09 11:21:39 -07:00
Derek Mauro
9eff97861b Fix C++17 constexpr storage deprecation warnings
This change introduces the symbol
ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
to guard redundant declarations of static constexpr data
members that are needed prior to C++17.

This change also introduces the symbol
ABSL_INTERNAL_CPLUSPLUS_LANG, which is supposed to be set
to the same value as __cplusplus, except it uses _MSVC_LANG
on MSVC so that the value is correct on MSVC.

Neither of these new symbols should be used outside of Abseil.

Fixes #1191

PiperOrigin-RevId: 453923908
Change-Id: I1316c52c19fa0c168b93cced0c817e4cb7c9c862
2022-06-09 07:50:21 -07:00
Copybara-Service
fa5d5f4c26 Merge pull request #714 from kgotlinux:patch-2
PiperOrigin-RevId: 452619005
Change-Id: I6c120f9e7bbabe3b00821adc441608ae9118bee6
2022-06-02 14:13:21 -07:00
Andy Getzendanner
859c63524f Include proper #includes for POSIX thread identity implementation when using that implementation on MinGW.
Fixes #1124

PiperOrigin-RevId: 452596638
Change-Id: Iab34b8e112dc050ffe346a418fa7b499983f0dcf
2022-06-02 12:27:26 -07:00