File: prevent-floating-point-exception.patch

package info (click to toggle)
ecl 20.4.24%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,632 kB
  • sloc: ansic: 148,594; lisp: 67,213; xml: 8,221; asm: 5,551; sh: 3,145; makefile: 1,973; cpp: 190; java: 116
file content (44 lines) | stat: -rw-r--r-- 1,942 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From cdb602e40de866058aea37e47f886e026b87dd99 Mon Sep 17 00:00:00 2001
From: Marius Gerbershagen <marius.gerbershagen@gmail.com>
Date: Sat, 31 Oct 2020 11:34:28 +0100
Subject: [PATCH] fpe: prevent spurious floating point exceptions in
 WITH_LISP_FPE

feenableexcept may generate a SIGFPE signal if exception status flags
are not cleared beforehand. Happens for example on powerpc platforms.

Fixes #612.
---
 src/doc/manual/user-guide/embedding.txi | 3 +--
 src/h/impl/math_fenv.h                  | 4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

--- a/src/doc/manual/user-guide/embedding.txi
+++ b/src/doc/manual/user-guide/embedding.txi
@@ -258,8 +258,7 @@
 later restoring the floating point environment of surrounding C code
 so that changes in the floating point environment don't leak outside.
 
-@coderef{ECL_WITH_LISP_FPE} can be also used before ECL has booted or
-before an external thread has been imported.
+@coderef{ECL_WITH_LISP_FPE} can be also used before ECL has booted.
 
 @exindex Safely executing Lisp code with floating point exceptions in embedding program
 @paragraph Example
--- a/src/h/impl/math_fenv.h
+++ b/src/h/impl/math_fenv.h
@@ -75,12 +75,12 @@
 #  define ECL_WITH_LISP_FPE_BEGIN do {                       \
         fenv_t __fenv;                                       \
         fegetenv(&__fenv);                                   \
+        feclearexcept(FE_ALL_EXCEPT);                        \
         if (ecl_get_option(ECL_OPT_BOOTED) > 0) {            \
                 int bits = ecl_process_env()->trap_fpe_bits; \
                 fedisableexcept(FE_ALL_EXCEPT & ~bits);      \
                 feenableexcept(FE_ALL_EXCEPT & bits);        \
-        }                                                    \
-        feclearexcept(FE_ALL_EXCEPT);
+        }
 # else
 #  define ECL_WITH_LISP_FPE_BEGIN do {                   \
         fenv_t __fenv;                                   \