On Sun, 2010-01-10 at 05:26 -0800, José Fonseca wrote:
> Attached is a patch that generalizes the ALIGN16/8_XXX macros in
> p_compiler.h to work on MSVC and handle alignments beyond 8 and 16
> bytes.
> 
> There is more than one way to have cross-platform alignment macros --
> all quite ugly.
> 
> The major complication here is that GCC and MSVC syntax for type/vars
> attributes differs. MSVC's attributes are before types/vars
> declarations. GCC's attributes are in general after the types/vars
> declarations, although it is possible to put var attributes before too.
> For more detail read:
> - http://gcc.gnu.org/onlinedocs/gcc-4.4.2/gcc/Attribute-Syntax.html
> - http://msdn.microsoft.com/en-us/library/83ythb65.aspx
> 
> The approach I chose in the attached patch was to define the alignment
> macros to contain the whole declaration as an argument, e.g.:
> 
>   PIPE_ALIGN_TYPE(16, 
>   struct {
>     float rgba[4];
>   });
> 
>   PIPE_ALIGN_VAR(16, float rgba[4]);
> 
> Another alternative would be to define pre-/post-fix macros, where
> alignment would have to be passed twice:
> 
>   PIPE_ALIGN_TYPE_BEGIN(16) 
>   struct {
>     float rgba[4];
>   }
>   PIPE_ALIGN_TYPE_END(16);
> 
>   PIPE_ALIGN_VAR_BEGIN(16)
>   float rgba[4]
>   PIPE_ALIGN_VAR_END(16);
> 
> Or provide a mixture or union of all the above macros.
> 
> I honestly don't care either way -- they all look ugly to me --, as long
> it works with all compilers I'm happy to go either way.


I'm the same.  Probably slightly prefer the direction you've taken, ie
single macro wrapping the declaration.

Keith


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to