From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-03 01:10:52
A cursory search of boost has not yielded information
I need on how to create a maximally aligned integer.
Specifically, given a positive integer n, I need to find
an integer m, such that p+m is maximally aligned, where
p is maximally aligned.
This calculation is required for ALL code which suballocates
memory for indeterminate types. My particular problem is
a garbage collector, which chains allocated blocks together:
the pointers of the chain are stored in a 'block header'
before the address returned to the user. I need to know
how big to make that header. I'm currently using:
#define _MAX_ALIGN 4
#define _ROUNDUP(i,n) ((i + n - 1) / n * n)
#define _ALIGN(i) _ROUNDUP(i,_MAX_ALIGN)
but the constant value of '_MAX_ALIGN' must be set
manually by the client. This isn't really acceptable.
It would be useful if an appropriate value were available
in the boost library.
-- John (Max) Skaller, mailto:skaller_at_[hidden] 10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850 checkout Vyper http://Vyper.sourceforge.net download Interscript http://Interscript.sourceforge.net
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk