[parisc-linux] Usage of __attribute__?

John Marvin jsm@udlkern.fc.hp.com
Sat, 27 Jan 2001 02:48:49 -0700 (MST)


As part of my effort to fix the alignment problems in libpthread, I am
creating a type with the aligned attribute. However, I discovered
something strange, which I don't know if it is a bug, or is the expected
behaviour (i.e. I am doing something wrong/don't understand how
__attribute__ works).

If I directly declare the type as follows:

    typedef int _lt_spinlock_t __attribute__((aligned(16)));

then EVERY int that follows has the aligned 16 attribute, e.g. just
declaring "int tmp;" gives tmp a 16 byte alignment. So, is that what
you would expect from my above declaration?

I worked around the problem by declaring the type in two steps:

    typedef int _spin16;
    typedef _spin16 _lt_spinlock_t __attribute__((aligned(16)));

Is there a way of combining the above two into one declaration,
without having the undesired side effect of making every int
aligned to a 16 byte boundary?

John Marvin
jsm@fc.hp.com