* [Linux-ia64] do me a favor
@ 2001-11-13 0:57 Qiu HongBing
2001-11-13 1:20 ` Dan Pop
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Qiu HongBing @ 2001-11-13 0:57 UTC (permalink / raw)
To: linux-ia64
Hi,
I'm Qiu HongBing. Now I process some project from IA32 to IA64 on Linux. Now
I have one question. If someone know it why and have spare time, Please help
me.Thanks a lot.
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".
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.
...
{
unsigned int tt;
tt¡->b;
fun1(a,b,c,d,&a1->b,e);
a1->b=tt;
}
...
That's all.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
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
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Dan Pop @ 2001-11-13 1:20 UTC (permalink / raw)
To: linux-ia64
On Tue, 13 Nov 2001, Qiu HongBing wrote:
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
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
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qiu HongBing @ 2001-11-13 1:59 UTC (permalink / raw)
To: linux-ia64
But next example happened same.
...
newtComponent newtEntry(int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...
char d[20][20];
...
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&d[11],NEWT_ENTRY_SCROLL);--->>outp
ut the unaligned access
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...
but , If I changed it to as follows and it is OK.
...
newtComponent newtEntry9int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...
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);
}
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...
I want to know why.
That's all.
Thanks.
--Qiu HongBing
----- Original Message -----
From: "Dan Pop" <Dan.Pop@cern.ch>
To: "Qiu HongBing" <qiuhb@necas.nec.co.jp>
Cc: <linux-ia64@linuxia64.org>
Sent: Tuesday, November 13, 2001 9:20 AM
Subject: Re: [Linux-ia64] do me a favor
>
>
> On Tue, 13 Nov 2001, Qiu HongBing wrote:
>
> > 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
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [Linux-ia64] do me a favor
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
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Tom King @ 2001-11-13 2:11 UTC (permalink / raw)
To: linux-ia64
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
Tom
-----Original Message-----
From: Qiu HongBing [mailto:qiuhb@necas.nec.co.jp]
Sent: Tuesday, November 13, 2001 12:59 PM
To: Dan Pop
Cc: linux-ia64@linuxia64.org
Subject: Re: [Linux-ia64] do me a favor
But next example happened same.
...
newtComponent newtEntry(int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...
char d[20][20];
...
entry[2]=newtEntry(-1,-1,d[2],10,(char**)&d[11],NEWT_ENTRY_SCROLL);--->>outp
ut the unaligned access
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...
but , If I changed it to as follows and it is OK.
...
newtComponent newtEntry9int left, int top, const char* initialValue, int
width, char** resultPtr,int flags);
...
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);
}
...
entry[3]=newtEntry(-1,-1,d[7],10,(char**)&d[16],NEWT_ENTRY_SCROLL);
...
I want to know why.
That's all.
Thanks.
--Qiu HongBing
----- Original Message -----
From: "Dan Pop" <Dan.Pop@cern.ch>
To: "Qiu HongBing" <qiuhb@necas.nec.co.jp>
Cc: <linux-ia64@linuxia64.org>
Sent: Tuesday, November 13, 2001 9:20 AM
Subject: Re: [Linux-ia64] do me a favor
>
>
> On Tue, 13 Nov 2001, Qiu HongBing wrote:
>
> > 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
>
>
_______________________________________________
Linux-IA64 mailing list
Linux-IA64@linuxia64.org
http://lists.linuxia64.org/lists/listinfo/linux-ia64
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
2001-11-13 0:57 [Linux-ia64] do me a favor Qiu HongBing
` (2 preceding siblings ...)
2001-11-13 2:11 ` Tom King
@ 2001-11-13 4:12 ` Qiu HongBing
2001-11-13 10:04 ` Andreas Schwab
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Qiu HongBing @ 2001-11-13 4:12 UTC (permalink / raw)
To: linux-ia64
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
> >
> >
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
2001-11-13 0:57 [Linux-ia64] do me a favor Qiu HongBing
` (3 preceding siblings ...)
2001-11-13 4:12 ` Qiu HongBing
@ 2001-11-13 10:04 ` Andreas Schwab
2001-11-13 10:11 ` Qiu HongBing
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2001-11-13 10:04 UTC (permalink / raw)
To: linux-ia64
"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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
2001-11-13 0:57 [Linux-ia64] do me a favor Qiu HongBing
` (4 preceding siblings ...)
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
7 siblings, 0 replies; 9+ messages in thread
From: Qiu HongBing @ 2001-11-13 10:11 UTC (permalink / raw)
To: linux-ia64
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
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
2001-11-13 0:57 [Linux-ia64] do me a favor Qiu HongBing
` (5 preceding siblings ...)
2001-11-13 10:11 ` Qiu HongBing
@ 2001-11-13 11:26 ` Andreas Schwab
2001-11-13 15:30 ` n0ano
7 siblings, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2001-11-13 11:26 UTC (permalink / raw)
To: linux-ia64
"Qiu HongBing" <qiuhb@necas.nec.co.jp> writes:
|> 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.
Align the memory accesses.
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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Linux-ia64] do me a favor
2001-11-13 0:57 [Linux-ia64] do me a favor Qiu HongBing
` (6 preceding siblings ...)
2001-11-13 11:26 ` Andreas Schwab
@ 2001-11-13 15:30 ` n0ano
7 siblings, 0 replies; 9+ messages in thread
From: n0ano @ 2001-11-13 15:30 UTC (permalink / raw)
To: linux-ia64
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
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2001-11-13 15:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox