[FFmpeg-cvslog] r11889 - trunk/libavutil/mem.h

Diego Biurrun diego
Mon Feb 11 08:57:07 CET 2008


On Sun, Feb 10, 2008 at 11:15:18PM +0100, Reimar D?ffinger wrote:
> On Sun, Feb 10, 2008 at 10:50:35PM +0100, Diego Biurrun wrote:
> > On Sun, Feb 10, 2008 at 11:47:01PM +0200, Uoti Urpala wrote:
> > > On Sun, 2008-02-10 at 22:16 +0100, Diego Biurrun wrote:
> > > > On Sun, Feb 10, 2008 at 10:11:52PM +0100, Diego Biurrun wrote:
> > > > > Wait, icc defines __GNUC__?!?
> > > > 
> > > > I suggest the following, which is farm more readable IMO even if -
> > > > strictly speaking - it duplicates one line:
> > > > 
> > > > #ifdef __GNUC__
> > > >   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
> > > >   #define DECLARE_ASM_CONST(n,t,v)     static const t v attribute_used __attribute__ ((aligned (n)))
> > > > #elif __ICC
> > > 
> > > icc does define __GNUC__ as it tries to support the same extensions. So
> > > if there is a test for __GNUC__, any icc-specific code must be on the
> > > __GNUC__ side, not the non-__GNUC__ side like in your suggestion.
> > 
> > Then it can be done the other way around:
> > 
> > #ifdef __ICC
> >   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
> >   #define DECLARE_ASM_CONST(n,t,v)     const t __attribute__ ((aligned (n))) v
> > #elif __GNUC__
> >   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
> >   #define DECLARE_ASM_CONST(n,t,v)     static const t v attribute_used __attribute__ ((aligned (n)))
> > #else
> >   #define DECLARE_ALIGNED(n,t,v)       __declspec(align(n)) t v
> >   #define DECLARE_ASM_CONST(n,t,v)     __declspec(align(n)) static const t v
> > #endif
> 
> I'd still suggest something along the lines
> 
> #ifdef __ICC
>   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
>   #define DECLARE_ASM_CONST(n,t,v)     const t __attribute__ ((aligned (n))) v
> #elif HAVE_DECLSPEC
>   #define DECLARE_ALIGNED(n,t,v)       __declspec(align(n)) t v
>   #define DECLARE_ASM_CONST(n,t,v)     __declspec(align(n)) static const t v
> #elif HAVE_GENERIC_C
>   #define DECLARE_ALIGNED(n,t,v)       t v
>   #define DECLARE_ASM_CONST(n,t,v)     static const t v
> #else
>   #define DECLARE_ALIGNED(n,t,v)       t v __attribute__ ((aligned (n)))
>   #define DECLARE_ASM_CONST(n,t,v)     static const t v attribute_used __attribute__ ((aligned (n)))
> #endif
> 
> Where HAVE_GENERIC_C would/should only be used for a compile without any
> asm at all (I don't mind if you leave that section out completely, I
> just think it would be better to have. I would not like to have this
> case the default though, since it could create hard-to-debug problems
> while gaining little if anything in terms of supported compilers).

Unfortunately nobody has stepped up to add this sort of proper
__declspec/MSVC support, so I vote against keeping it in the
default/fallback case.

Diego




More information about the ffmpeg-cvslog mailing list