Also include portable fallbacks for other compilers. They don't produce good error messages, but they do prevent silent breakages on other platforms/toolchains.
PiperOrigin-RevId: 723629074
Change-Id: I29ee8fbc679b70bb67d42577d0723b52268f7caf
I am still keeping `SooSlotMemcpySize` that may be 1, 4, 8 or 16. Microbenchmarks showed that it is useful to have compile time memcpy. In the long run, when/if more types will become trivially transferable and a potential increase of the SOO maximal size, this optimization can become (even) more useful. So I would stick with it for the time being.
`SooSlotMemcpySize` is always zero for non SOO types or not memcpyable types.
So as a result we merge all sizes for non SOO or non transferable types.
For memcpyable SOO types we have 4 options.
PiperOrigin-RevId: 723233539
Change-Id: If38c69527a2f873c07ce869bf3ca609fc7371a07
Call to `SampleSlow` was happening in SOO tables on insert.
That increases binary size in the hot place.
With this change only verification of whether sample needs to be done is performed.
PiperOrigin-RevId: 723201811
Change-Id: I75eba1c4803390587edc9342a177d4ed5eaf342c
The implementations for these functions changed recently to no longer zero pad and instead duplicate input bytes. Also remove a TODO that has been done.
PiperOrigin-RevId: 722793915
Change-Id: Ib5c3d444530270d227ec1636935925acc4d8dc0c
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1819
Fix the following error:
absl/random/internal/randen_detect.cc:123:12: error: no member named 'nullopt' in namespace 'std'; did you mean 'absl::nullopt'?
123 | return std::nullopt;
| ^~~~~~~~~~~~
| absl::nullopt
absl/types/optional.h:86:43: note: 'absl::nullopt' declared here
86 | ABSL_INTERNAL_INLINE_CONSTEXPR(nullopt_t, nullopt,
| ^
Merge b9a2d3920a into 7253ff8f95
Merging this change closes#1819
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1819 from clementperon:master b9a2d3920a
PiperOrigin-RevId: 722599523
Change-Id: Ie66cbf9daf3b115668194da8b74acd6a43e12a03
That reduces binary size by moving more code to type erased InitializeSlots.
It also make SOO element to be moved once that can be useful for expensive to move types.
PiperOrigin-RevId: 721938625
Change-Id: I449753440fe91cb1bb5a1569e23d1986f5b0a642
implementations that use a branch marked unreachable so that it is
usable in more contexts.
The unimplemented case now uses the same definition as ABSL_ASSERT
when NDEBUG is defined.
Fixes https://github.com/abseil/abseil-cpp/issues/1814
PiperOrigin-RevId: 720236336
Change-Id: I4f4f6e8a384dd11a07626b085a001fc2f5b7db21
raw_hash_set is an internal class, and the API comments are mostly targeted towards implementers rather than users. Note that the public API comments are in the public headers, e.g. flat_hash_set.h.
PiperOrigin-RevId: 720199830
Change-Id: I0b0a31a1b905696fb9da7706105b7fb4117a90c3
This is already documented by a [test case](fd8b35b9aa/absl/log/scoped_mock_log_test.cc (L218)), but it would have been nicer to just read about it in the header file.
PiperOrigin-RevId: 719021749
Change-Id: I058eeec77d6c54b906ad449221b09222be59f898
The sized constructors, reserve(), and rehash() methods of
absl::{flat,node}_hash_{set,map} did not impose an upper bound on
their size argument. As a result, it was possible for a caller to pass
a very large size that would cause an integer overflow when computing
the size of the container's backing store. Subsequent accesses to the
container might then access out-of-bounds memory.
The fix is in two parts:
1) Update max_size() to return the maximum number of items that can be
stored in the container
2) Validate the size arguments to the constructors, reserve(), and
rehash() methods, and abort the program when the argument is invalid
We've looked at uses of these containers in Google codebases like
Chrome, and determined this vulnerability is likely to be difficult to
exploit. This is primarily because container sizes are rarely
attacker-controlled.
The bug was discovered by Dmitry Vyukov <dvyukov@google.com>.
PiperOrigin-RevId: 718841870
Change-Id: Ic09dc9de140a35dbb45ab9d90f58383cf2de8286
The __builtin_cpu_supports path seems to cause problems on certain builds, let's remove it.
PiperOrigin-RevId: 717993600
Change-Id: I69568c17dc768a5edd097709884ba07f2c78db91
non_temporal_store_memcpy_avx uses gnu::target("avx") to use AVX intrinsics
inside its function body even if the compiler was not configured for AVX
support. This is OK because non_temporal_store_memcpy_avx is guarded by a cpuid
check before it is called.
However, non_temporal_memcpy_test.cc performs no such cpuid guard. In practice,
nobody will really notice this bug as CPUs have had AVX for a long time by now.
That said, this does come up if one has compiled absl for x86_64 and runs the
binary on a arm64 Mac. This is because the Rosetta 2 emulation environment does
not support AVX or newer instructions.
PiperOrigin-RevId: 717991751
Change-Id: Id41bd186ebfd1cf7124ab5211fbfb74a01d5b56c
It seems that this feature is not fully baked on all build configurations, let's remove it for now.
PiperOrigin-RevId: 716825311
Change-Id: I2ea9d941f8f3f177f9eb2afbd737935d58923780
library to prevent some exit-time destructor warnings
This is the convention in the rest of Abseil.
PiperOrigin-RevId: 716767392
Change-Id: Ie7e1df54e79eba9057fbaeea000f63b6ec9929bc
Note that the error message says downgrade to 0.0.15, but I'm not sure
why. 0.0.17 is the latest.
```
ERROR: Error computing the main repository mapping: Yanked version detected in your resolved dependency graph: rules_cc@0.1.0, for the reason: rules_cc 0.1.0 is yanked due to incompatible change (prematurely removing cc_proto_library from defs.bzl), please downgrade to 0.0.15.
```
PiperOrigin-RevId: 716675841
Change-Id: I459c35186161cc3d10b8c38973041d9a592c7cec
This lets us dynamically determine if we should attempt to use HW
instructions for AES.
PiperOrigin-RevId: 716350656
Change-Id: I1ead17b7b44373850b3591307b7f6d3f9147d5f9
Otherwise we can observe a build failure when absl::optional != std::optional.
PiperOrigin-RevId: 716275922
Change-Id: I4918a8901530f0daafeec07e319fd79123358bc1
This is a followup to the change to use ARM hashing techniques in absl. I didn't realize the distinction between rev/rbit originally, but we expect that rbit will result in better hash quality at the same latency.
LLVM-MCA rev: https://godbolt.org/z/94Mo71TKd
LLVM-MCA rbit: https://godbolt.org/z/nK8bMfeKf
PiperOrigin-RevId: 715443087
Change-Id: Ic05608851529d1447ed11557e7f430a088a4efcd
With a newer clang, we can use __builtin_cpu_supports which caches all
the feature bits.
If we are using an older clang, we fall back to querying sysctlbyname
for the relevant processor features.
PiperOrigin-RevId: 715153229
Change-Id: I570fa349f96829d5da3b32c928480ddf67176cad
We introduce combine_raw as an implementation detail of HashState that allows for keeping the same IntegralFastPath implementation but to have separately optimized Read*To* functions for the string hashing use case.
PiperOrigin-RevId: 715122407
Change-Id: Iabe35d2d3ecbca5d134a782378b7ecb2e3b9aac6
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
This will allow catching some lifetime issues such as the following:
```
absl::flat_hash_set<absl::string_view> s;
s.add(std::string(...)); // dangling
```
PiperOrigin-RevId: 714123078
Change-Id: I67f382e97fa8d5e2dc2b58a1ccb8cc013819e4b3