[FFmpeg-devel] [PATCH 07/17] Make LOCAL_ALIGNED macro fully C99 compatible
Ronald S. Bultje
rsbultje
Thu Jan 20 02:23:47 CET 2011
Hi,
On Tue, Jan 18, 2011 at 2:32 PM, Mans Rullgard <mans at mansr.com> wrote:
> C99 variadic macros require more arguments than there are named
> parameters in the definition. ?This means we must perform this
> little dance to avoid having two different macros.
> ---
> ?libavcodec/dsputil.h | ? 20 +++++++++++++-------
> ?1 files changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
> index 1571491..261bc14 100644
> --- a/libavcodec/dsputil.h
> +++ b/libavcodec/dsputil.h
> @@ -664,20 +664,26 @@ static inline void emms(void)
> ?# ? define STRIDE_ALIGN 8
> ?#endif
>
> -#define LOCAL_ALIGNED(a, t, v, s, ...) ? ? ? ? ? ? ? ? ? ? ? ? ?\
> - ? ?uint8_t la_##v[sizeof(t s __VA_ARGS__) + (a)]; ? ? ? ? ? ? ?\
> - ? ?t (*v) __VA_ARGS__ = (void *)FFALIGN((uintptr_t)la_##v, a)
> +#define CAR(...) XCAR(__VA_ARGS__, x)
> +#define XCAR(x, ...) x
> +
> +#define CDR(...) XCDR(__VA_ARGS__,,)
> +#define XCDR(a, b, ...) b
> +
> +#define LOCAL_ALIGNED(a, t, v, ...) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? \
> + ? ?uint8_t la_##v[sizeof(t CAR(__VA_ARGS__) CDR(__VA_ARGS__)) + (a)]; ?\
> + ? ?t (*v) CDR(__VA_ARGS__) = (void *)FFALIGN((uintptr_t)la_##v, a)
>
> ?#if HAVE_LOCAL_ALIGNED_8
> -# ? define LOCAL_ALIGNED_8(t, v, s, ...) DECLARE_ALIGNED(8, t, v) s __VA_ARGS__
> +# ? define LOCAL_ALIGNED_8(t, v, ...) DECLARE_ALIGNED(8, t, v) CAR(__VA_ARGS__) CDR(__VA_ARGS__)
> ?#else
> -# ? define LOCAL_ALIGNED_8(t, v, s, ...) LOCAL_ALIGNED(8, t, v, s, __VA_ARGS__)
> +# ? define LOCAL_ALIGNED_8(t, v, ...) LOCAL_ALIGNED(8, t, v, __VA_ARGS__)
> ?#endif
>
> ?#if HAVE_LOCAL_ALIGNED_16
> -# ? define LOCAL_ALIGNED_16(t, v, s, ...) DECLARE_ALIGNED(16, t, v) s __VA_ARGS__
> +# ? define LOCAL_ALIGNED_16(t, v, ...) DECLARE_ALIGNED(16, t, v) CAR(__VA_ARGS__) CDR(__VA_ARGS__)
> ?#else
> -# ? define LOCAL_ALIGNED_16(t, v, s, ...) LOCAL_ALIGNED(16, t, v, s, __VA_ARGS__)
> +# ? define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__)
> ?#endif
>
> ?/* PSNR */
> --
> 1.7.3.5
OK.
Ronald
More information about the ffmpeg-devel
mailing list