Subject: Re: unaligned access: how to track ?
To: None <port-alpha@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: port-alpha
Date: 06/08/2000 01:18:07
In article <20000607185412.G28302@antioche.lip6.fr>,
Manuel Bouyer <bouyer@antioche.lip6.fr> wrote:
>
> Hum ok, so we should pad the key to the alignement required by the
> architecture.
> Shouldn't be hard to do in rpc.statd but I need to know the alignement
> requirement for the arch we are compiling for. Is there a macro or something
> that will give me that info ? Doing "#ifdef __foo_" doesn't look like the
> rigth solution.
Something like that might work...
Quiz question: Who can write ALIGNOF for c++ :-)
christos
#include <stdio.h>
#define ALIGNOF(type) &(((struct { char c; type t; } *) 0)->t
void
main()
{
printf("%d\n", ALIGNOF(char));
printf("%d\n", ALIGNOF(short));
printf("%d\n", ALIGNOF(int));
printf("%d\n", ALIGNOF(long));
printf("%d\n", ALIGNOF(long long));
printf("%d\n", ALIGNOF(float));
printf("%d\n", ALIGNOF(double));
}