Re: Data alignment code... What goes on?
- From: "dk_sz" <dk_sz@xxxxxxxxxxx>
- Date: Fri, 22 Dec 2006 19:04:19 +0100
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
Yeah... But as far as I can see:
If you call Align4 gives value 4 (for len between 1-4)
If you call Align8 gives value 8 (for len between 1-8)
etc.
In the examples used, the author "hard
code" each call (i.e. Align2, Align4 etc.)
So why not simply
#define ALIGN4(len) (4)
#define ALIGN8(len) (8)
etc.
Well, I just find it peculiar :-)
I think it must be an incomplete example / usage.
best regards
Thomas
"Anders Isaksson" <blockcad@xxxxxxxxxxxxxxx> skrev i en meddelelse
news:458bb0f2$1@xxxxxxxxxxxxxxxxxxxxxxxxx
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: Anders Isaksson
- 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
- Re: Data alignment code... What goes on?
- From: Anders Isaksson
- Data alignment code... What goes on?
- Prev by Date: Re: Fastcode Unofficial D5 CharPos B&V
- Next by Date: Re: Fastcode StrToInt32 B&V 1.0.4
- Previous by thread: Re: Data alignment code... What goes on?
- Next by thread: Re: Data alignment code... What goes on?
- Index(es):
Relevant Pages
|