Inquiry on Alignment Requirements

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

 



I'm in the process of writing a memory allocator for a project of
mine; needless to say, GCC is one of the targeted compilers.

I find myself having to think about what memory alignment rules to
guarantee for pointers returned from my allocator. I know that some
subset of instructions on some architectures work much faster when
operating on properly aligned data. Furthermore, I know that other
such instructions flat out fail to work if operating on improperly
aligned data.

The question is: does GCC use such instructions? I don't want to
return poorly aligned data from my alloc() function and have GCC
try to use an aligned-only instruction it, resulting in things
exploding at runtime.

__alignof__ seems like it might be of some help:
http://gcc.gnu.org/onlinedocs/gcc-4.3.3/gcc/Alignment.html#Alignment
But unfortunately it doesn't tell me what the _strictest_ alignment
rule is, which is what I need to know to write a generic memory
allocator.

Does GCC document or otherwise make known what minimum alignment it
expects on each platform?

I wish I could detect this automatically at build time; or during
./configure time (it's an autotools projects).

Thanks for reading,
-Patrick


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux