Subject: Re: unaligned access: how to track ?
To: None <>
From: Christos Zoulas <>
List: port-alpha
Date: 06/08/2000 01:18:07
In article <>,
Manuel Bouyer <> 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++ :-)


#include <stdio.h>

#define ALIGNOF(type)	&(((struct { char c; type t; } *) 0)->t

	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));