[fpc-pascal] Carbon: i386 vs PPC API's
Jonas Maebe
jonas.maebe at elis.ugent.be
Mon Sep 29 10:45:49 CEST 2008
On 29 Sep 2008, at 09:27, EarMaster - Bent Olsen wrote:
> Is there any precautions one should make when sharing FPC codes
> between i386
> and PowerPC?
>
> I've few calls to AudioToolbox API's which works fine under i386, but
> crashes in PPC - the exact API call is AudioConverterNew, and the
> records
> passed to the API looks good, and is also returned by AudioToolbox
> itself.
>
> It doesn't return an error code - just crashes with EXC_ARITHMETIC
> error in
> a procedure called SincKernel::CalculateFilterCoefficients.
First of all: when starting a new thread, please write a new message
to the mailing list rather than replying to an existing one and
changing the subject. Such replies mess up automatic threading both in
the web archive and in various mail clients.
That said, the crash you get is caused by a floating point arithmetic
error (one of many) in Apple's system frameworks (which also exist in
several OpenGL implementations for Windows, in GTK2 etc). These do not
cause any problems in most C programs, because in C programs by
default all floating point exceptions are masked (and hence no one
ever notices such errors).
You can mask them in FPC as well by adding the "math" unit to your
uses clause and performing the following call at the start of your
program:
SetExceptionMask([exInvalidOp, exDenormalized, exZeroDivide,
exOverflow, exUnderflow, exPrecision])
Note that this will mask all floating point exceptions everywhere,
i.e., also in your Pascal code. The only alternative is to save,
change and restore the floating point exception mask around every call
to a system routine directly or indirectly related to audio or graphics.
Jonas
More information about the fpc-pascal
mailing list