This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unaligned attribute


20/3/2008, "Jan Hoogerbrugge" <jan.hoogerbrugge@gmail.com> napisał/a:

>Hi,
>
>I am looking for a way to specify that data is not aligned and that therefore
>word accesses should be expanded into byte accesses. For example:
>
>void f(__unaligned int *a)
>{
>  *a = 0;
>}
>
>Expands into 4 byte stores. Any suggestions on how to implement this?

$ cat 0.c

typedef struct { unsigned value __attribute__(( packed ));
}unaligned_uint;

void f( unaligned_uint* p ) { p->value = 0; }

$ sparc-sun-solaris2.9-gcc 0.c -O2 -S produces:

f:
        stb     %g0, [%o0+3]
        stb     %g0, [%o0]
        stb     %g0, [%o0+1]
        jmp     %o7+8
        stb    %g0, [%o0+2]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]