summarylogtreecommitdiffstats
path: root/sagemath-ecl-sigfpe.patch
diff options
context:
space:
mode:
authorAntonio Rojas2019-01-13 08:51:59 +0000
committerAntonio Rojas2019-01-13 08:51:59 +0000
commit0d93c577796185e7b537b2f8506f9edcc9d555f3 (patch)
tree21786cefe6caf4b84c8359c5ae0729d5b3b36206 /sagemath-ecl-sigfpe.patch
parentc53c51b496753121148f90c504c3bb524ce97439 (diff)
downloadaur-0d93c577796185e7b537b2f8506f9edcc9d555f3.tar.gz
Update patches
Diffstat (limited to 'sagemath-ecl-sigfpe.patch')
-rw-r--r--sagemath-ecl-sigfpe.patch154
1 files changed, 139 insertions, 15 deletions
diff --git a/sagemath-ecl-sigfpe.patch b/sagemath-ecl-sigfpe.patch
index f3d06fdd972e..f0984acebc67 100644
--- a/sagemath-ecl-sigfpe.patch
+++ b/sagemath-ecl-sigfpe.patch
@@ -1,23 +1,147 @@
diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
-index 1fafb6c..4f730ad 100644
+index e408866..fa24ac0 100644
--- a/src/sage/libs/ecl.pyx
+++ b/src/sage/libs/ecl.pyx
-@@ -321,6 +321,7 @@ def init_ecl():
+@@ -16,7 +16,7 @@ from __future__ import print_function, absolute_import
+ #adapted to work with pure Python types.
+
+ from libc.stdlib cimport abort
+-from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD
++from libc.signal cimport SIGINT, SIGBUS, SIGSEGV, SIGCHLD, SIGFPE
+ from libc.signal cimport raise_ as signal_raise
+ from posix.signal cimport sigaction, sigaction_t
+ cimport cysignals.signals
+@@ -48,9 +48,14 @@ cdef extern from "eclsig.h":
+ void ecl_sig_off()
+ cdef sigaction_t ecl_sigint_handler
+ cdef sigaction_t ecl_sigbus_handler
++ cdef sigaction_t ecl_sigfpe_handler
+ cdef sigaction_t ecl_sigsegv_handler
+ cdef mpz_t ecl_mpz_from_bignum(cl_object obj)
+ cdef cl_object ecl_bignum_from_mpz(mpz_t num)
++ cdef int fegetexcept()
++ cdef int feenableexcept(int)
++ cdef int fedisableexcept(int)
++ cdef int ecl_feflags
+
+ cdef cl_object string_to_object(char * s):
+ return ecl_read_from_cstring(s)
+@@ -239,6 +244,7 @@ def init_ecl():
+ global ecl_has_booted
+ cdef char *argv[1]
+ cdef sigaction_t sage_action[32]
++ cdef int sage_fpes
+ cdef int i
+
+ if ecl_has_booted:
+@@ -258,6 +264,8 @@ def init_ecl():
+ for i in range(1,32):
+ sigaction(i, NULL, &sage_action[i])
+
++ sage_fpes = fegetexcept()
++
+ #initialize ECL
+ ecl_set_option(ECL_OPT_SIGNAL_HANDLING_THREAD, 0)
+ cl_boot(1, argv)
+@@ -265,8 +273,12 @@ def init_ecl():
+ #save signal handler from ECL
+ sigaction(SIGINT, NULL, &ecl_sigint_handler)
+ sigaction(SIGBUS, NULL, &ecl_sigbus_handler)
++ sigaction(SIGFPE, NULL, &ecl_sigfpe_handler)
+ sigaction(SIGSEGV, NULL, &ecl_sigsegv_handler)
+
++ #save ECL's floating point exception flags
++ ecl_feflags = fegetexcept()
++
+ #verify that no SIGCHLD handler was installed
+ cdef sigaction_t sig_test
+ sigaction(SIGCHLD, NULL, &sig_test)
+@@ -277,6 +289,9 @@ def init_ecl():
+ for i in range(1,32):
+ sigaction(i, &sage_action[i], NULL)
+
++ fedisableexcept(ecl_feflags)
++ feenableexcept(sage_fpes)
++
+ #initialise list of objects and bind to global variable
+ # *SAGE-LIST-OF-OBJECTS* to make it rooted in the reachable tree for the GC
+ list_of_objects=cl_cons(Cnil,cl_cons(Cnil,Cnil))
+@@ -320,7 +335,6 @@ def init_ecl():
+ (values nil (princ-to-string cnd)))))
"""))
safe_funcall_clobj=cl_eval(string_to_object(b"(symbol-function 'sage-safe-funcall)"))
-
-+ cl_eval(string_to_object("(si::trap-fpe T NIL)"))
+-
ecl_has_booted = 1
cdef cl_object ecl_safe_eval(cl_object form) except NULL:
---- sage-8.5/src/sage/interfaces/maxima_lib.py.orig 2018-12-23 21:59:46.431420340 +0000
-+++ sage-8.5/src/sage/interfaces/maxima_lib.py 2018-12-23 22:00:05.494568891 +0000
-@@ -107,6 +107,7 @@
- else:
- ecl_eval("(require 'maxima)")
- ecl_eval("(in-package :maxima)")
-+ecl_eval("(si::trap-fpe 'floating-point-overflow nil)")
- ecl_eval("(setq $nolabels t))")
- ecl_eval("(defvar *MAXIMA-LANG-SUBDIR* NIL)")
- ecl_eval("(set-locale-subdir)")
-
+diff --git a/src/sage/libs/eclsig.h b/src/sage/libs/eclsig.h
+index f9f2690..a7e1f40 100644
+--- a/src/sage/libs/eclsig.h
++++ b/src/sage/libs/eclsig.h
+@@ -9,24 +9,66 @@
+
+
+ #include <signal.h>
++
++/* Rummage around to determine how ECL was configured */
++#define ECL_AVOID_FPE_H /* Prevent some local includes */
++#include <ecl/config-internal.h>
++
++#ifdef HAVE_FENV_H
++#include <fenv.h>
++#ifndef FE_ALL_EXCEPT
++#define FE_ALL_EXCEPT FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INVALID
++#endif
++#else
++#ifndef FE_ALL_EXCEPT
++#define FE_ALL_EXCEPT 0
++#endif
++#define feclearexcept(flags) do {} while (0)
++#endif
++
++#ifndef HAVE_FEENABLEEXCEPT
++/* These are GNU extensions */
++#define fegetexcept() 0
++#define feenablexcept(flags) do {} while (0)
++#define fdisableexcept(flags) do {} while (0)
++#endif
++
+ static struct sigaction ecl_sigint_handler;
+ static struct sigaction ecl_sigbus_handler;
++static struct sigaction ecl_sigfpe_handler;
+ static struct sigaction ecl_sigsegv_handler;
+ static struct sigaction sage_sigint_handler;
+ static struct sigaction sage_sigbus_handler;
++static struct sigaction sage_sigfpe_handler;
+ static struct sigaction sage_sigsegv_handler;
++static int ecl_feflags;
++static int sage_feflags;
+
+ static inline void set_ecl_signal_handler(void)
+ {
+ sigaction(SIGINT, &ecl_sigint_handler, &sage_sigint_handler);
+ sigaction(SIGBUS, &ecl_sigbus_handler, &sage_sigbus_handler);
++ sigaction(SIGFPE, &ecl_sigfpe_handler, &sage_sigfpe_handler);
+ sigaction(SIGSEGV, &ecl_sigsegv_handler, &sage_sigsegv_handler);
++
++ /* first clear pending floating point exceptions, if any */
++ feclearexcept(FE_ALL_EXCEPT);
++
++ /* sage_feflags should be 0; we don't set them otherwise */
++ sage_feflags = fedisableexcept(FE_ALL_EXCEPT);
++ feenableexcept(ecl_feflags);
+ }
+
+ static inline void unset_ecl_signal_handler(void)
+ {
++ /* clear pending exceptions and restore previous exception mask */
++ feclearexcept(FE_ALL_EXCEPT);
++ ecl_feflags = fedisableexcept(FE_ALL_EXCEPT);
++ feenableexcept(sage_feflags);
++
+ sigaction(SIGINT, &sage_sigint_handler, NULL);
+ sigaction(SIGBUS, &sage_sigbus_handler, NULL);
++ sigaction(SIGFPE, &sage_sigfpe_handler, NULL);
+ sigaction(SIGSEGV, &sage_sigsegv_handler, NULL);
+ }
+