Clean up changes to the atomic_queue
This commit is contained in:
parent
bd93955fb3
commit
8ba825d3dd
1 changed files with 25 additions and 5 deletions
30
src/external/atomic_queue/atomic_queue.h
vendored
30
src/external/atomic_queue/atomic_queue.h
vendored
|
|
@ -95,15 +95,35 @@ constexpr T& map(T* elements, unsigned index) noexcept {
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// Implement a "bit-twiddling hack" for finding the next power of 2
|
||||||
|
// in either 32 bits or 64 bits in C++11 compatible constexpr functions
|
||||||
|
|
||||||
|
// "Runtime" version for 32 bits
|
||||||
|
// --a;
|
||||||
|
// a |= a >> 1;
|
||||||
|
// a |= a >> 2;
|
||||||
|
// a |= a >> 4;
|
||||||
|
// a |= a >> 8;
|
||||||
|
// a |= a >> 16;
|
||||||
|
// ++a;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T decrement(T x) { return x - 1; }
|
constexpr T decrement(T x) {
|
||||||
|
return x - 1;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T increment(T x) { return x + 1; }
|
constexpr T increment(T x) {
|
||||||
|
return x + 1;
|
||||||
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T or_equal(T x, unsigned u) { return (x | x >> u); }
|
constexpr T or_equal(T x, unsigned u) {
|
||||||
|
return (x | x >> u);
|
||||||
|
}
|
||||||
|
|
||||||
template<class T, class... Args>
|
template<class T, class... Args>
|
||||||
constexpr T or_equal(T x, unsigned u, Args... rest)
|
constexpr T or_equal(T x, unsigned u, Args... rest) {
|
||||||
{
|
|
||||||
return or_equal(or_equal(x, u), rest...);
|
return or_equal(or_equal(x, u), rest...);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue