From 0b44ce834d5e8da454aa989f382b0e65b53b3d39 Mon Sep 17 00:00:00 2001
From: Robert Izzard <r.izzard@surrey.ac.uk>
Date: Fri, 8 Nov 2019 16:07:17 +0000
Subject: [PATCH] make buffered_printf now be binary_c_buffered_printf, and
 expose it to the API.

All other functions should not have been exposed in the shared library but were: now fixed by mixing the visibility flag into CFLAGS.
---
 CHANGES                                              |  4 ++++
 configure                                            |  4 ++++
 src/API/binary_c_evolve_for_dt.c                     |  2 --
 src/binary_c_code_options.h                          |  7 ++++++-
 src/binary_c_function_macros.h                       |  4 ++--
 src/binary_c_version.h                               |  2 +-
 ...{buffered_printf.c => binary_c_buffered_printf.c} | 12 +++++++++++-
 src/buffering/buffering_macros.h                     |  2 +-
 src/buffering/buffering_prototypes.h                 | 12 ++++++++----
 tbse                                                 |  4 ++--
 10 files changed, 39 insertions(+), 14 deletions(-)
 rename src/buffering/{buffered_printf.c => binary_c_buffered_printf.c} (97%)

diff --git a/CHANGES b/CHANGES
index 40ee6b5d7..5122dbcc5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -33,6 +33,10 @@ Updated API call to binary_c_free_memory with a flag that allows one to
 not free the raw_buffer and error_buffer : useful for logging and
 the python interface (note that these have to be freed by the user).
 
+buffered_printf is now binary_c_buffered_printf and is exposed in the API,
+the Printf macro has been updated to point to this. This change allows
+Perl and Python front-ends to construct Printf code.
+
 02/10/2019 V2.1.2
 
     add new "overspin_algorithm" option to handle what happens
diff --git a/configure b/configure
index 70dfa0304..e03646fc2 100755
--- a/configure
+++ b/configure
@@ -330,6 +330,10 @@ sub secondary_variables
                 $cflags .= '  -Wformat-signedness ';
             }
 
+            # make functions hidden in the shared library unless 
+            # specifically allowed access
+            $cflags .= ' -fvisibility=hidden ';
+
             # activate gcc hints
             if(defined $gcc_hints && 
                $gcc_hints &&
diff --git a/src/API/binary_c_evolve_for_dt.c b/src/API/binary_c_evolve_for_dt.c
index b0c3cbf2e..a1a50169c 100644
--- a/src/API/binary_c_evolve_for_dt.c
+++ b/src/API/binary_c_evolve_for_dt.c
@@ -16,8 +16,6 @@ int binary_c_API_function binary_c_evolve_for_dt(struct stardata_t * const stard
            stardata->model.time+dt,
            stardata->model.max_evolution_time);
     
-    //stardata = stardata;
-
     APIDebug("API call log at time %g\n",
            stardata->model.time);
 
diff --git a/src/binary_c_code_options.h b/src/binary_c_code_options.h
index 1c6dc1ba5..c49c5a3d2 100644
--- a/src/binary_c_code_options.h
+++ b/src/binary_c_code_options.h
@@ -680,6 +680,11 @@ void Print_trace(void);
  */
 #define BINARY_C_API_FORTRAN
 
+/*
+ * Hidden functions
+ */
+#define binary_c_hidden_function __attribute__ ((visibility("hidden")))
+
 /*
  * API function visibility
  */
@@ -772,7 +777,7 @@ void Print_trace(void);
 
 /*
  * Warn when the buffer is overrun.
- * buffered_printf but will truncate such strings so it 
+ * binary_c_buffered_printf but will truncate such strings so it 
  * still works but this is likely not really what you want!
  */
 #define BUFFERED_STRING_OVERRUN_WARNINGS
diff --git a/src/binary_c_function_macros.h b/src/binary_c_function_macros.h
index 6a68a0efc..7be569003 100644
--- a/src/binary_c_function_macros.h
+++ b/src/binary_c_function_macros.h
@@ -688,8 +688,8 @@
     NAME,...) NAME
 
 #define Printf_no_op(...) /* no-op */
-#define Printf_n(...) buffered_printf(stardata,FALSE,__VA_ARGS__);
-#define Printf_n_deslash(...) buffered_printf(stardata,TRUE,__VA_ARGS__);
+#define Printf_n(...) binary_c_buffered_printf(stardata,FALSE,__VA_ARGS__);
+#define Printf_n_deslash(...) binary_c_buffered_printf(stardata,TRUE,__VA_ARGS__);
 #define Printf(...)                                             \
     Get_printf_macro(                                           \
     _0, ##__VA_ARGS__,                                          \
diff --git a/src/binary_c_version.h b/src/binary_c_version.h
index c6a1c2496..f6a41650e 100644
--- a/src/binary_c_version.h
+++ b/src/binary_c_version.h
@@ -30,7 +30,7 @@
  * 
  * Patch is zero for a major release.  
  */
-#define BINARY_C_VERSION "2.1.3"
+#define BINARY_C_VERSION "2.1.4"
 
 /* and a CEMP run version */
 #define CEMP_VERSION "prelim10-O1-noCNEMPs"
diff --git a/src/buffering/buffered_printf.c b/src/buffering/binary_c_buffered_printf.c
similarity index 97%
rename from src/buffering/buffered_printf.c
rename to src/buffering/binary_c_buffered_printf.c
index 18689c06a..3d6e65ea4 100644
--- a/src/buffering/buffered_printf.c
+++ b/src/buffering/binary_c_buffered_printf.c
@@ -48,9 +48,19 @@ static void __buffered_printf_error(struct tmpstore_t * t,
  *
  * If we cannot do that, we cannot do much and it's up to you
  * to fix things. 
+ *
+ *
+ * Note: 
+ *
+ * binary_c_buffered_printf is also a binary_c_API_function because 
+ * it is exposed to the outside world through the API.
+ * 
+ * It is *also* used internally, so is always built, whether 
+ * BINARY_C_API is defined or not.
  */
 
-int Gnu_format_args(3,4) buffered_printf(
+int binary_c_API_function
+Gnu_format_args(3,4) binary_c_buffered_printf(
     struct stardata_t * RESTRICT const stardata,
     const Boolean deslash,
     const char * RESTRICT const format,
diff --git a/src/buffering/buffering_macros.h b/src/buffering/buffering_macros.h
index bb347810c..12bf6066f 100644
--- a/src/buffering/buffering_macros.h
+++ b/src/buffering/buffering_macros.h
@@ -3,7 +3,7 @@
 #define BUFFERING_MACROS_H
 
 /*
- * buffered_printf error codes
+ * binary_c_buffered_printf error codes
  */
 #define BUFFERED_PRINTF_GENERIC_ERROR 0
 #define BUFFERED_PRINTF_ASPRINTF_ERROR -1
diff --git a/src/buffering/buffering_prototypes.h b/src/buffering/buffering_prototypes.h
index 3bf4caa0f..85b95ed84 100644
--- a/src/buffering/buffering_prototypes.h
+++ b/src/buffering/buffering_prototypes.h
@@ -4,10 +4,13 @@
 
 #include "../binary_c_structures.h"
 
-int buffered_printf(struct stardata_t * RESTRICT const stardata,
-                    const Boolean deslash,
-                    const char * RESTRICT const format,
-                    ...) Gnu_format_args(3,4);
+
+int binary_c_API_function
+binary_c_buffered_printf(struct stardata_t * RESTRICT const stardata,
+                             const Boolean deslash,
+                             const char * RESTRICT const format,
+                             ...) Gnu_format_args(3,4);
+
 void buffer_info(const struct stardata_t * RESTRICT const stardata,
                  char ** const buffer,
                  size_t * const size,
@@ -28,4 +31,5 @@ void clear_printf_buffer(struct stardata_t * RESTRICT const stardata);
 void clear_error_buffer(struct stardata_t * RESTRICT const stardata);
 
 
+
 #endif // BUFFERING_PROTOTYPES_H
diff --git a/tbse b/tbse
index 63000af9f..13937aecd 100755
--- a/tbse
+++ b/tbse
@@ -167,7 +167,7 @@ RANDOM_SKIP=0
 #
 # Core mass limits
 MAX_TPAGB_CORE_MASS=1.38
-CHANDRASEKHAR_MASS=1.44
+CHANDRASEKHAR_MASS=1.3238
 
 # mass above which neutron stars collapse to black holes
 MAX_NEUTRON_STAR_MASS=1.8
@@ -1209,7 +1209,7 @@ TIMESTEP_MODULATOR=1.0
 # below).
 #
 ############################################################
-NOVA_TIMESTEP_ACCELERATOR_NUM=100 # 100
+NOVA_TIMESTEP_ACCELERATOR_NUM=0 # 100
 NOVA_TIMESTEP_ACCELERATOR_INDEX=0.5 # 0.5
 NOVA_TIMESTEP_ACCELERATOR_MAX=-1 # -1
 
-- 
GitLab