* Alignment on alpha?
@ 1993-09-14 21:38 chrisp
1993-09-15 13:29 ` Dave Hill
0 siblings, 1 reply; 4+ messages in thread
From: chrisp @ 1993-09-14 21:38 UTC (permalink / raw)
Hi,
Can someone explain to me how to do long un-aligned accesses without
generating run-time errors.
And what alignment is necessary on alpha, byte word long or quad
Chris, Email: chrisp@marc.cri.nz
HortResearch Ltd., New Zealand.
"He's dead, Jim. I'll get his tricorder. You take his wallet."
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alignment on alpha?
1993-09-14 21:38 Alignment on alpha? chrisp
@ 1993-09-15 13:29 ` Dave Hill
1993-09-16 16:07 ` Burkhard Neidecker-Lutz
1993-09-17 12:06 ` Art Stine
0 siblings, 2 replies; 4+ messages in thread
From: Dave Hill @ 1993-09-15 13:29 UTC (permalink / raw)
In article <275gq7INNg9j@zephyr.grace.cri.nz>, chrisp@marc.cri.nz writes:
|> Hi,
|> Can someone explain to me how to do long un-aligned accesses without
|> generating run-time errors.
|>
|> And what alignment is necessary on alpha, byte word long or quad
|>
|> Chris, Email: chrisp@marc.cri.nz
|>
|> HortResearch Ltd., New Zealand.
|>
|> "He's dead, Jim. I'll get his tricorder. You take his wallet."
Structures, pointers, longs (sizeof(x) == 8)
on a mod 8 boundry
int (sizeof(int) == 4)
on a mod 4 boundry
short (sizeof(short) == 2)
on a mod 2 boundry
char (sizeof(cahr) == 1)
on any boundry
There is a pattern there somewhere :-)
Malloc always returns % 8
Almost all unaligned access errors I have dealt with on the Alpha
platform have been because the wrong thing was passed, for example:
func (long * l)
{
*l = some_value;
}
main()
{
int i;
func(&i);
}
This code can generate an unaligned access, and can produce bad side
affects. For example, the compliler will write 64 bits into the address
that is passed to the function, but you only passed 32 bits worth of
space, so something is getting squashed.
/Dave
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alignment on alpha?
1993-09-15 13:29 ` Dave Hill
@ 1993-09-16 16:07 ` Burkhard Neidecker-Lutz
1993-09-17 12:06 ` Art Stine
1 sibling, 0 replies; 4+ messages in thread
From: Burkhard Neidecker-Lutz @ 1993-09-16 16:07 UTC (permalink / raw)
If you *really* need unaligned access to objects that are misaligned
on purpose, you can either write portable code by using byte accesses
and assembling into words or the (faster) way is to use an extension
to C provided by the Alpha/OSF/1 compilers which will generate the
more efficient unaligned access code sequences found in the Alpha
architecture:
main()
{
char mis[10];
__unaligned int *p;
p = (int *) (mis + 1);
return(*p);
}
Burkhard Neidecker-Lutz
Distributed Multimedia Group, CEC Karlsruhe
Software Motion Pictures & BERKOM II Project
Digital Equipment Corporation
neidecker@nestvx.enet.dec.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Alignment on alpha?
1993-09-15 13:29 ` Dave Hill
1993-09-16 16:07 ` Burkhard Neidecker-Lutz
@ 1993-09-17 12:06 ` Art Stine
1 sibling, 0 replies; 4+ messages in thread
From: Art Stine @ 1993-09-17 12:06 UTC (permalink / raw)
In article 52b@utne.zk3.dec.com, ddhill@zk3.dec.com (Dave Hill) writes:
> Almost all unaligned access errors I have dealt with on the Alpha
> platform have been because the wrong thing was passed, for example:
>
> func (long * l)
> {
> *l = some_value;
> }
>
>
> main()
> {
> int i;
> func(&i);
> }
>
> This code can generate an unaligned access, and can produce bad side
> affects. For example, the compliler will write 64 bits into the address
> that is passed to the function, but you only passed 32 bits worth of
> space, so something is getting squashed.
>
> /Dave
i tried playing around with this and it doesn't generate an unaligned access but
it does generate compiler warnings under cc and and error under c89
---
-art
---- __
Art Stine \ / /(_ /\/ 11440 Commerce Park Drive
Software Engineer \/ / __)/ /\ Reston, Virginia 22091
abstine@visix.com Software Inc Voice: (703) 758-2767 (direct)
(703) 758-8230 (main)
... and I'm only saying this because (800) 832-8668 (toll-free)
I'm your friend, but there are FAX: (703) 758-0233
many decaffeinated brands that are
just as tasty as the real thing.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1993-09-17 12:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1993-09-14 21:38 Alignment on alpha? chrisp
1993-09-15 13:29 ` Dave Hill
1993-09-16 16:07 ` Burkhard Neidecker-Lutz
1993-09-17 12:06 ` Art Stine
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox