aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/intmath.h
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2025-03-31 14:02:36 +0200
committerMartin Storsjö <martin@martin.st>2025-06-12 14:17:37 +0300
commit43dc443446e48614323bd1f083e90ae11ea66827 (patch)
treeae3b68d077fba54486b12b6e5d9ec2e290850456 /libavutil/intmath.h
parentf019dd69f0f5ecd89add139784cf37148af56bd0 (diff)
downloadffmpeg-43dc443446e48614323bd1f083e90ae11ea66827.tar.gz
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. Signed-off-by: Kacper Michajłow <kasper93@gmail.com> Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavutil/intmath.h')
-rw-r--r--libavutil/intmath.h12
1 files changed, 5 insertions, 7 deletions
diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index 52e11a8d5f..b177a848c6 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -35,7 +35,7 @@
#endif
#if HAVE_FAST_CLZ
-#if AV_GCC_VERSION_AT_LEAST(3,4)
+#if AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_clz)
#ifndef ff_log2
# define ff_log2(x) (31 - __builtin_clz((x)|1))
# ifndef ff_log2_16bit
@@ -90,18 +90,16 @@ static av_always_inline av_const int ff_log2_16bit_c(unsigned int v)
*/
#if HAVE_FAST_CLZ
-#if AV_GCC_VERSION_AT_LEAST(3,4)
-#ifndef ff_ctz
+#if !defined(ff_ctz) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_ctz))
#define ff_ctz(v) __builtin_ctz(v)
#endif
-#ifndef ff_ctzll
+#if !defined(ff_ctzll) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_ctzll))
#define ff_ctzll(v) __builtin_ctzll(v)
#endif
-#ifndef ff_clz
+#if !defined(ff_clz) && (AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_clz))
#define ff_clz(v) __builtin_clz(v)
#endif
#endif
-#endif
#ifndef ff_ctz
#define ff_ctz ff_ctz_c
@@ -154,7 +152,7 @@ static av_always_inline av_const unsigned ff_clz_c(unsigned x)
}
#endif
-#if AV_GCC_VERSION_AT_LEAST(3,4)
+#if AV_GCC_VERSION_AT_LEAST(3,4) || AV_HAS_BUILTIN(__builtin_parity)
#ifndef av_parity
#define av_parity __builtin_parity
#endif