From: David Bremner <bremner@unb.ca>
Subject: [PATCH] feature/privatize-symbols
Make some symbols static so that they are not exported from static/shared libraries
Signed-off-by: David Bremner <bremner@unb.ca>
---
lrsgmp.c | 2 +-
lrsgmp.h | 5 -----
lrslib.c | 49 +++++++++++++++++++++++++++++++++++++------------
lrslib.h | 22 ----------------------
lrslong.h | 5 -----
lrsmp.h | 5 -----
6 files changed, 38 insertions(+), 50 deletions(-)
diff --git a/lrsgmp.c b/lrsgmp.c
index 3816422..691c74e 100644
--- a/lrsgmp.c
+++ b/lrsgmp.c
@@ -19,7 +19,7 @@ long digits;
long record_digits;
/* these are allocated once and used as temporary storage where needed */
-lrs_mp temp1,temp2,temp3;
+static lrs_mp temp1,temp2,temp3;
#define MAXINPUT 1000 /*max length of any input rational */
diff --git a/lrsgmp.h b/lrsgmp.h
index 32c455f..60928c8 100644
--- a/lrsgmp.h
+++ b/lrsgmp.h
@@ -120,11 +120,6 @@
#define errcheck(s,e) if ((long)(e)==-1L){ perror(s);exit(1);}
#endif
-#ifndef OMIT_TIMES
-void ptimes ();
-#endif
-
-
#define CALLOC(n,s) xcalloc(n,s,__LINE__,__FILE__)
/*************/
diff --git a/lrslib.c b/lrslib.c
index a6ba891..79d26db 100644
--- a/lrslib.c
+++ b/lrslib.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "lrslib.h"
+
/* Globals; these need to be here, rather than lrslib.h, so they are
not multiply defined. */
@@ -29,7 +30,8 @@ FILE *lrs_cfp; /* output file for checkpoint information */
FILE *lrs_ifp; /* input file pointer */
FILE *lrs_ofp; /* output file pointer */
-unsigned long dict_count, dict_limit, cache_tries, cache_misses;
+
+static unsigned long dict_count, dict_limit, cache_tries, cache_misses;
/* Variables and functions global to this file only */
static long lrs_checkpoint_seconds = 0;
@@ -39,9 +41,32 @@ static long lrs_global_count = 0; /* Track how many lrs_dat records are
static lrs_dat_p *lrs_global_list[MAX_LRS_GLOBALS + 1];
+static lrs_dic *new_lrs_dic (long m, long d, long m_A);
+
+
+static void cache_dict (lrs_dic ** D_p, lrs_dat * global, long i, long j);
+static long check_cache (lrs_dic ** D_p, lrs_dat * global, long *i_p, long *j_p);
+static void save_basis (lrs_dic * D, lrs_dat * Q);
static void lrs_dump_state ();
+static void pushQ (lrs_dat * global, long m, long d, long m_A);
+
+#ifdef TIMES
+static void ptimes ();
+static double get_time();
+#endif
+
+
+/*******************************/
+/* signals handling */
+/*******************************/
+#ifdef SIGNALS
+static void checkpoint ();
+static void die_gracefully ();
+static void setup_signals ();
+static void timecheck ();
+#endif
/*******************************/
/* functions for external use */
@@ -3743,7 +3768,7 @@ pimat (lrs_dic * P, long r, long s, lrs_mp Nt, char name[])
/* From here mostly Bremner's handiwork */
-void
+static void
cache_dict (lrs_dic ** D_p, lrs_dat * global, long i, long j)
{
@@ -3829,7 +3854,7 @@ copy_dict (lrs_dat * global, lrs_dic * dest, lrs_dic * src)
#define TRACE(s)
#endif
-void
+static void
pushQ (lrs_dat * global, long m, long d ,long m_A)
{
@@ -3921,7 +3946,7 @@ lrs_dic *p;
#define NULLRETURN(e) if (!(e)) return NULL;
-lrs_dic *
+static lrs_dic *
new_lrs_dic (long m, long d, long m_A)
{
lrs_dic *p;
@@ -4023,7 +4048,7 @@ lrs_free_dat ( lrs_dat *Q )
}
-long
+static long
check_cache (lrs_dic ** D_p, lrs_dat * global, long *i_p, long *j_p)
{
/* assign local variables to structures */
@@ -4174,7 +4199,7 @@ lrs_alloc_dic (lrs_dat * Q)
It is also used to make sure that in case of overflow, we
have a valid cobasis to restart from.
*/
-void
+static void
save_basis (lrs_dic * P, lrs_dat * Q)
{
int i;
@@ -4283,7 +4308,7 @@ print_basis (FILE * fp, lrs_dat * global)
INT (ctrl-C) ditto
HUP ditto
*/
-void
+static void
setup_signals ()
{
errcheck ("signal", signal (SIGTERM, die_gracefully));
@@ -4293,7 +4318,7 @@ setup_signals ()
errcheck ("signal", signal (SIGUSR1, checkpoint));
}
-void
+static void
timecheck ()
{
lrs_dump_state ();
@@ -4301,14 +4326,14 @@ timecheck ()
alarm (lrs_checkpoint_seconds);
}
-void
+static void
checkpoint ()
{
lrs_dump_state ();
errcheck ("signal", signal (SIGUSR1, checkpoint));
}
-void
+static void
die_gracefully ()
{
lrs_dump_state ();
@@ -4326,7 +4351,7 @@ die_gracefully ()
#include <sys/resource.h>
#define double_time(t) ((double)(t.tv_sec)+(double)(t.tv_usec)/1000000)
-void
+static void
ptimes ()
{
struct rusage rusage;
@@ -4339,7 +4364,7 @@ ptimes ()
}
-double get_time()
+static double get_time()
{
struct rusage rusage;
getrusage (RUSAGE_SELF, &rusage);
diff --git a/lrslib.h b/lrslib.h
index c46b681..52a2bea 100644
--- a/lrslib.h
+++ b/lrslib.h
@@ -43,12 +43,6 @@
#define errcheck(s,e) if ((long)(e)==-1L){ perror(s);exit(1);}
#endif
-#ifdef TIMES
-void ptimes ();
-double get_time();
-#endif
-
-
#define CALLOC(n,s) xcalloc(n,s,__LINE__,__FILE__)
/* make this include file includable in a C++ file
@@ -208,7 +202,6 @@ lrs_dat, lrs_dat_p;
extern FILE *lrs_cfp; /* output file for checkpoint information */
-extern unsigned long dict_count, dict_limit, cache_tries, cache_misses;
extern lrs_dic *PBnew; /* we will save Bob's dictionary in getabasis */
@@ -314,27 +307,12 @@ long checkindex (lrs_dic * P, lrs_dat * Q, long index); /* index=0 non-red.,1 r
void lrs_free_dic ( lrs_dic *P, lrs_dat *Q);
void lrs_free_dat ( lrs_dat *Q);
-void cache_dict (lrs_dic ** D_p, lrs_dat * global, long i, long j);
-long check_cache (lrs_dic ** D_p, lrs_dat * global, long *i_p, long *j_p);
void copy_dict (lrs_dat * global, lrs_dic * dest, lrs_dic * src);
-void pushQ (lrs_dat * global, long m, long d, long m_A);
-void save_basis (lrs_dic * D, lrs_dat * Q);
lrs_dic *alloc_memory (lrs_dat * Q);
lrs_dic * lrs_getdic(lrs_dat *Q);
-lrs_dic *new_lrs_dic (long m, long d, long m_A);
lrs_dic *resize (lrs_dic * P, lrs_dat * Q);
-
-/*******************************/
-/* signals handling */
-/*******************************/
-
-void checkpoint ();
-void die_gracefully ();
-void setup_signals ();
-void timecheck ();
-
/*******************************/
/* utilities */
/*******************************/
diff --git a/lrslong.h b/lrslong.h
index af16731..53c598a 100644
--- a/lrslong.h
+++ b/lrslong.h
@@ -126,11 +126,6 @@
#define errcheck(s,e) if ((long)(e)==-1L){ perror(s);exit(1);}
#endif
-#ifndef OMIT_TIMES
-void ptimes ();
-#endif
-
-
#define CALLOC(n,s) xcalloc(n,s,__LINE__,__FILE__)
/*************/
diff --git a/lrsmp.h b/lrsmp.h
index 14b79ef..eccf3f5 100644
--- a/lrsmp.h
+++ b/lrsmp.h
@@ -119,11 +119,6 @@
#define errcheck(s,e) if ((long)(e)==-1L){ perror(s);exit(1);}
#endif
-#ifdef TIMES
-void ptimes ();
-#endif
-
-
#define CALLOC(n,s) xcalloc(n,s,__LINE__,__FILE__)
/*************/
--
tg: (9210b3a..) feature/privatize-symbols (depends on: upstream)