From c15b9d3718635cf8bb075df726dcff98946b80a6 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Wed, 11 Dec 2019 17:34:00 +0000
Subject: [PATCH] reverse the logic of FPU control : it now defaults to failing
 (e.g. on a Mac)

---
 meson.build                    | 5 +++--
 src/binary_c_function_macros.h | 2 +-
 src/binary_c_main.h            | 4 +++-
 src/setup/version.c            | 2 +-
 4 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/meson.build b/meson.build
index fcd71a471..7e676a23e 100644
--- a/meson.build
+++ b/meson.build
@@ -364,7 +364,8 @@ endif
 ############################################################
 # check for FPU precision control
 #
-if compiler.compiles('''
+if compiler.has_header('fpu_control.h') and \
+   compiler.compiles('''
 #include <fpu_control.h>
 int main(int argc,char **argv)
 {
@@ -382,8 +383,8 @@ return 0;
 	             args : '-lm',	
 		     name : 'FPU control check')  
     message('Enabled FPU control on this CPU')
+    cflags += '-DFPU_CONTROL'
 else
-    cflags += '-DNO_FPU_CONTROL'
     message('Disabled FPU control on this CPU')
 endif
 
diff --git a/src/binary_c_function_macros.h b/src/binary_c_function_macros.h
index c27f8453c..3aace9acb 100644
--- a/src/binary_c_function_macros.h
+++ b/src/binary_c_function_macros.h
@@ -34,7 +34,7 @@
  * http://christian-seiler.de/projekte/fpmath/
  */
 #if defined FPU_PRECISION && \
-    !defined NO_FPU_CONTROL && \
+    defined FPU_CONTROL && \
     defined _FPU_EXTENDED
     
 #define Set_FPU_precision fpu_control_t fpu_oldcw,fpu_cw;       \
diff --git a/src/binary_c_main.h b/src/binary_c_main.h
index 40180cb0b..f82ff8c2d 100644
--- a/src/binary_c_main.h
+++ b/src/binary_c_main.h
@@ -24,9 +24,11 @@
 
 
 #include "binary_c.h"
-#ifdef FPU_PRECISION
+
+#if defined FPU_PRECISION && defined FPU_CONTROL 
 #include <fpu_control.h>
 #endif//FPU_PRECISION
+
 #include "binary_c_main_prototypes.h"
 #include "binary_c_main_macros.h"
 #ifdef STACK_SIZE
diff --git a/src/setup/version.c b/src/setup/version.c
index 04b0615e5..8190b2571 100644
--- a/src/setup/version.c
+++ b/src/setup/version.c
@@ -183,7 +183,7 @@ void version(struct stardata_t * RESTRICT const stardata)
     Macrotest(FPU_CAPTURE_UNDERFLOWS);
     Macrotest(FPU_CAPTURE_OVERFLOWS);
     Macrotest(FPU_CAPTURE_DIVIDE_BY_ZERO);
-    Macrotest(NO_FPU_CONTROL);
+    Macrotest(FPU_CONTROL);
     Macrotest(CHECK_ISNAN_WORKS);
     
     Show_float_macro(ZERO);
-- 
GitLab