tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Address alignment

Hi, I have a requirement where I'm writing N bytes of data to a buffer. If the 
last byte after data is not aligned on 8-byte boundary, I need to add some 
padding after data.

So assume 'buffer' is a pointer to a buffer, after putting N bytes of data in 
the buffer the pointer will be incremented by N. Is the following code correct 
for aligning a pointer on 8-byte boundary? Will it work correctly with 64-bit 
addresses, or do I need to cast -8 to 64-bit value in that case?

buffer & -8

Home | Main Index | Thread Index | Old Index