312 Commits

Author SHA1 Message Date
Abseil Team
852fc61f31 Remove more lingering C++17 type traits polyfill usages
This will let us deprecate the declarations without triggering warnings in Abseil itself.

PiperOrigin-RevId: 906360966
Change-Id: Iee362ac0eac647909ef38003280f1179813f764d
2026-04-27 08:03:53 -07:00
Mike Kruskal
7dac70835c Expose gloop peer friendship for testing
PiperOrigin-RevId: 895336821
Change-Id: I178e7d654e45de4af6bba133b496115c6d37adc1
2026-04-06 08:17:56 -07:00
Mike Kruskal
1bcce1bda4 Internal functionality
PiperOrigin-RevId: 882667993
Change-Id: I47f0d92b58caa9cc137ae92e8b568277dd9b1d78
2026-03-12 10:37:49 -07:00
Mike Kruskal
45c8989b87 Add a visibility placeholder to Abseil for Gloop.
PiperOrigin-RevId: 875292936
Change-Id: I5622f33f8d6581ca3f55783579f612e3e5c4822f
2026-02-25 12:48:48 -08:00
Abseil Team
28e6a799ba Make absl::Condition work with C++23 deducing-this
Closes: #1992
PiperOrigin-RevId: 857136106
Change-Id: Iae31d7c6c9a0fda16ebf2c4f68764da521d036bf
2026-01-16 06:34:20 -08:00
Derek Mauro
6d8e1a5cf0 Mark legacy Mutex methods and MutexLock pointer constructors as deprecated
Updates `absl::Mutex` and related RAII lockers (`absl::MutexLock`,
etc) to deprecate legacy APIs in favor of standard-compliant
alternatives.
  * `absl::Mutex`: Adds `[[deprecated]]` to legacy CamelCase methods
    (e.g., `Lock`, `ReaderLock`) in favor of standard C++ lower-case
    methods (`lock`, `lock_shared`) which support `std::scoped_lock`.
  * `absl::MutexLock` (and friends): Adds `[[deprecated]]` to
    constructors accepting raw pointers, favoring new
    reference-accepting constructors.

To support this change, warnings coming from external repositories
are now suppressed in Bazel CI builds.

PiperOrigin-RevId: 852978576
Change-Id: I54ae951f28a1b7d90fcb46ceeaf09f192af257df
2026-01-06 16:22:35 -08:00
Derek Mauro
de9ab52205 No-op changes to relative timeout support code.
PiperOrigin-RevId: 847827629
Change-Id: I84dec0fafa6cdbb8ffee013f9d5ad9b3cb977ee4
2025-12-22 11:19:58 -08:00
Abseil Team
e6a6acdca4 Fixed incorrect include for ABSL_NAMESPACE_BEGIN
PiperOrigin-RevId: 831364966
Change-Id: Ib2b3346523ffa1627899b1d6df55e3a9d9c41260
2025-11-12 06:40:49 -08:00
Abseil Team
18ac608307 Export Mutex::Dtor from shared libraries in NDEBUG mode
When Abseil is built as a shared library (`ABSL_BUILD_DLL`) with `NDEBUG` defined, `Mutex::Dtor()` is currently fully inlined and no symbol is emitted.

Downstream clients building against this shared library without `NDEBUG` defined (e.g., a debug build of an application linking against a system-provided release Abseil DLL) will expect a `Mutex::Dtor()` symbol to exist, ensuring ABI compatibility. Currently, this leads to undefined reference linker errors.

This patch aligns `Mutex::Dtor()` with the existing logic for `Mutex::~Mutex()`: it disables inlining in the header when `ABSL_BUILD_DLL` is active and ensures an empty definition is provided in the source file for these builds.

PiperOrigin-RevId: 828160210
Change-Id: I5ed1fd6757d631e80d6f084d20bfe8e25f6ef253
2025-11-04 15:33:27 -08:00
Jesse Rosenstock
820cd9ee90 type_traits: Add type_identity and type_traits_t backfills
https://en.cppreference.com/w/cpp/types/type_identity.html

PiperOrigin-RevId: 812886166
Change-Id: I159cf4e4bdbe2ac801768ff6c996c2d2a3d47a71
2025-09-29 12:03:04 -07:00
Abseil Team
768f75440f Fixed up some #includes in mutex.h
PiperOrigin-RevId: 807378888
Change-Id: Ic4e11444b4839228c365c68321848c954bf67e63
2025-09-15 14:14:49 -07:00
Abseil Team
7fc86c6786 Fix inconsistent nullability annotation in ReleasableMutexLock
ReleasableMutexLock::Release() resets this pointers, so destructor can compare
it to nullptr, to avoid double release.
PiperOrigin-RevId: 803163168
Change-Id: Ib97f86a4e5fca789552b1a8c385868d4227b9874
2025-09-04 13:56:08 -07:00
Abseil Team
18ab653605 Automated Code Change
PiperOrigin-RevId: 794920077
Change-Id: I8f2c2ec4b8ff86de5fd6812c0225441425ea32a1
2025-08-14 01:06:04 -07:00
Abseil Team
81dff3b24f Move comment specific to pointer-taking MutexLock variant to its definition.
PiperOrigin-RevId: 791367956
Change-Id: I85d1f0962886a5b24651930122fd152b4cb66f30
2025-08-05 14:21:34 -07:00
Chris Kennelly
6a91068203 Add lifetime annotations to MutexLock, SpinLockHolder, etc.
PiperOrigin-RevId: 791269651
Change-Id: Ie3ad265f6ab6535a3240fb159ba498f5a6bb15ce
2025-08-05 10:19:40 -07:00
Chris Kennelly
5ee41ba787 Remove comment mentioning deferenceability.
This is implicit from the reference.

PiperOrigin-RevId: 791229648
Change-Id: I80145d0ec422ce1f54c19651d2fbc0d52692c1ae
2025-08-05 08:39:22 -07:00
Chris Kennelly
097d0d80cd Add referenceful MutexLock with Condition overload.
PiperOrigin-RevId: 790787285
Change-Id: I571a6cf6e0f3940f7022d4d3ba89dc7fd2693db8
2025-08-04 09:48:09 -07:00
Chris Kennelly
f67705a410 Whitespace change
PiperOrigin-RevId: 790764902
Change-Id: I09ec1bf76b5bd57363c2b8781af5de62c3c1b78d
2025-08-04 08:45:07 -07:00
Chris Kennelly
d473c92b9e Inline internal usages of Mutex::Lock, etc. in favor of lock.
PiperOrigin-RevId: 789459507
Change-Id: I573dec1c33b047388509cfea129342ea7bdfe494
2025-07-31 13:51:06 -07:00
Chris Kennelly
0f1abc9b73 Inline internal usages of pointerful SpinLockHolder/MutexLock.
PiperOrigin-RevId: 789441157
Change-Id: I2ed5d12f4b9725edbe3fd6cf629a0563a2f2d739
2025-07-31 12:59:26 -07:00
Chris Kennelly
785b11b33f Accept references on SpinLockHolder/MutexLock
This aligns these classes more closely with std::scoped_lock.

PiperOrigin-RevId: 788920634
Change-Id: If29e8092b782bfbb11a1da31834dc738f1cbcfbc
2025-07-30 09:00:30 -07:00
Chris Kennelly
56945519b5 Fix typos in comments.
PiperOrigin-RevId: 788575830
Change-Id: I10d97c367472edd89efd59eda455764285f6ad88
2025-07-29 13:12:26 -07:00
Chris Kennelly
3e0d9ff64a Inline SpinLock Lock->lock, Unlock->unlock internal to Abseil.
PiperOrigin-RevId: 788531193
Change-Id: Icca9ff096c2ec2fc0662f1f94ecfb232a8492974
2025-07-29 11:12:36 -07:00
Chris Kennelly
1f28b48632 Rename Mutex methods to use the typical C++ lower case names.
PiperOrigin-RevId: 788502749
Change-Id: Ibb2a8d46eca84dd87011c8e1bbd20b829f211ea4
2025-07-29 10:09:07 -07:00
Abseil Team
18dd270ff9 Adds required load statements for C++ rules to BUILD and bzl files.
PiperOrigin-RevId: 786301329
Change-Id: I342de39e40e90c82501baac9858291b7c4d5c2d0
2025-07-23 08:59:55 -07:00
Evan Brown
492fccd3ba Skip flaky expectations in waiter_test for MSVC.
PiperOrigin-RevId: 782040454
Change-Id: Ia51834a4c871b6bbf4748805656b7e68169239d6
2025-07-11 11:01:41 -07:00
Abseil Team
2b320cbfaa Fix includes and fuse constructors of SpinLock.
PiperOrigin-RevId: 774835829
Change-Id: I0fa7cab1b98c1b7222de0acd71b7846df693f1e2
2025-06-23 10:32:42 -07:00
Vitaly Goldshteyn
fdf821ec60 Add tags to skip some tests under UBSAN.
PiperOrigin-RevId: 758783019
Change-Id: I3b5d6a7cce9a001a7dbc3edb9dd5c7e9132b33dd
2025-05-14 12:14:46 -07:00
Thomas Schenker
9768012425 PR #1884: Remove duplicate dependency
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1884

Remove a duplicated dependency to `absl::tracing_internal`.
Merge 6805baed96 into 9a89ea8714

Merging this change closes #1884

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1884 from schenker:delete-duplicate-dependency 6805baed96
PiperOrigin-RevId: 757896259
Change-Id: I3eecc788e2ec995bd1320345749b5fe4046cbea4
2025-05-12 13:46:41 -07:00
Laramie Leavitt
3870e283fb Use absl::InsecureBitGen in place of std::random_device in Abseil tests.
PiperOrigin-RevId: 750721356
Change-Id: I84e8a1c2a80335983e557270ef78b8b0b4f1e452
2025-04-23 14:16:54 -07:00
Abseil Team
f9ea7cf87d Fully annotate nullability in headers where it is partially annotated.
To support building abseil with -Wnullability-completeness flag

PiperOrigin-RevId: 741425018
Change-Id: I894049b80149198a1ab242efd88af8b8df826ba4
2025-03-28 00:27:33 -07:00
Abseil Team
d79e680580 Add nullability annotations to some very-commonly-used APIs.
Manual annotation of these APIs specifically helps us avoid inferring them with tooling as having conflicted nullability due to a small number of incorrect uses out of many, many uses.

These annotations have no runtime impact.

PiperOrigin-RevId: 739258146
Change-Id: Id18bd1f0313c5b196e1d9e8ed4d1ce057dfcd582
2025-03-21 12:11:24 -07:00
CJ Johnson
930a70d12e PR #1860: Add unsigned to character buffers to ensure they can provide storage (https://eel.is/c++draft/intro.object#3)
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1860

I just learned today that `char` cannot "provide storage" in the way I previously thought. Only `std::byte` and `unsigned char` are allowed. So I decided to fix my past mistakes in `absl::InlinedVector` and `absl::Cleanup` as well as any others I could find in Abseil. See: https://eel.is/c++draft/intro.object#3

Merge ae9c1ef57a into c4ff4d561c

Merging this change closes #1860

COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1860 from CJ-Johnson:master ae9c1ef57a
PiperOrigin-RevId: 739220589
Change-Id: I533b040e4cf4ee2f48008affb6603c25f34d5b4b
2025-03-21 10:11:45 -07:00
Derek Mauro
67cab0c465 Cleanups related to benchmarks
* Fix many benchmarks to be cc_binary instead of cc_test
  * Add a few benchmarks for StrFormat
  * Add benchmarks for Substitute
  * Add benchmarks for Damerau-Levenshtein distance used in flags

PiperOrigin-RevId: 738448552
Change-Id: I521f4b2ef9116c9895b44c32d27e94507380bee8
2025-03-19 10:21:06 -07:00
Derek Mauro
0856410fc6 graphcycles_test: Avoid applying a non-zero offset to a null pointer
Applying a non-zero offset to a null pointer is undefined behavior.

Our UBSAN tests were missing `-fno-sanitize-recover`, which
means UBSAN logs a warning, but the program continues,
causing the test not to fail.

`-fno-sanitize-recover` will be added once all errors are fixed.

PiperOrigin-RevId: 733395060
Change-Id: Ibf71d0d2a27fac14f0c33dbdf83f4089645b8b37
2025-03-04 11:08:39 -08:00
Derek Mauro
1af129f1c3 Use C++17 [[nodiscard]] instead of the deprecated ABSL_MUST_USE_RESULT
In this change, //absl/status is intentionally excluded because of
complication with SWIG compatibility. This may be handled separately.

PiperOrigin-RevId: 731387819
Change-Id: I71bf2e02f3a477d65575d467f5e5ab163846d31e
2025-02-26 11:16:38 -08:00
Derek Mauro
ea9951d3a9 MSVC: Fix warnings c4244 and c4267 in the main library code
These are integer-type shortening warnings.
These warnings are still disabled in tests.

c4244: conversion from 'type1' to 'type2', possible loss of data
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-levels-3-and-4-c4244?view=msvc-170
c4267: conversion from 'size_t' to 'type', possible loss of data
https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4267?view=msvc-170

Fixes https://github.com/abseil/abseil-cpp/issues/1844

PiperOrigin-RevId: 730882892
Change-Id: Id6506d71846caf1a6a5be3375c34266299c221e1
2025-02-25 07:44:44 -08:00
Derek Mauro
feb3d276d4 Remove ABSL_INTERNAL_NEED_REDUNDANT_CONSTEXPR_DECL
which is longer needed with the C++17 floor

PiperOrigin-RevId: 729365281
Change-Id: Ife5e778ead193bb37150b9799099e92f53252cb4
2025-02-20 21:07:28 -08:00
Evan Brown
c8977ff7b5 Avoid flaky expectation in WaitDurationWoken test case in MSVC.
PiperOrigin-RevId: 715017153
Change-Id: Icbbf70f3694e3a098b2c150eb927bfb0d2504d52
2025-01-13 10:14:56 -08:00
Derek Mauro
f4af6c0072 Use Bazel rules_cc for many compiler-specific rules
instead of our custom ones from before the Bazel rules existed.

Also add the missing rules_cc to WORKSPACE, since we already had
it in MODULE.bazel

PiperOrigin-RevId: 715006932
Change-Id: Ibb38a78c115a7dc2983426455bb271162795846f
2025-01-13 09:53:07 -08:00
Derek Mauro
90a7ba66e8 Updates to CI to support newer versions of tools
Linux "latest" containers updated to
GCC 14.2
CMake 3.31.2
Bazel 8.0.0

Included are various fixes to get these versions to work.

Bazel now references repositories by their canonical names from the
Bazel Central Registry. For example, Abseil is now @abseil-cpp instead
of @com_google_absl, and GoogleTest is now @googletest instead of
@com_google_googletest. Users still using the old WORKSPACE system may
need to use `repo_mapping` on repositories using the old names. See
`WORKSPACE.bazel` in this commit for an example.

PiperOrigin-RevId: 709102146
Change-Id: I02327ed4f8fb947766480bdeef2b1930a7f831eb
2024-12-23 10:58:05 -08:00
Evan Brown
63c03fec44 Avoid flakiness in notification_test on MSVC.
PiperOrigin-RevId: 708348881
Change-Id: I261eec13ec78aa13cf9a51dc45cee777f0a1db5e
2024-12-20 09:45:05 -08:00
piotrzielinski
482ca0b9d6 Small Mutex::Unlock optimization
Saving one "&" operation in the Mutex::Unlock fast path. This has likely no performance impact (the two AND instructions ran in parallel anyway), but is as complex as the current solution, and enables two possible improvements in the future.

1. If bits Ev, Wr, Wa, De are made into the highest bits in the kMuLow,
   then the second "&" operation can be omitted because if kMuWriter is set,
   the there are no readers, so the kMuHigh bits are zero.

2. If the meanings of kMuWriter and kMuDesig are flipped, then the "^"
   operation is not needed either.

PiperOrigin-RevId: 679272590
Change-Id: Iea7a04df0118d2410b7bfdab70b30e33d4b90e43
2024-09-26 13:31:57 -07:00
Abseil Team
162dc789f1 It seems like commit abc9b916a9 did not work as intended.
PiperOrigin-RevId: 676486501
Change-Id: I874097a85486534150ce4c2f814d20be9d8b3b1f
2024-09-19 11:09:27 -07:00
Abseil Team
abc9b916a9 Attempt to fix flaky Abseil waiter/sleep tests
The existing implementation uses wall-clock time. However, wall clock can drastically differ from the internal system clock, because the system can be suspended and then resumed.

We want to account for at least some kinds of suspensions that might occur during automated testing, such as VM suspension or hypervisor preemption ("steal time"). These are tricky cases, because the physical (host) CPU is still running -- just the logical (guest) virtual CPU isn't. Therefore, we need to ensure that our time measurements exclude elapsed host-only time.

Unfortunately the correctness of a method depends on the nature & configuration of each VM and the guest. For example, it can depend whether RDTSC is virtualized, or on whether the host and guest support accounting for steal time. Windows, for example, appears to only support steal time measurements if the hypervisor is Hyper-V.

Since this is all for the sake of testing, we use a simpler trick that we hope will work around the problem on our systems: we subtract the so-called "interrupt time bias" from the system uptime in Windows. The interrupt time bias includes sleep/hibernation time, and seems to advance during for VM suspensions as well, so it may take care of the problem.

PiperOrigin-RevId: 675654840
Change-Id: I66150b18912175fa72609d3f137e3ea4fee8fc43
2024-09-17 11:59:38 -07:00
Abseil Team
70502ae69d Add comments about ThreadIdentity struct allocation behavior.
PiperOrigin-RevId: 662586240
Change-Id: Ibee60b935da5d8135ac99b6caf00b3c035ecfd89
2024-08-13 11:19:06 -07:00
Martijn Vels
bb63788b4b Add tracing annotations to absl::Notification
PiperOrigin-RevId: 656188416
Change-Id: I43d901d99f8a4688406b8aab08bc2655a065af46
2024-07-25 19:12:40 -07:00
Martijn Vels
034f8d0598 Add tracing annotations to absl::BlockingCounter
PiperOrigin-RevId: 656010740
Change-Id: I99ef6f18502a0cb2c363c805ae5f9a9a42bd3b41
2024-07-25 10:54:32 -07:00
Abseil Team
0d9c2fc763 Replace signed integer overflow, since that's undefined behavior, with unsigned integer overflow.
PiperOrigin-RevId: 648730502
Change-Id: I662c365c59be9e51f565fd215d284a96b7bd8743
2024-07-02 08:41:39 -07:00
Evan Brown
93763764d7 Disable flaky test cases in kernel_timeout_internal_test.
PiperOrigin-RevId: 645054874
Change-Id: Ic4a820b47edfa71bd3e1f149d54f00ac3c1d16a6
2024-06-20 09:12:48 -07:00