Re: Data alignment code... What goes on?
- From: "Anders Isaksson" <blockcad@xxxxxxxxxxxxxxx>
- Date: Fri, 22 Dec 2006 11:18:39 +0100
dk_sz wrote:
[...]
#define ALIGN2(len) (((len) + 1) & ~1) // round up to 2 items
#define ALIGN4(len) (((len) + 3) & ~3) // round up to 4 items
#define ALIGN8(len) (((len) + 7) & ~7) // round up to 8 items
#define ALIGN8(len) (((len) + 15) & ~15) // round up to 16 items
Isn't this a kinda convoluted way to hardcode Align8 to return 8?
Well, it returns 0, 8, 16, 24, 32, and so on, depending on the 'len'
argument. As far as I can understand the macros, they align the data block
*size* to a multiple of the power of two that's part of their name (although
you have *two* ALIGN8 there, the last one is probably ALIGN16) so the name
is badly chosen, PADSIZExx or something like that should be (a bit) more
intuitive.
--
Anders Isaksson, Sweden
BlockCAD: http://web.telia.com/~u16122508/proglego.htm
Gallery: http://web.telia.com/~u16122508/gallery/index.htm
.
- Follow-Ups:
- Re: Data alignment code... What goes on?
- From: dk_sz
- Re: Data alignment code... What goes on?
- References:
- Data alignment code... What goes on?
- From: dk_sz
- Re: Data alignment code... What goes on?
- From: Anders Isaksson
- Re: Data alignment code... What goes on?
- From: dk_sz
- Data alignment code... What goes on?
- Prev by Date: Re: Fastcode library 0.62 and Delphi 6 problems
- Next by Date: Re: Fastcode Supported Compilers
- Previous by thread: Re: Data alignment code... What goes on?
- Next by thread: Re: Data alignment code... What goes on?
- Index(es):
Relevant Pages
|