[erlang-questions] binary alignment

Zvi <>
Mon Apr 14 13:56:29 CEST 2008


Hi,
I wander if it's possible either to create binaries already aligned, say by
512 bytes. Or somehow get actual address of the binary and calculate offset
aligned by 512 bytes (512 bytes is just an example).
In C++ code I doing something like this:

const int ALIGNMENT_SIZE = 512;
const int BUFFER_SIZE = 16384;
unsigned char *pBuffer = new unsigned char[ALIGNMENT_SIZE + BUFFER_SIZE];
unsigned char *pAlignedBuffer = (unsigned char*)( (unsigned
int)(pBuffer+ALIGNMENT_SIZE) & ~(ALIGNMENT_SIZE-1) );

Thanks in advance,
Zvi
-- 
View this message in context: http://www.nabble.com/binary-alignment-tp16676932p16676932.html
Sent from the Erlang Questions mailing list archive at Nabble.com.




More information about the erlang-questions mailing list