Re: [Linux-ia64] do me a favor

n0ano
2001-11-13T15:30:11Z

Qiu-

The fact that your code works does not mean that it is completely
correct, it's not. Some architectures (IA32) silently allow unaligned
access (although there is a performance penality for doing this),
some architectures (IA64) verbosely allow unaligned accesses (with
a significant performance penality) and other architectures (Sparc)
don't allow unaligned accesses at all.

The way to avoid an unaligned access is actually very simple. Don't
cast a pointer to one type into a pointer to another type. For example,
this code:

{
int i, *ip;

ip = &i;
return(*ip);
}

will not generate an unaligned access whereas this code:

{
short s;
int *ip;

ip = (int *)&s;
return(*ip);
}

will. If you analyze your code carefully you'll discover that it's
doing something similar to the second example.

On Tue, Nov 13, 2001 at 06:11:44PM +0800, Qiu HongBing wrote:
> But I test on ItaniumTM, It work normally only output unaligned access. I
> think it maybe gcc compile options not to use strict-align option. My
> environment is ASUZU Machine to NEC.
>
> I only want to know how to avoid to write into syslog that messages.
> most of our source finished porting and now we are testing it and found this
> problem.
> Please help me.
>
> --Qiu HongBing
> ----- Original Message -----
> From: "Andreas Schwab" <schwab@suse.de>
> To: "Qiu HongBing" <qiuhb@necas.nec.co.jp>
> Cc: "Tom King" <Tom.King@bullant.com>; "Dan Pop" <Dan.Pop@cern.ch>;
> <linux-ia64@linuxia64.org>
> Sent: Tuesday, November 13, 2001 6:04 PM
> Subject: Re: [Linux-ia64] do me a favor
>
>
> > "Qiu HongBing" <qiuhb@necas.nec.co.jp> writes:
> >
> > |> Excuse me,
> > |> But I want to avoid this problem. How to do?
> >
> > Your code has never been portable. You can't just do that. FWIW, on a
> > sparc it will just crash, because unaligned accesses are strictly
> > forbidden.
> >
> > Andreas.
> >
> > --
> > Andreas Schwab "And now for something
> > Andreas.Schwab@suse.de completely different."
> > SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
> > Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> >
>
>
>
> _______________________________________________
> Linux-IA64 mailing list
> Linux-IA64@linuxia64.org
> http://lists.linuxia64.org/lists/listinfo/linux-ia64

--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
n0ano@indstorage.com
Ph: 303/652-0870x117