|
ADS
Algorithms and Data Structures
|
The primitives of the processor that the compilers spell each in their own way, in one form for all: the product of two words of 64 bits by the products of their halves of 32 bits (wideProductHalves(), the portable form of the product of Wide.h), and the swap of the bytes of a word, which is the std::byteswap() of C++23 where the library has it, else the boost::core::byteswap() of Boost.Core where Boost is found, else three exchanges by masks, of the bytes, of the pairs of bytes and of the halves. More...
#include <bit>#include <compare>#include <concepts>#include <cstdint>#include <type_traits>Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Macros | |
| #define | ADS_BYTESWAP_BOOST 0 |
| #define | ADS_NO_UNIQUE_ADDRESS [[no_unique_address]] |
| an empty member that takes no storage, by the attribute that does so (the standard one is accepted but has no effect under the ABI of MSVC) | |
| #define | ADS_ALWAYS_INLINE inline |
| a function inlined even where the compiler would not | |
| #define | ADS_NOINLINE |
| a function never inlined | |
| #define | ADS_COLD_PATH ADS_NOINLINE |
| a function of a rare path: never inlined, laid out away from the hot code | |
| #define | ADS_POISON(p, n) |
| the \( n \) bytes from \( p \) forbidden, and allowed again, under the sanitizer of addresses, by the macros of its interface, which the interface itself turns into no code when the sanitizer is off; no code where the toolchain has no such interface | |
| #define | ADS_UNPOISON(p, n) |
The primitives of the processor that the compilers spell each in their own way, in one form for all: the product of two words of 64 bits by the products of their halves of 32 bits (wideProductHalves(), the portable form of the product of Wide.h), and the swap of the bytes of a word, which is the std::byteswap() of C++23 where the library has it, else the boost::core::byteswap() of Boost.Core where Boost is found, else three exchanges by masks, of the bytes, of the pairs of bytes and of the halves.
The rest of the arithmetic of two words (the product by the instruction of the processor, the division of two words by one and the signed integers of 128 bits) is in Wide.h. They are details of the implementation, out of the API reference, and their arithmetic is on the theory page of the area.
Two attributes have the same fate: ADS_NO_UNIQUE_ADDRESS, the [[no_unique_address]] of C++20 under the name that MSVC honors ([[msvc::no_unique_address]], since MSVC accepts the standard spelling and ignores it), so that an empty member takes no storage with every compiler; and ADS_COLD_PATH, a function that is never inlined and is laid out away from the hot code ([[gnu::cold, gnu::noinline]], the noinline of MSVC), which keeps the rare path of an operation, e.g., the notification of its observers, out of the code of the common one. Under the sanitizer of addresses, ADS_POISON( p , n ) and ADS_UNPOISON( p , n ) mark the \( n \) bytes from \( p \) as forbidden and allowed again, so that a pool which drops its objects at once (the clear() of Arena and ObjectPool) makes the sanitizer stop a stale pointer at its first access; elsewhere they are no code, which the interface of the sanitizer decides by itself (its macros are empty when it is off), so that ADS needs not know whether it is on.
| #define ADS_BYTESWAP_BOOST 0 |
| #define ADS_UNPOISON | ( | p, | |
| n ) |