FP exceptions on Raspberry Pi

Daniel Kochmański daniel at turtleware.eu
Tue Dec 31 08:11:54 UTC 2019

Hey Dave,

Dave Richards writes:

> It appears that the VFP unit on the Raspberry Pi does not generate FPU
> exceptions.  Therefore, no SIGFPE is generated and cannot be handled by ECL.
> This causes numerous 'make check' test failures.  I am working on a patch.
> I am not very familiar with the ECL C environment so I am sure the patch
> will need some help.  The approach is as follows:
> 1. There is no value in registering a SIGFPE handler.  For the ARM I will
> just not register the handler at all.

If you are interested in how handler works please take a look at file
src/c/unixint.d (most notably install_fpe_handler). That said the option
you look for is ECL_OPT_TRAP_SIGFPE (src/c/main.d). That said there is
no harm with leaving it at its default value, if sigfpe is not signaled
then the handler will simply not be called.

> 2. I will created an arch/fpe_arm.c file.  I will re-define the macro to
> read the FPSCR register and check for exception bits being set.  If any are
> I will call a C function that will disambiguate which exception to map to a
> condition and signal the condition.

please see files:
- c/arch/fpe_*.c for software ecl_detect_fpe() definitions
- c/number.d for a definition of DO_DETECT_FPE()

calls to floating point operations are always detected in the float
number constructors (if software fpe handling is used). They are
signalled with ecl_deliver_fpe.

> 3. I was planning on creating a static inline function for this purpose
> right inside fpe_arm.c but if it should go somewhere else I'd be happy to
> put it there.  The inline thing is just an excuse for sticking in the
> fpe_arm.c file.  In reality it's probably better to make a C function call
> to do the heavy lifting rather than making each FPE check pay for it.

If you need a file then fpe_/arch/.c is the right place to put
it. Preferably this file is self-contained (static function definition).
> 	Dave

Best regards,

Daniel Kochmański ;; aka jackdaniel | Przemyśl, Poland
TurtleWare - Daniel Kochmański      | www.turtleware.eu

"Be the change that you wish to see in the world." - Mahatma Gandhi

More information about the ecl-devel mailing list