Re: Data alignment code... What goes on?



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


.



Relevant Pages

  • Re: Data alignment code... What goes on?
    ... As far as I can understand the macros, they align the data block ... Yeah... ...
    (borland.public.delphi.language.basm)
  • Re: [PATCH] x86: include ENTRY/END in entry handlers in entry_64.S
    ... This does not align "something", because something is not in the ... behind the programmers back, that's completely and totally stupid in an ... I think using the macros for opcodes make sense, as the CFI operation is ... That is a good way to use macros. ...
    (Linux-Kernel)
  • [PATCH] alpha: fix iommu-related boot panic
    ... Fix boot panic due to a typo in the recent iommu patchset from ... This also removes a couple of unnecessary BUG_ONand ALIGN() macros. ...
    (Linux-Kernel)
  • Check Boxes
    ... macros. ... I still cant seem to line up multiple boxes evenly. ... I've even tried the draw tab to align, ...
    (microsoft.public.excel.newusers)