From: "Qiu HongBing" <qiuhb@necas.nec.co.jp>
To: linux-ia64@vger.kernel.org
Subject: Re: [Linux-ia64] do me a favor
Date: Tue, 13 Nov 2001 04:12:38 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590698805487@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-105590698805482@msgid-missing>
Excuse me,
But I want to avoid this problem. How to do?
Thanks.
--Qiu HongBing
> temp will be aligned when storage is allocated for it
> d[16] just happens to work because it is aligned
> any address that is not divisible by 8 can be considered unaligned
>
> But next example happened same.
>
> char d[20][20];
> ...
>
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&d[11],NEWT_ENTRY_SCROLL);--->>outp
> ut the unaligned access
>
> but , If I changed it to as follows and it is OK.
>
>
> char d[20][20];
> ...
> {
> char temp[20];
> sprintf(temp,"%s",d[11]);
>
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&temp/*&d[11]*/,NEWT_ENTRY_SCROLL);
> sprintf(d[11],"%s",temp);
> }
> ...
>
> I want to know why.
> That's all.
> Thanks.
>
> >
> > > My problem is as follows:
> > >
> > > struct aa{
> > > unsigned short a;
> > > unsigned short b;
> > > unsigned short c;
> > > unsigned short d;
> > > unsigned int e;
> > > unsigned int f;
> > > unsigned int g;
> > > unsigned int h;
> > > unsigned short i;
> > > }
> > > ...
> > > struct aa *a1;
> > > ...
> > >
> > > fun1(char *,unsigned int *,char *,char *,unsigned int * temp,unsigned
> int *)
> > > {
> > > ...
> > > *temp\x10;
> > > ...
> > > }
> > > ...
> > >
> > > fun1(a,b,c,d,&a1->b,e);
> > > ...
> > >
> > > On IA64 Linux RedHat 7.1(2.4.3-3), when the program run to
> > > fun1(a,b,c,d,&a1->b,e), the kernel write into syslog some message
which
> is
> > > "Nov 5 10:12:02 sdv2 kernel: ESMmlx(7837): unaligned access to
> > > 0x600000000001684c, ip=0x2000000000624370".
> >
> > The reason is obvious: fun1 expects temp to be a pointer to unsigned
> > int, but you're passing it &a1->b, which is a pointer to unsigned
> > short. The compiler should have actually warned you about that.
> >
> > > But if I modify the source as follows and it is OK. I dont know why.
So
> I
> > > want to get some help to solve the real cause.
> >
> > Then, either define the b member as unsigned int, or the temp
> > parameter as pointer to unsigned short.
> >
> > Dan
> >
> >
next prev parent reply other threads:[~2001-11-13 4:12 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 [this message]
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
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-105590698805487@msgid-missing \
--to=qiuhb@necas.nec.co.jp \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.