From ed322e109664c4004c48129c23965d087bcfae46 Mon Sep 17 00:00:00 2001 From: Robert Smith Date: Wed, 11 Oct 2023 13:40:29 -0700 Subject: [PATCH] add restart to reload MPFR if it couldn't be Co-authored by: Phoebe Goldman --- library/big-float/impl-sbcl.lisp | 33 ++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/library/big-float/impl-sbcl.lisp b/library/big-float/impl-sbcl.lisp index c3794160d..c81761d6a 100644 --- a/library/big-float/impl-sbcl.lisp +++ b/library/big-float/impl-sbcl.lisp @@ -2,6 +2,31 @@ ;;;; ;;;; Arbitrary precision floats using SBCL's MPFR library. +(in-package #:cl-user) + +#-sbcl +(error "This file is hopelessly SBCL specific.") + +#+sbcl +(eval-when (:compile-toplevel :load-toplevel) + (loop :until (uiop:featurep :sb-mpfr) + :do (restart-case (error "SB-MPFR failed to load, for some reason. ~ + This is probably due to the shared library ~ + not existing, or the system being unable ~ + to find it. If you do not wish to install it, ~ + re-compile Coalton from scratch with the ~ + environment variable ~ + ~ + COALTON_PORTABLE_BIGFLOAT=1 ~ + ~ + set, or add the feature ~ + :COALTON-PORTABLE-BIGFLOAT.") + (reload-sb-mpfr () + :report "Reload the MPFR library" + (handler-case (sb-mpfr::load-mpfr) + (simple-warning (e) (declare (ignore e)))))))) + + (in-package #:coalton-library/big-float) (named-readtables:in-readtable coalton:coalton) @@ -9,14 +34,6 @@ #+coalton-release (cl:declaim #.coalton-impl/settings:*coalton-optimize-library*) -#-sbcl (error "This file is hopelessly SBCL specific.") -#-sb-mpfr (error "SB-MPFR failed to load, for some reason. ~ - This is probably due to the shared library ~ - not existing, or the system being unable ~ - to find it. ~ - Set COALTON_PORTABLE_BIGFLOAT=1 or ~ - add the feature :coalton-portable-bigfloat.") - ;;; Preliminary patched functionality for SB-MPFR ;;; ;;; This functionality has been submitted upstream as a patch to