This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Unaligned attribute
- From: <pluto at agmk dot net>
- To: "Jan Hoogerbrugge" <jan dot hoogerbrugge at gmail dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Thu, 20 Mar 2008 17:41:11 +0200
- Subject: Re: Unaligned attribute
- Bounce-to: <pluto@agmk.net>
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]