History

avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability

Fixes use of bultins on clang x86_64-pc-windows-msvc which does not define any __GNUC__. Also on other targets __GNUC__ is defined to 4 by default, so any feature testing based on version is not really valid.

Kacper Michajłow committed 1 year ago

Commit 43dc4431 parent f019dd62 files · +7 −9Browse files

Unified · Split

2 files
  1. libavutil/intmath.h +5 −7
  2. libavutil/x86/intmath.h +2 −2
libavutil/intmath.h+5−7
@@ -35,7 +35,7 @@ · 34 unmodified lines
35#endif35#endif
36 36
37#if HAVE_FAST_CLZ37#if HAVE_FAST_CLZ
38#if AV_GCC_VERSION_AT_LEAST(3,4)38#if AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_clz)
39#ifndef ff_log239#ifndef ff_log2
40# define ff_log2(x) (31 - __builtin_clz((x)|1))40# define ff_log2(x) (31 - __builtin_clz((x)|1))
41# ifndef ff_log2_16bit41# ifndef ff_log2_16bit
@@ -90,18 +90,16 @@ static av_always_inline av_const int ff_log2_16bit_c(unsigned int v) · 48 unmodified lines
90 */90 */
91 91
92#if HAVE_FAST_CLZ92#if HAVE_FAST_CLZ
93#if AV_GCC_VERSION_AT_LEAST(3,4)93#if !defined(ff_ctz) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_ctz))
94#ifndef ff_ctz
95#define ff_ctz(v) __builtin_ctz(v)94#define ff_ctz(v) __builtin_ctz(v)
96#endif95#endif
97#ifndef ff_ctzll96#if !defined(ff_ctzll) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_ctzll))
98#define ff_ctzll(v) __builtin_ctzll(v)97#define ff_ctzll(v) __builtin_ctzll(v)
99#endif98#endif
100#ifndef ff_clz99#if !defined(ff_clz) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_clz))
101#define ff_clz(v) __builtin_clz(v)100#define ff_clz(v) __builtin_clz(v)
102#endif101#endif
103#endif102#endif
104#endif
105 103
106#ifndef ff_ctz104#ifndef ff_ctz
107#define ff_ctz ff_ctz_c105#define ff_ctz ff_ctz_c
@@ -154,7 +152,7 @@ static av_always_inline av_const unsigned ff_clz_c(unsigned x) · 46 unmodified lines
154}152}
155#endif153#endif
156 154
157#if AV_GCC_VERSION_AT_LEAST(3,4)155#if AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_parity)
158#ifndef av_parity156#ifndef av_parity
159#define av_parity __builtin_parity157#define av_parity __builtin_parity
160#endif158#endif
libavutil/x86/intmath.h+2−2
@@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) · 65 unmodified lines
66 66
67#endif /* HAVE_FAST_CLZ */67#endif /* HAVE_FAST_CLZ */
68 68
69#if defined(__GNUC__)69#if defined(__GNUC__) || defined(__clang__)
70 70
71/* Our generic version of av_popcount is faster than GCC's built-in on71/* Our generic version of av_popcount is faster than GCC's built-in on
72 * CPUs that don't support the popcnt instruction.72 * CPUs that don't support the popcnt instruction.
@@ -81,7 +81,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) · 8 unmodified lines
81 81
82#if defined(__BMI2__)82#if defined(__BMI2__)
83 83
84#if AV_GCC_VERSION_AT_LEAST(5,1)84#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si)
85#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 285#if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
86#define av_zero_extend av_zero_extend_bmi286#define av_zero_extend av_zero_extend_bmi2
87static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p)87static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t