24 #ifndef PPL_compiler_hh
25 #define PPL_compiler_hh 1
33 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
38 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
39 #define PPL_USED(v) (void)(v)
41 #ifdef PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS
46 #endif // defined(PPL_DOXYGEN_INCLUDE_IMPLEMENTATION_DETAILS)
50 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
51 __asm__ __volatile__ (
"" :
"+m" (const_cast<T&>(x)));
58 #ifndef PPL_SUPPRESS_UNINIT_WARNINGS
59 #define PPL_SUPPRESS_UNINIT_WARNINGS 1
62 #ifndef PPL_SUPPRESS_UNINITIALIZED_WARNINGS
63 #define PPL_SUPPRESS_UNINITIALIZED_WARNINGS 1
66 #if PPL_SUPPRESS_UNINITIALIZED_WARNINGS
72 #define PPL_UNINITIALIZED(type, name) \
73 PPL_U(type) PPL_U(name) \
74 = Suppress_Uninitialized_Warnings_Type<PPL_U(type)>::synonym()
76 #define PPL_UNINITIALIZED(type, name) \
80 #define sizeof_to_bits(size) \
81 ((size) * static_cast<std::size_t>(CHAR_BIT))
83 #if !defined(__GNUC__)
88 if ((w & 0xffff0000U) != 0) {
92 if ((w & 0xff00U) != 0) {
96 if ((w & 0xf0U) != 0) {
100 if ((w & 0xcU) != 0) {
104 if ((w & 0x2U) != 0) {
112 if ((w & 0xffffffff00000000ULL) == 0) {
113 return clz32(static_cast<uint32_t>(w)) + 32;
116 return clz32(static_cast<uint32_t>(w >> 32));
122 static const unsigned int mod37_table[] = {
123 32, 0, 1, 26, 2, 23, 27, 0, 3, 16, 24, 30, 28, 11, 0, 13,
124 4, 7, 17, 0, 25, 22, 31, 15, 29, 10, 12, 6, 0, 21, 14, 9,
127 return mod37_table[(w & -w) % 37];
132 if ((w & 0x00000000ffffffffULL) == 0) {
133 return ctz32(static_cast<uint32_t>(w >> 32)) + 32;
136 return ctz32(static_cast<uint32_t>(w));
145 #if defined(__GNUC__)
146 return static_cast<unsigned int>(__builtin_clz(u));
147 #elif PPL_SIZEOF_INT == 4
149 #elif PPL_SIZEOF_INT == 8
152 #error "Unsupported unsigned int size"
159 #if defined(__GNUC__)
160 return static_cast<unsigned int>(__builtin_clzl(ul));
161 #elif PPL_SIZEOF_LONG == 4
163 #elif PPL_SIZEOF_LONG == 8
166 #error "Unsupported unsigned long size"
171 clz(
unsigned long long ull) {
173 #if defined(__GNUC__)
174 return static_cast<unsigned int>(__builtin_clzll(ull));
175 #elif PPL_SIZEOF_LONG_LONG == 4
177 #elif PPL_SIZEOF_LONG_LONG == 8
180 #error "Unsupported unsigned long long size"
188 #if defined(__GNUC__)
189 return static_cast<unsigned int>(__builtin_ctz(u));
190 #elif PPL_SIZEOF_INT == 4
192 #elif PPL_SIZEOF_INT == 8
195 #error "Unsupported unsigned int size"
202 #if defined(__GNUC__)
203 return static_cast<unsigned int>(__builtin_ctzl(ul));
204 #elif PPL_SIZEOF_LONG == 4
206 #elif PPL_SIZEOF_LONG == 8
209 #error "Unsupported unsigned long size"
214 ctz(
unsigned long long ull) {
216 #if defined(__GNUC__)
217 return static_cast<unsigned int>(__builtin_ctzll(ull));
218 #elif PPL_SIZEOF_LONG_LONG == 4
220 #elif PPL_SIZEOF_LONG_LONG == 8
223 #error "Unsupported unsigned long long size"
229 #endif // !defined(PPL_compiler_hh)
unsigned int ctz(unsigned int u)
unsigned int clz64(uint64_t w)
unsigned int ctz32(uint32_t w)
unsigned int ctz64(uint64_t w)
void PPL_CC_FLUSH(const T &x)
No-op function that force the compiler to store the argument and to reread it from memory if needed (...
The entire library is confined to this namespace.
unsigned int clz(unsigned int u)
#define PPL_USED(v)
No-op macro that allows to avoid unused variable warnings from the compiler.
unsigned int clz32(uint32_t w)