public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
From: n0ano@indstorage.com
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] do me a favor
Date: Tue, 13 Nov 2001 15:30:11 +0000	[thread overview]
Message-ID: <marc-linux-ia64-105590698805493@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590698805482@msgid-missing>

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


      parent reply	other threads:[~2001-11-13 15:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-13  0:57 [Linux-ia64] do me a favor Qiu HongBing
2001-11-13  1:20 ` Dan Pop
2001-11-13  1:59 ` Qiu HongBing
2001-11-13  2:11 ` Tom King
2001-11-13  4:12 ` Qiu HongBing
2001-11-13 10:04 ` Andreas Schwab
2001-11-13 10:11 ` Qiu HongBing
2001-11-13 11:26 ` Andreas Schwab
2001-11-13 15:30 ` n0ano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=marc-linux-ia64-105590698805493@msgid-missing \
    --to=n0ano@indstorage.com \
    --cc=linux-ia64@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox