[arch-commits] Commit in sagemath-doc/repos (6 files)
Antonio Rojas
arojas at archlinux.org
Sun Mar 24 13:06:12 UTC 2019
Date: Sunday, March 24, 2019 @ 13:06:11
Author: arojas
Revision: 443326
archrelease: copy trunk to community-testing-any
Added:
sagemath-doc/repos/community-testing-any/
sagemath-doc/repos/community-testing-any/PKGBUILD
(from rev 443325, sagemath-doc/trunk/PKGBUILD)
sagemath-doc/repos/community-testing-any/docbuild_main.patch
(from rev 443325, sagemath-doc/trunk/docbuild_main.patch)
sagemath-doc/repos/community-testing-any/sagemath-doc-segfault.patch
(from rev 443325, sagemath-doc/trunk/sagemath-doc-segfault.patch)
sagemath-doc/repos/community-testing-any/sagemath-doc-sphinx-1.8.patch
(from rev 443325, sagemath-doc/trunk/sagemath-doc-sphinx-1.8.patch)
sagemath-doc/repos/community-testing-any/sagemath-ecl-sigfpe.patch
(from rev 443325, sagemath-doc/trunk/sagemath-ecl-sigfpe.patch)
-------------------------------+
PKGBUILD | 68 ++++++++
docbuild_main.patch | 6
sagemath-doc-segfault.patch | 14 +
sagemath-doc-sphinx-1.8.patch | 332 ++++++++++++++++++++++++++++++++++++++++
sagemath-ecl-sigfpe.patch | 147 +++++++++++++++++
5 files changed, 567 insertions(+)
Copied: sagemath-doc/repos/community-testing-any/PKGBUILD (from rev 443325, sagemath-doc/trunk/PKGBUILD)
===================================================================
--- community-testing-any/PKGBUILD (rev 0)
+++ community-testing-any/PKGBUILD 2019-03-24 13:06:11 UTC (rev 443326)
@@ -0,0 +1,68 @@
+# Maintainer: Antonio Rojas <arojas at archlinux.org>
+
+pkgname=sagemath-doc
+pkgver=8.7
+pkgrel=1
+pkgdesc="HTML documentation and inline help for SageMath"
+arch=(any)
+url="http://www.sagemath.org"
+license=(GPL)
+depends=(python2-sphinx gap-doc pplpy-doc thebe)
+makedepends=(sagemath python2-pyzmq python2-docutils python2-jupyter_client python2-pkgconfig cython2 python2-ipywidgets)
+source=(sagemath-$pkgver.tar.gz::"https://github.com/sagemath/sage/archive/$pkgver.tar.gz"
+ docbuild_main.patch
+ sagemath-doc-sphinx-1.8.patch
+ sagemath-doc-segfault.patch
+ sagemath-ecl-sigfpe.patch)
+sha256sums=('263c3b3fc956b8bebc532f3b51e68c1b0d559d3b7e7c9fadffdfc0f4dbae18ab'
+ 'ea5e17bb7a7cb36a22e5e3872fcc2585852bc971c4b139b0b2cd69a36c1b009b'
+ 'ec6835d555056e1f20684de015f43c46cff62a132c9cd6f5ea7243c6bacd3f1e'
+ '2ee218610001f906015df647881581ff1f7eb0acf923b79b72056965129bac22'
+ 'a42f3b152b1aedb8abf16bc70971419919d1fe30328574e7fef8305f9d07d938')
+
+prepare() {
+ cd sage-$pkgver
+
+# fix relative imports
+ patch -p0 -i ../docbuild_main.patch
+# use sage_setup imports from sagemath source, but use system sage ones (which include compiled modules)
+ mkdir -p local-python
+ ln -sr src/sage_setup local-python
+# fix build with sphinx 1.8
+ patch -p1 -i ../sagemath-doc-sphinx-1.8.patch
+# Fix segfault when pari is compiled with threads https://trac.sagemath.org/ticket/26608
+ patch -p1 -i ../sagemath-doc-segfault.patch
+# Fix SIGFPE crashes with ecl 16.1.3 https://trac.sagemath.org/ticket/22191
+ patch -p1 -i ../sagemath-ecl-sigfpe.patch
+}
+
+build() {
+ cd sage-$pkgver/src
+
+ export SAGE_LOCAL="/usr"
+ export SAGE_ROOT="/usr"
+ export SAGE_SRC="$PWD"
+ export SAGE_DOC_SRC="$SAGE_SRC"/doc
+ export SAGE_DOC="$SAGE_DOC_SRC"
+ export SAGE_DOC_MATHJAX=yes
+ export PYTHONPATH="$srcdir"/sage-$pkgver/local-python
+ python2 sage_setup/docbuild --no-pdf-links all html
+}
+
+package() {
+ cd sage-$pkgver/src/doc
+
+ mkdir -p "$pkgdir"/usr/share/doc/sage/en
+ cp -r en/introspect "$pkgdir"/usr/share/doc/sage/en
+ cp -r common "$pkgdir"/usr/share/doc/sage
+ cp -r html "$pkgdir"/usr/share/doc/sage
+
+# Replace duplicated files by symlinks (Gentoo)
+ cd "$pkgdir"/usr/share/doc/sage
+ mv html/en/_static{,.tmp}
+ for _dir in `find -name _static` ; do
+ rm -r $_dir
+ ln -s /usr/share/doc/sage/html/en/_static $_dir
+ done
+ mv html/en/_static{.tmp,}
+}
Copied: sagemath-doc/repos/community-testing-any/docbuild_main.patch (from rev 443325, sagemath-doc/trunk/docbuild_main.patch)
===================================================================
--- community-testing-any/docbuild_main.patch (rev 0)
+++ community-testing-any/docbuild_main.patch 2019-03-24 13:06:11 UTC (rev 443326)
@@ -0,0 +1,6 @@
+--- src/sage_setup/docbuild/__main__.py.orig
++++ src/sage_setup/docbuild/__main__.py
+@@ -1,2 +1,2 @@
+-from . import main
++from sage_setup.docbuild import main
+ main()
Copied: sagemath-doc/repos/community-testing-any/sagemath-doc-segfault.patch (from rev 443325, sagemath-doc/trunk/sagemath-doc-segfault.patch)
===================================================================
--- community-testing-any/sagemath-doc-segfault.patch (rev 0)
+++ community-testing-any/sagemath-doc-segfault.patch 2019-03-24 13:06:11 UTC (rev 443326)
@@ -0,0 +1,14 @@
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 5877b5b..7dc8ff7 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -265,7 +265,7 @@ class DocBuilder(object):
+ inventory = builder_helper('inventory')
+
+
+-if not (CYGWIN_VERSION and CYGWIN_VERSION[0] < 3):
++if False:
+ def build_many(target, args):
+ # Pool() uses an actual fork() to run each new instance. This is
+ # important for performance reasons, i.e., don't use a forkserver when
+
Copied: sagemath-doc/repos/community-testing-any/sagemath-doc-sphinx-1.8.patch (from rev 443325, sagemath-doc/trunk/sagemath-doc-sphinx-1.8.patch)
===================================================================
--- community-testing-any/sagemath-doc-sphinx-1.8.patch (rev 0)
+++ community-testing-any/sagemath-doc-sphinx-1.8.patch 2019-03-24 13:06:11 UTC (rev 443326)
@@ -0,0 +1,332 @@
+diff --git a/src/doc/common/conf.py b/src/doc/common/conf.py
+index 70dd17f..e9a3dae 100644
+--- a/src/doc/common/conf.py
++++ b/src/doc/common/conf.py
+@@ -4,6 +4,8 @@ import sage.version
+ from sage.misc.sagedoc import extlinks
+ import dateutil.parser
+ from six import iteritems
++from docutils import nodes
++from docutils.transforms import Transform
+
+ # If your extensions are in another directory, add it here.
+ sys.path.append(os.path.join(SAGE_SRC, "sage_setup", "docbuild", "ext"))
+@@ -669,7 +671,7 @@ def call_intersphinx(app, env, node, contnode):
+ sage: for line in open(thematic_index).readlines(): # optional - dochtml
+ ....: if "padics" in line:
+ ....: _ = sys.stdout.write(line)
+- <li><a class="reference external" href="../reference/padics/sage/rings/padics/tutorial.html#sage-rings-padics-tutorial" title="(in Sage Reference Manual: p-Adics v...)"><span>Introduction to the -adics</span></a></li>
++ <li><a class="reference external" href="../reference/padics/sage/rings/padics/tutorial.html#sage-rings-padics-tutorial" title="(in Sage Reference Manual: p-Adics v...)"><span>Introduction to the p-adics</span></a></li>
+ """
+ debug_inf(app, "???? Trying intersphinx for %s" % node['reftarget'])
+ builder = app.builder
+diff --git a/src/sage/misc/sphinxify.py b/src/sage/misc/sphinxify.py
+index 6e21344..4270294 100644
+--- a/src/sage/misc/sphinxify.py
++++ b/src/sage/misc/sphinxify.py
+@@ -68,20 +68,20 @@ def sphinxify(docstring, format='html'):
+ sage: assert n == len(sys.path)
+ """
+ srcdir = mkdtemp()
+- base_name = os.path.join(srcdir, 'docstring')
+- rst_name = base_name + '.rst'
++ outdir = mkdtemp()
++ src_base_name = os.path.join(srcdir, 'docstring')
++ out_base_name = os.path.join(outdir, 'docstring')
++ rst_name = src_base_name + '.rst'
+
+ if format == 'html':
+ suffix = '.html'
+ else:
+ suffix = '.txt'
+- output_name = base_name + suffix
++ output_name = out_base_name + suffix
+
+ with open(rst_name, 'w') as filed:
+ filed.write(docstring)
+
+- # Sphinx constructor: Sphinx(srcdir, confdir, outdir, doctreedir,
+- # buildername, confoverrides, status, warning, freshenv).
+ confdir = os.path.join(SAGE_DOC_SRC, 'en', 'introspect')
+
+ open(os.path.join(srcdir, 'docutils.conf'), 'w').write(r"""
+@@ -93,7 +93,9 @@ smart_quotes = no
+
+ import sys
+ old_sys_path = list(sys.path) # Sphinx modifies sys.path
+- sphinx_app = Sphinx(srcdir, confdir, srcdir, doctreedir, format,
++ # Sphinx constructor: Sphinx(srcdir, confdir, outdir, doctreedir,
++ # buildername, confoverrides, status, warning, freshenv).
++ sphinx_app = Sphinx(srcdir, confdir, outdir, doctreedir, format,
+ confoverrides, None, None, True)
+ sphinx_app.build(None, [rst_name])
+ sys.path = old_sys_path
+@@ -118,13 +120,15 @@ smart_quotes = no
+ # Remove spurious \(, \), \[, \].
+ output = output.replace('\\(', '').replace('\\)', '').replace('\\[', '').replace('\\]', '')
+ else:
+- print("BUG -- Sphinx error")
++ from warnings import warn
++ warn("Sphinx did not produce any output", Warning)
+ if format == 'html':
+ output = '<pre class="introspection">%s</pre>' % docstring
+ else:
+ output = docstring
+
+ shutil.rmtree(srcdir, ignore_errors=True)
++ shutil.rmtree(outdir, ignore_errors=True)
+
+ return output
+
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 4546f87..9efe45d 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -53,7 +53,6 @@ import warnings
+
+ logger = logging.getLogger(__name__)
+
+-import sphinx.cmdline
+ import sphinx.util.console
+ import sphinx.ext.intersphinx
+
+@@ -354,6 +353,7 @@ class AllBuilder(object):
+ getattr(get_builder(document), 'inventory')(*args, **kwds)
+
+ logger.warning("Building reference manual, second pass.\n")
++ sage_makedirs(os.path.join(SAGE_DOC, "html", "en", "reference", "_static"))
+ for document in refs:
+ getattr(get_builder(document), name)(*args, **kwds)
+
+diff --git a/src/sage_setup/docbuild/ext/inventory_builder.py b/src/sage_setup/docbuild/ext/inventory_builder.py
+index 113849a..92deaa1 100644
+--- a/src/sage_setup/docbuild/ext/inventory_builder.py
++++ b/src/sage_setup/docbuild/ext/inventory_builder.py
+@@ -12,6 +12,7 @@ from os import path
+
+ from six import iteritems, text_type
+
++import shutil
+
+ try:
+ from hashlib import md5
+@@ -107,6 +108,18 @@ class InventoryBuilder(StandaloneHTMLBuilder):
+ """
+ raise RuntimeError("This function shouldn't be called in \"%s\" builder"%(self.name))
+
++ def cleanup(self):
++ """
++ Remove the '_static' directory.
++
++ This directory is unnecessary for the inventory build, but it
++ may be created by the graphviz extension. Its presence will
++ break the docbuild later on, so remove it.
++ """
++ if path.isdir(path.join(self.outdir, '_static')):
++ shutil.rmtree(path.join(self.outdir, '_static'))
++
++
+ copy_image_files = removed_method_error
+ copy_download_files = removed_method_error
+ copy_static_files = removed_method_error
+diff --git a/src/sage_setup/docbuild/ext/multidocs.py b/src/sage_setup/docbuild/ext/multidocs.py
+index 15c7ca5..bc5ca9e 100644
+--- a/src/sage_setup/docbuild/ext/multidocs.py
++++ b/src/sage_setup/docbuild/ext/multidocs.py
+@@ -32,6 +32,7 @@ from sphinx.util.console import bold
+ from sage.env import SAGE_DOC
+ from sage.misc.misc import sage_makedirs
+
++logger = sphinx.util.logging.getLogger(__name__)
+
+ CITE_FILENAME = 'citations.pickle'
+
+@@ -48,13 +49,13 @@ def merge_environment(app, env):
+
+ - domaindata['py']['modules'] # list of python modules
+ """
+- app.info(bold('Merging environment/index files...'))
++ logger.info(bold('Merging environment/index files...'))
+ for curdoc in app.env.config.multidocs_subdoc_list:
+- app.info(" %s:" % curdoc, nonl=1)
++ logger.info(" %s:"%curdoc, nonl=1)
+ docenv = get_env(app, curdoc)
+ if docenv is not None:
+ fixpath = lambda path: os.path.join(curdoc, path)
+- app.info(" %s todos, %s index, %s citations"%(
++ logger.info(" %s todos, %s index, %s citations"%(
+ len(docenv.todo_all_todos),
+ len(docenv.indexentries),
+ len(docenv.domaindata["std"]["citations"])
+@@ -99,8 +100,8 @@ def merge_environment(app, env):
+ six.iteritems(docenv.domaindata['py']['modules'])):
+ newmodules[ind] = (fixpath(modpath),v1,v2,v3)
+ env.domaindata['py']['modules'].update(newmodules)
+- app.info(", %s modules"%(len(newmodules)))
+- app.info('... done (%s todos, %s index, %s citations, %s modules)'%(
++ logger.info(", %s modules"%(len(newmodules)))
++ logger.info('... done (%s todos, %s index, %s citations, %s modules)'%(
+ len(env.todo_all_todos),
+ len(env.indexentries),
+ len(env.domaindata["std"]["citations"]),
+@@ -118,8 +119,8 @@ def get_env(app, curdoc):
+ try:
+ f = open(filename, 'rb')
+ except IOError:
+- app.info("")
+- app.warn("Unable to fetch %s " % filename)
++ logger.info("")
++ logger.warning("Unable to fetch %s " % filename)
+ return None
+ docenv = cPickle.load(f)
+ f.close()
+@@ -130,16 +131,16 @@ def merge_js_index(app):
+ """
+ Merge the JS indexes of the sub-docs into the main JS index
+ """
+- app.info('')
+- app.info(bold('Merging js index files...'))
++ logger.info('')
++ logger.info(bold('Merging js index files...'))
+ mapping = app.builder.indexer._mapping
+ for curdoc in app.env.config.multidocs_subdoc_list:
+- app.info(" %s:"%curdoc, nonl=1)
++ logger.info(" %s:"%curdoc, nonl=1)
+ fixpath = lambda path: os.path.join(curdoc, path)
+ index = get_js_index(app, curdoc)
+ if index is not None:
+ # merge the mappings
+- app.info(" %s js index entries"%(len(index._mapping)))
++ logger.info(" %s js index entries"%(len(index._mapping)))
+ for (ref, locs) in six.iteritems(index._mapping):
+ newmapping = set(map(fixpath, locs))
+ if ref in mapping:
+@@ -159,8 +160,8 @@ def merge_js_index(app):
+ dest = os.path.join(app.outdir, "_sources", curdoc)
+ if not os.path.exists(dest):
+ os.symlink(os.path.join("..", curdoc, "_sources"), dest)
+- app.info('... done (%s js index entries)'%(len(mapping)))
+- app.info(bold('Writing js search indexes...'), nonl=1)
++ logger.info('... done (%s js index entries)'%(len(mapping)))
++ logger.info(bold('Writing js search indexes...'), nonl=1)
+ return [] # no extra page to setup
+
+
+@@ -181,8 +182,8 @@ def get_js_index(app, curdoc):
+ try:
+ f = open(indexfile, 'r')
+ except IOError:
+- app.info("")
+- app.warn("Unable to fetch %s " % indexfile)
++ logger.info("")
++ logger.warning("Unable to fetch %s " % indexfile)
+ return None
+ indexer.load(f, sphinx.search.js_index)
+ f.close()
+@@ -240,7 +241,7 @@ def write_citations(app, citations):
+ outdir = citation_dir(app)
+ with atomic_write(os.path.join(outdir, CITE_FILENAME), binary=True) as f:
+ cPickle.dump(citations, f)
+- app.info("Saved pickle file: %s" % CITE_FILENAME)
++ logger.info("Saved pickle file: %s" % CITE_FILENAME)
+
+
+ def fetch_citation(app, env):
+@@ -248,13 +249,13 @@ def fetch_citation(app, env):
+ Fetch the global citation index from the refman to allow for cross
+ references.
+ """
+- app.builder.info(bold('loading cross citations... '), nonl=1)
++ logger.info(bold('loading cross citations... '), nonl=1)
+ filename = os.path.join(citation_dir(app), '..', CITE_FILENAME)
+ if not os.path.isfile(filename):
+ return
+ with open(filename, 'rb') as f:
+ cache = cPickle.load(f)
+- app.builder.info("done (%s citations)."%len(cache))
++ logger.info("done (%s citations)."%len(cache))
+ cite = env.domaindata["std"]["citations"]
+ for ind, (path, tag, lineno) in six.iteritems(cache):
+ if ind not in cite: # don't override local citation
+@@ -267,18 +268,18 @@ def init_subdoc(app):
+ doc itself.
+ """
+ if app.config.multidocs_is_master:
+- app.info(bold("Compiling the master document"))
++ logger.info(bold("Compiling the master document"))
+ app.connect('env-updated', merge_environment)
+ app.connect('html-collect-pages', merge_js_index)
+ if app.config.multidocs_subdoc_list:
+ # Master file with indexes computed by merging indexes:
+ # Monkey patch index fetching to silence warning about broken index
+ def load_indexer(docnames):
+- app.builder.info(bold('skipping loading of indexes... '), nonl=1)
++ logger.info(bold('skipping loading of indexes... '), nonl=1)
+ app.builder.load_indexer = load_indexer
+
+ else:
+- app.info(bold("Compiling a sub-document"))
++ logger.info(bold("Compiling a sub-document"))
+ app.connect('html-page-context', fix_path_html)
+ if not app.config.multidoc_first_pass:
+ app.connect('env-updated', fetch_citation)
+@@ -294,7 +295,7 @@ def init_subdoc(app):
+ def copy_static_files(self):
+ [...]
+ """
+- app.builder.info(bold('linking _static directory.'))
++ logger.info(bold('linking _static directory.'))
+ static_dir = os.path.join(app.builder.outdir, '_static')
+ master_static_dir = os.path.join('..', '_static')
+ if os.path.lexists(static_dir):
+@@ -308,6 +309,9 @@ def init_subdoc(app):
+
+ if app.config.multidoc_first_pass == 1:
+ app.config.intersphinx_mapping = {}
++ else:
++ app.emit('env-check-consistency', app.env)
++
+
+
+ def setup(app):
+diff --git a/src/sage_setup/docbuild/ext/sage_autodoc.py b/src/sage_setup/docbuild/ext/sage_autodoc.py
+index 25895d3..2e640a0 100644
+--- a/src/sage_setup/docbuild/ext/sage_autodoc.py
++++ b/src/sage_setup/docbuild/ext/sage_autodoc.py
+@@ -40,7 +40,8 @@ from sphinx.errors import ExtensionError
+ from sphinx.ext.autodoc.importer import mock, import_object, get_object_members
+ from sphinx.ext.autodoc.inspector import format_annotation, formatargspec
+ from sphinx.locale import _, __
+-from sphinx.pycode import ModuleAnalyzer, PycodeError
++from sphinx.pycode import ModuleAnalyzer
++from sphinx.errors import ExtensionError, PycodeError
+ from sphinx.util import logging
+ from sphinx.util import rpartition, force_decode
+ from sphinx.util.docstrings import prepare_docstring
+diff --git a/src/sage_setup/docbuild/sphinxbuild.py b/src/sage_setup/docbuild/sphinxbuild.py
+index 8c7efbe..9a2fba7 100644
+--- a/src/sage_setup/docbuild/sphinxbuild.py
++++ b/src/sage_setup/docbuild/sphinxbuild.py
+@@ -22,6 +22,7 @@ We redirect stdout and stderr to our own logger, and remove some unwanted chatte
+ # ****************************************************************************
+
+ import os, sys, re, sphinx
++import sphinx.cmd.build
+
+ # override the fancy multi-line formatting
+ def term_width_line(text):
+@@ -304,12 +305,12 @@ def runsphinx():
+ try:
+ sys.stdout = SageSphinxLogger(sys.stdout, os.path.basename(output_dir))
+ sys.stderr = SageSphinxLogger(sys.stderr, os.path.basename(output_dir))
+- # Note that this call as of eraly 2018 leaks memory. So make sure that
++ # Note that this call as of early 2018 leaks memory. So make sure that
+ # you don't call runsphinx() several times in a row. (i.e., you want to
+ # fork() somewhere before this call.)
+ # We don't use subprocess here, as we don't want to re-initialize Sage
+ # for every docbuild as this takes a while.
+- sphinx.cmdline.main(sys.argv[1:])
++ sphinx.cmd.build.main(sys.argv[1:])
+ sys.stderr.raise_errors()
+ sys.stdout.raise_errors()
+ finally:
Copied: sagemath-doc/repos/community-testing-any/sagemath-ecl-sigfpe.patch (from rev 443325, sagemath-doc/trunk/sagemath-ecl-sigfpe.patch)
===================================================================
--- community-testing-any/sagemath-ecl-sigfpe.patch (rev 0)
+++ community-testing-any/sagemath-ecl-sigfpe.patch 2019-03-24 13:06:11 UTC (rev 443326)
@@ -0,0 +1,147 @@
+diff --git a/src/sage/libs/ecl.pyx b/src/sage/libs/ecl.pyx
+index e408866..fa24ac0 100644
+--- a/src/sage/libs/ecl.pyx
++++ b/src/sage/libs/ecl.pyx
+@@ -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)"))
+-
+ ecl_has_booted = 1
+
+ cdef cl_object ecl_safe_eval(cl_object form) except NULL:
+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);
+ }
+
More information about the arch-commits
mailing list