Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
62 user(s) are online (41 user(s) are browsing Forums)

Members: 1
Guests: 61

sTix, more...

Support us!

Headlines






Alignment Exception
Just popping in
Joined:
2009/1/21 13:39
Posts: 48
I *think* to remember that it was possible on OS 4 to make alignment exception not cause a crash (but did not have a working Amiga for some while, so not sure right now), I think to remember there was some ENV Variable or such... Can someone tell if I remember right?

I have an alignment exception in one of my programs which looks like a data structure is not aligned to 32 Bit boundaries (which AFAIK is a problem on the Sam).

Also: Would -mstrict-align help?

MagicSN

   Report Go to top

Re: Alignment Exception
Quite a regular
Joined:
2006/11/27 14:24
From Scarfskerry
Posts: 590
@MagicSN

I had the same problem when developing Digital Universe with the latest SDK. Older SDKs worked but the latest one did not.

The answer I was given from the SDK experts is:

Quote:




OK, we finally figured out what is happening and it is anAmigaOS-specific GCC compiler bug.



Quote:




The root cause of the trouble is the pack(2) as you suspected all along. However, our GCC should have been created withthe -mstrict-align option to force strict alignments of floatingpoint types which makes the code run faster (alignment is good)at the expense of storage space.A bug has been filed against our version of GCC.



Quote:




So add the -mstrict-align optionand your code should still compile and run without this problem. This enables the optimizer to do its job without worry.



So currently add the -mstrict-align in your makefiles when compiling for OS4, in a future SDK you should be able to leave this out as it will be on by default.

Hope this helps.

   Report Go to top

Re: Alignment Exception
Just popping in
Joined:
2009/1/21 13:39
Posts: 48
@BillE

Well, let's hope Mame 0.131 will finally work after this recompile

   Report Go to top

Re: Alignment Exception
Home away from home
Joined:
2007/5/19 14:23
From England
Posts: 3553
@BillE
Do you know if this bug could affect 64-bit (long long) values? And whether -mstrict-align would help?

_________________
Author of the PortablE programming language.
I love using Amiga OS4.1
It is pitch black. You are likely to be eaten by a grue...
   Report Go to top

Re: Alignment Exception
Not too shy to talk
Joined:
2006/11/22 8:44
Posts: 414
@MagicSN

How long does it take to compile?

I get annoyed at my 1 minute 15 second WookieChat compiles.. it went a lot faster on the A1. :)

   Report Go to top

Re: Alignment Exception
Quite a regular
Joined:
2006/11/27 14:24
From Scarfskerry
Posts: 590
@ChrisH

Quote:

ChrisH wrote:
Do you know if this bug could affect 64-bit (long long) values? And whether -mstrict-align would help?


To be honest, no idea. But from what I currently gather...

It should not affect 64 bit values as they should be aligned anyway. It is small variables that in a structure may not fit on an aligned memory boundary that will have this problem. Furthermore only structures that use #pragma pack(2) to read in existing data files would be affected.

   Report Go to top

Re: Alignment Exception
Not too shy to talk
Joined:
2006/12/1 23:50
From Skærbæk. Denmark
Posts: 266
@MagicSN

The cpu on the Sam440 is a little special... where the 'normal' powerpc cpus want 4 bytes alligned Floats, the sam wants 8 bytes.. The exec implements a execption handler that will catch this error and correct it.

I am not sure if it will only work for 4 bytes allign floats. but you can write to Thomas Frieden and ask I'm very sure he can tell you, I only write what my memory allows me to remeber, I dident followed this topic very closely then the Sam port was done.

RWO

   Report Go to top

Re: Alignment Exception
Just popping in
Joined:
2009/1/21 13:39
Posts: 48
@rwo

Yes, I examined the code now, and there is something like that in the structure causing the crash:

UBYTE8 ...;
ULONG ...;
float ...;

so the float ends up on a non-aligned address, which after what you wrote is a problem.

I added -mstrict-align to the compile but not to the link, this did not help (do I need to add it to the link as well?)

Now I am trying something else: Including 3 Pad-Bytes after the UBYTE Just hope such a problem is not at a different location as well!

I will also phone Thomas Frieden at some times and ask him if he has a suggestion, though

Steffen

   Report Go to top

Re: Alignment Exception
Amigans Defender
Joined:
2006/11/26 23:16
From Canada
Posts: 986
@MagicSN
Quote:

UBYTE8 ...;
ULONG ...;
float ...;


Adding the -mstrict-align option should do the trick for that problem. Another way to get rid of the problem is to remove any #pragma pack() directives and let the compiler pack it.

Make sure you are using the latest SDK compiler as well. If you use an older version you will have problems on the 440ep.

_________________
ExecSG Team Lead
   Report Go to top

Re: Alignment Exception
Quite a regular
Joined:
2006/11/27 14:35
From Nantes, France
Posts: 865
@ssolie

IIRC correctly MagicSN is cross-compiling from Cygwin. Is the latest SDK enough or should an updated cross-compiler be used too ?

_________________
Back to a quiet home... At last
   Report Go to top

Re: Alignment Exception
Just popping in
Joined:
2009/1/21 13:39
Posts: 48
@ssolie: I am already using -mstrict-align and the problem still appears. I checked the ASM code which crashed and it was a loading of a float. So it seems -mstrict-align did not do the trick, probably due to a too old compiler.

@abalaban

You are right. I am using the cygwin-cross-compiler. I am using the latest one I could find which was already quite old (from 2007). My guess is this version is too old for it. If anyone has the recent compiler for cygwin, please tell me where I can get it.

And I am still interested in a A1/Peg2 based tester for Mame, so I can see if it runs on a non-Sam system in the current compile.

MagicSN

   Report Go to top

Re: Alignment Exception
Amigans Defender
Joined:
2006/12/2 13:27
From Taranto, Italy
Posts: 964
@MagicSN

as Steven (ssolie) said and as I said you on AW, try #pragma pack() directive and try also __align() attribute:

Link

_________________
i'm really tired...
   Report Go to top





[Advanced Search]



Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project