* [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability @ 2025-03-31 12:02 Kacper Michajłow 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow ` (2 more replies) 0 siblings, 3 replies; 9+ messages in thread From: Kacper Michajłow @ 2025-03-31 12:02 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Kacper Michajłow 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> --- libavutil/intmath.h | 12 +++++------- libavutil/x86/intmath.h | 4 ++-- 2 files changed, 7 insertions(+), 9 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 diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h index 4893a1f1b4..030ded6b6f 100644 --- a/libavutil/x86/intmath.h +++ b/libavutil/x86/intmath.h @@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) #endif /* HAVE_FAST_CLZ */ -#if defined(__GNUC__) +#if defined(__GNUC__) || defined(__clang__) /* Our generic version of av_popcount is faster than GCC's built-in on * 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) #if defined(__BMI2__) -#if AV_GCC_VERSION_AT_LEAST(5,1) +#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si) #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 #define av_zero_extend av_zero_extend_bmi2 static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) -- 2.45.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check 2025-03-31 12:02 [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajłow @ 2025-03-31 12:02 ` Kacper Michajłow 2025-06-11 18:34 ` Kacper Michajlow 2025-06-12 9:52 ` Martin Storsjö 2025-06-11 18:33 ` [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajlow 2025-06-12 9:49 ` Martin Storsjö 2 siblings, 2 replies; 9+ messages in thread From: Kacper Michajłow @ 2025-03-31 12:02 UTC (permalink / raw) To: ffmpeg-devel; +Cc: Kacper Michajłow Clang x86_64-pc-windows-msvc doesn't define __GNUC__. Signed-off-by: Kacper Michajłow <kasper93@gmail.com> --- libavformat/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/internal.h b/libavformat/internal.h index fe428d85eb..bf83571430 100644 --- a/libavformat/internal.h +++ b/libavformat/internal.h @@ -354,7 +354,7 @@ static av_always_inline const FFStream *cffstream(const AVStream *st) return (const FFStream*)st; } -#ifdef __GNUC__ +#if defined (__GNUC__) || defined (__clang__) #define dynarray_add(tab, nb_ptr, elem)\ do {\ __typeof__(tab) _tab = (tab);\ -- 2.45.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow @ 2025-06-11 18:34 ` Kacper Michajlow 2025-06-12 9:52 ` Martin Storsjö 1 sibling, 0 replies; 9+ messages in thread From: Kacper Michajlow @ 2025-06-11 18:34 UTC (permalink / raw) To: ffmpeg-devel On Mon, 31 Mar 2025 at 14:03, Kacper Michajłow <kasper93@gmail.com> wrote: > > Clang x86_64-pc-windows-msvc doesn't define __GNUC__. > > Signed-off-by: Kacper Michajłow <kasper93@gmail.com> > --- > libavformat/internal.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/internal.h b/libavformat/internal.h > index fe428d85eb..bf83571430 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -354,7 +354,7 @@ static av_always_inline const FFStream *cffstream(const AVStream *st) > return (const FFStream*)st; > } > > -#ifdef __GNUC__ > +#if defined (__GNUC__) || defined (__clang__) > #define dynarray_add(tab, nb_ptr, elem)\ > do {\ > __typeof__(tab) _tab = (tab);\ > -- > 2.45.1 > bump _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow 2025-06-11 18:34 ` Kacper Michajlow @ 2025-06-12 9:52 ` Martin Storsjö 1 sibling, 0 replies; 9+ messages in thread From: Martin Storsjö @ 2025-06-12 9:52 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Kacper Michajłow On Mon, 31 Mar 2025, Kacper Michajłow wrote: > Clang x86_64-pc-windows-msvc doesn't define __GNUC__. > > Signed-off-by: Kacper Michajłow <kasper93@gmail.com> > --- > libavformat/internal.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libavformat/internal.h b/libavformat/internal.h > index fe428d85eb..bf83571430 100644 > --- a/libavformat/internal.h > +++ b/libavformat/internal.h > @@ -354,7 +354,7 @@ static av_always_inline const FFStream *cffstream(const AVStream *st) > return (const FFStream*)st; > } > > -#ifdef __GNUC__ > +#if defined (__GNUC__) || defined (__clang__) > #define dynarray_add(tab, nb_ptr, elem)\ > do {\ > __typeof__(tab) _tab = (tab);\ > -- > 2.45.1 This patch also looks good, so I'll push it. But as with the other one as I asked yesterday, it would be good to describe the status quo and what the change gains. In this case I presume that it gains the type checking abilities of the GCC compatible version of dynarray_add? Also, regarding these patchs for clang in msvc mode; when testing things I ran into another build failure, which is fixed by https://patchwork.ffmpeg.org/project/ffmpeg/patch/20250612093933.395475-1-martin@martin.st/. I wonder if you haven't run into this as well, or why it isn't happening for you? (With that fixed, I'll try to set up fate instances with this build mode; I already have such for Clang in MSVC mode targeting arm/aarch64, but no for x86/x86_64 yet.) // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability 2025-03-31 12:02 [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajłow 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow @ 2025-06-11 18:33 ` Kacper Michajlow 2025-06-11 18:44 ` Martin Storsjö 2025-06-12 9:49 ` Martin Storsjö 2 siblings, 1 reply; 9+ messages in thread From: Kacper Michajlow @ 2025-06-11 18:33 UTC (permalink / raw) To: ffmpeg-devel On Mon, 31 Mar 2025 at 14:03, Kacper Michajłow <kasper93@gmail.com> wrote: > > 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> > --- > libavutil/intmath.h | 12 +++++------- > libavutil/x86/intmath.h | 4 ++-- > 2 files changed, 7 insertions(+), 9 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 > diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h > index 4893a1f1b4..030ded6b6f 100644 > --- a/libavutil/x86/intmath.h > +++ b/libavutil/x86/intmath.h > @@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) > > #endif /* HAVE_FAST_CLZ */ > > -#if defined(__GNUC__) > +#if defined(__GNUC__) || defined(__clang__) > > /* Our generic version of av_popcount is faster than GCC's built-in on > * 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) > > #if defined(__BMI2__) > > -#if AV_GCC_VERSION_AT_LEAST(5,1) > +#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si) > #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 > #define av_zero_extend av_zero_extend_bmi2 > static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) > -- > 2.45.1 > bump _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability 2025-06-11 18:33 ` [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajlow @ 2025-06-11 18:44 ` Martin Storsjö 2025-06-11 18:51 ` Kacper Michajlow 0 siblings, 1 reply; 9+ messages in thread From: Martin Storsjö @ 2025-06-11 18:44 UTC (permalink / raw) To: FFmpeg development discussions and patches On Wed, 11 Jun 2025, Kacper Michajlow wrote: > On Mon, 31 Mar 2025 at 14:03, Kacper Michajłow <kasper93@gmail.com> wrote: >> >> 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> >> --- >> libavutil/intmath.h | 12 +++++------- >> libavutil/x86/intmath.h | 4 ++-- >> 2 files changed, 7 insertions(+), 9 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 >> diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h >> index 4893a1f1b4..030ded6b6f 100644 >> --- a/libavutil/x86/intmath.h >> +++ b/libavutil/x86/intmath.h >> @@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) >> >> #endif /* HAVE_FAST_CLZ */ >> >> -#if defined(__GNUC__) >> +#if defined(__GNUC__) || defined(__clang__) >> >> /* Our generic version of av_popcount is faster than GCC's built-in on >> * 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) >> >> #if defined(__BMI2__) >> >> -#if AV_GCC_VERSION_AT_LEAST(5,1) >> +#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si) >> #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 >> #define av_zero_extend av_zero_extend_bmi2 >> static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) >> -- >> 2.45.1 >> > > bump Can you specify the symptoms that are fixed? Is there a specific build configuration that fails, or is it a case of using more optimal builtins where suitable? (Same goes for 2/2 probably.) // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability 2025-06-11 18:44 ` Martin Storsjö @ 2025-06-11 18:51 ` Kacper Michajlow 2025-06-11 18:57 ` Kacper Michajlow 0 siblings, 1 reply; 9+ messages in thread From: Kacper Michajlow @ 2025-06-11 18:51 UTC (permalink / raw) To: FFmpeg development discussions and patches On Wed, 11 Jun 2025 at 20:45, Martin Storsjö <martin@martin.st> wrote: > > On Wed, 11 Jun 2025, Kacper Michajlow wrote: > > > On Mon, 31 Mar 2025 at 14:03, Kacper Michajłow <kasper93@gmail.com> wrote: > >> > >> 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> > >> --- > >> libavutil/intmath.h | 12 +++++------- > >> libavutil/x86/intmath.h | 4 ++-- > >> 2 files changed, 7 insertions(+), 9 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 > >> diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h > >> index 4893a1f1b4..030ded6b6f 100644 > >> --- a/libavutil/x86/intmath.h > >> +++ b/libavutil/x86/intmath.h > >> @@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) > >> > >> #endif /* HAVE_FAST_CLZ */ > >> > >> -#if defined(__GNUC__) > >> +#if defined(__GNUC__) || defined(__clang__) > >> > >> /* Our generic version of av_popcount is faster than GCC's built-in on > >> * 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) > >> > >> #if defined(__BMI2__) > >> > >> -#if AV_GCC_VERSION_AT_LEAST(5,1) > >> +#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si) > >> #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 > >> #define av_zero_extend av_zero_extend_bmi2 > >> static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) > >> -- > >> 2.45.1 > >> > > > > bump > > Can you specify the symptoms that are fixed? Is there a specific build > configuration that fails, or is it a case of using more optimal builtins > where suitable? (Same goes for 2/2 probably.) As the commit message says it "Fixes use of bultins on clang x86_64-pc-windows-msvc". It now uses builtins where previously it would fallback to C implementation. - Kacper _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability 2025-06-11 18:51 ` Kacper Michajlow @ 2025-06-11 18:57 ` Kacper Michajlow 0 siblings, 0 replies; 9+ messages in thread From: Kacper Michajlow @ 2025-06-11 18:57 UTC (permalink / raw) To: FFmpeg development discussions and patches On Wed, 11 Jun 2025 at 20:51, Kacper Michajlow <kasper93@gmail.com> wrote: > > On Wed, 11 Jun 2025 at 20:45, Martin Storsjö <martin@martin.st> wrote: > > > > On Wed, 11 Jun 2025, Kacper Michajlow wrote: > > > > > On Mon, 31 Mar 2025 at 14:03, Kacper Michajłow <kasper93@gmail.com> wrote: > > >> > > >> 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> > > >> --- > > >> libavutil/intmath.h | 12 +++++------- > > >> libavutil/x86/intmath.h | 4 ++-- > > >> 2 files changed, 7 insertions(+), 9 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 > > >> diff --git a/libavutil/x86/intmath.h b/libavutil/x86/intmath.h > > >> index 4893a1f1b4..030ded6b6f 100644 > > >> --- a/libavutil/x86/intmath.h > > >> +++ b/libavutil/x86/intmath.h > > >> @@ -66,7 +66,7 @@ static av_always_inline av_const int ff_ctzll_x86(long long v) > > >> > > >> #endif /* HAVE_FAST_CLZ */ > > >> > > >> -#if defined(__GNUC__) > > >> +#if defined(__GNUC__) || defined(__clang__) > > >> > > >> /* Our generic version of av_popcount is faster than GCC's built-in on > > >> * 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) > > >> > > >> #if defined(__BMI2__) > > >> > > >> -#if AV_GCC_VERSION_AT_LEAST(5,1) > > >> +#if AV_GCC_VERSION_AT_LEAST(5,1) || AV_HAS_BUILTIN(__builtin_ia32_bzhi_si) > > >> #if defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 > > >> #define av_zero_extend av_zero_extend_bmi2 > > >> static av_always_inline av_const unsigned av_zero_extend_bmi2(unsigned a, unsigned p) > > >> -- > > >> 2.45.1 > > >> > > > > > > bump > > > > Can you specify the symptoms that are fixed? Is there a specific build > > configuration that fails, or is it a case of using more optimal builtins > > where suitable? (Same goes for 2/2 probably.) > > As the commit message says it "Fixes use of bultins on clang > x86_64-pc-windows-msvc". It now uses builtins where previously it > would fallback to C implementation. > > - Kacper Additionally for __builtin_ia32_bzhi_si check, currently it uses AV_GCC_VERSION_AT_LEAST(5,1), which wouldn't work on any platform, because clang always defines __GNUC__ to 4 for compatibility reasons only. - Kacper _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability 2025-03-31 12:02 [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajłow 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow 2025-06-11 18:33 ` [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajlow @ 2025-06-12 9:49 ` Martin Storsjö 2 siblings, 0 replies; 9+ messages in thread From: Martin Storsjö @ 2025-06-12 9:49 UTC (permalink / raw) To: FFmpeg development discussions and patches; +Cc: Kacper Michajłow On Mon, 31 Mar 2025, Kacper Michajłow wrote: > 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> > --- > libavutil/intmath.h | 12 +++++------- > libavutil/x86/intmath.h | 4 ++-- > 2 files changed, 7 insertions(+), 9 deletions(-) LGTM, will push. // Martin _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-06-12 9:52 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2025-03-31 12:02 [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajłow 2025-03-31 12:02 ` [FFmpeg-devel] [PATCH 2/2] avformat/internal: add missing __clang__ check Kacper Michajłow 2025-06-11 18:34 ` Kacper Michajlow 2025-06-12 9:52 ` Martin Storsjö 2025-06-11 18:33 ` [FFmpeg-devel] [PATCH 1/2] avutil/intmath: use AV_HAS_BUILTIN to detect builtin availability Kacper Michajlow 2025-06-11 18:44 ` Martin Storsjö 2025-06-11 18:51 ` Kacper Michajlow 2025-06-11 18:57 ` Kacper Michajlow 2025-06-12 9:49 ` Martin Storsjö
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git