diff options
author | Chris Robinson <[email protected]> | 2022-12-06 01:48:58 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-12-06 01:48:58 -0800 |
commit | 4d757068c4784a18026089fd812949703bd9470a (patch) | |
tree | 1a1c2f819d14acc7a32cc26f10ffa1227c72b744 /common | |
parent | 25a6814cf36bee82b24cb1b5f40769e66c327db4 (diff) |
Avoid using a macro to wrap standard attributes
Diffstat (limited to 'common')
-rw-r--r-- | common/alcomplex.cpp | 4 | ||||
-rw-r--r-- | common/alnumeric.h | 10 | ||||
-rw-r--r-- | common/comptr.h | 2 | ||||
-rw-r--r-- | common/intrusive_ptr.h | 4 | ||||
-rw-r--r-- | common/opthelpers.h | 8 | ||||
-rw-r--r-- | common/polyphase_resampler.cpp | 16 |
6 files changed, 18 insertions, 26 deletions
diff --git a/common/alcomplex.cpp b/common/alcomplex.cpp index cce92665..a31df79c 100644 --- a/common/alcomplex.cpp +++ b/common/alcomplex.cpp @@ -101,7 +101,7 @@ complex_fft(const al::span<std::complex<Real>> buffer, const Real sign) */ const size_t log2_size{static_cast<size_t>(al::countr_zero(fftsize))}; - if(log2_size >= gBitReverses.size()) [[alunlikely]] + if(log2_size >= gBitReverses.size()) [[unlikely]] { for(size_t idx{1u};idx < fftsize-1;++idx) { @@ -116,7 +116,7 @@ complex_fft(const al::span<std::complex<Real>> buffer, const Real sign) std::swap(buffer[idx], buffer[revidx]); } } - else for(auto &rev : gBitReverses[log2_size]) [[allikely]] + else for(auto &rev : gBitReverses[log2_size]) [[likely]] std::swap(buffer[rev.first], buffer[rev.second]); /* Iterative form of Danielson-Lanczos lemma */ diff --git a/common/alnumeric.h b/common/alnumeric.h index b617b363..13e61645 100644 --- a/common/alnumeric.h +++ b/common/alnumeric.h @@ -161,11 +161,11 @@ inline int float2int(float f) noexcept shift = ((conv.i>>23)&0xff) - (127+23); /* Over/underflow */ - if(shift >= 31 || shift < -23) [[alunlikely]] + if(shift >= 31 || shift < -23) [[unlikely]] return 0; mant = (conv.i&0x7fffff) | 0x800000; - if(shift < 0) [[allikely]] + if(shift < 0) [[likely]] return (mant >> -shift) * sign; return (mant << shift) * sign; @@ -198,11 +198,11 @@ inline int double2int(double d) noexcept shift = ((conv.i64 >> 52) & 0x7ff) - (1023 + 52); /* Over/underflow */ - if(shift >= 63 || shift < -52) [[alunlikely]] + if(shift >= 63 || shift < -52) [[unlikely]] return 0; mant = (conv.i64 & 0xfffffffffffff_i64) | 0x10000000000000_i64; - if(shift < 0) [[allikely]] + if(shift < 0) [[likely]] return (int)(mant >> -shift) * sign; return (int)(mant << shift) * sign; @@ -251,7 +251,7 @@ inline float fast_roundf(float f) noexcept sign = (conv.i>>31)&0x01; expo = (conv.i>>23)&0xff; - if(expo >= 150/*+23*/) [[alunlikely]] + if(expo >= 150/*+23*/) [[unlikely]] { /* An exponent (base-2) of 23 or higher is incapable of sub-integral * precision, so it's already an integral value. We don't need to worry diff --git a/common/comptr.h b/common/comptr.h index 83f339ca..f2355d05 100644 --- a/common/comptr.h +++ b/common/comptr.h @@ -44,7 +44,7 @@ public: } ComPtr& operator=(ComPtr&& rhs) { - if(&rhs != this) [[allikely]] + if(&rhs != this) [[likely]] { if(mPtr) mPtr->Release(); mPtr = std::exchange(rhs.mPtr, nullptr); diff --git a/common/intrusive_ptr.h b/common/intrusive_ptr.h index ba932b95..5e65ba78 100644 --- a/common/intrusive_ptr.h +++ b/common/intrusive_ptr.h @@ -18,7 +18,7 @@ public: unsigned int release() noexcept { auto ref = DecrementRef(mRef); - if(ref == 0) [[alunlikely]] + if(ref == 0) [[unlikely]] delete static_cast<T*>(this); return ref; } @@ -71,7 +71,7 @@ public: } intrusive_ptr& operator=(intrusive_ptr&& rhs) noexcept { - if(&rhs != this) [[allikely]] + if(&rhs != this) [[likely]] { if(mPtr) mPtr->release(); mPtr = std::exchange(rhs.mPtr, nullptr); diff --git a/common/opthelpers.h b/common/opthelpers.h index 105ca89f..f6d9cc00 100644 --- a/common/opthelpers.h +++ b/common/opthelpers.h @@ -19,14 +19,6 @@ #define force_inline inline #endif -#if __has_attribute(likely) -#define allikely likely -#define alunlikely unlikely -#else -#define allikely -#define alunlikely -#endif - /* Unlike the likely attribute, ASSUME requires the condition to be true or * else it invokes undefined behavior. It's essentially an assert without * actually checking the condition at run-time, allowing for stronger diff --git a/common/polyphase_resampler.cpp b/common/polyphase_resampler.cpp index 76723915..5475cff8 100644 --- a/common/polyphase_resampler.cpp +++ b/common/polyphase_resampler.cpp @@ -21,7 +21,7 @@ using uint = unsigned int; */ double Sinc(const double x) { - if(std::abs(x) < Epsilon) [[alunlikely]] + if(std::abs(x) < Epsilon) [[unlikely]] return 1.0; return std::sin(al::numbers::pi*x) / (al::numbers::pi*x); } @@ -96,7 +96,7 @@ constexpr uint Gcd(uint x, uint y) constexpr uint CalcKaiserOrder(const double rejection, const double transition) { const double w_t{2.0 * al::numbers::pi * transition}; - if(rejection > 21.0) [[allikely]] + if(rejection > 21.0) [[likely]] return static_cast<uint>(std::ceil((rejection - 7.95) / (2.285 * w_t))); return static_cast<uint>(std::ceil(5.79 / w_t)); } @@ -104,7 +104,7 @@ constexpr uint CalcKaiserOrder(const double rejection, const double transition) // Calculates the beta value of the Kaiser window. Rejection is in dB. constexpr double CalcKaiserBeta(const double rejection) { - if(rejection > 50.0) [[allikely]] + if(rejection > 50.0) [[likely]] return 0.1102 * (rejection - 8.7); if(rejection >= 21.0) return (0.5842 * std::pow(rejection - 21.0, 0.4)) + @@ -171,13 +171,13 @@ void PPhaseResampler::init(const uint srcRate, const uint dstRate) // polyphase filter implementation. void PPhaseResampler::process(const uint inN, const double *in, const uint outN, double *out) { - if(outN == 0) [[alunlikely]] + if(outN == 0) [[unlikely]] return; // Handle in-place operation. std::vector<double> workspace; double *work{out}; - if(work == in) [[alunlikely]] + if(work == in) [[unlikely]] { workspace.resize(outN); work = workspace.data(); @@ -195,17 +195,17 @@ void PPhaseResampler::process(const uint inN, const double *in, const uint outN, // Only take input when 0 <= j_s < inN. double r{0.0}; - if(j_f < m) [[allikely]] + if(j_f < m) [[likely]] { size_t filt_len{(m-j_f+p-1) / p}; - if(j_s+1 > inN) [[allikely]] + if(j_s+1 > inN) [[likely]] { size_t skip{std::min<size_t>(j_s+1 - inN, filt_len)}; j_f += p*skip; j_s -= skip; filt_len -= skip; } - if(size_t todo{std::min<size_t>(j_s+1, filt_len)}) [[allikely]] + if(size_t todo{std::min<size_t>(j_s+1, filt_len)}) [[likely]] { do { r += f[j_f] * in[j_s]; |