[PATCH 16/20] Convert the toplevel directory to __GMP_*_DEFINE and include changes

Richard Henderson rth at twiddle.net
Mon Mar 4 19:41:46 CET 2013


---
 assert.c       |  5 ++---
 compat.c       |  2 --
 errno.c        |  7 +++++--
 extract-dbl.c  |  2 +-
 gen-bases.c    |  2 +-
 gen-fib.c      |  2 +-
 gen-rename.c   | 10 ++--------
 gen-renamei.c  |  6 ------
 invalid.c      | 18 ++++++------------
 memory.c       |  7 +++----
 mp_bpl.c       |  2 ++
 mp_dv_tab.c    |  2 +-
 mp_get_fns.c   |  3 +--
 mp_minv_tab.c  |  2 +-
 mp_set_fns.c   |  2 +-
 nextprime.c    |  4 ++--
 primesieve.c   |  3 ++-
 tal-debug.c    |  7 +++----
 tal-notreent.c |  4 +++-
 tal-reent.c    |  4 ++--
 version.c      |  2 +-
 21 files changed, 40 insertions(+), 56 deletions(-)

diff --git a/assert.c b/assert.c
index b9b5559..62379aa 100644
--- a/assert.c
+++ b/assert.c
@@ -21,9 +21,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -37,6 +34,7 @@ __gmp_assert_header (const char *filename, int linenum)
         fprintf (stderr, "%d: ", linenum);
     }
 }
+__GMP_INTERN_DEFINE (__gmp_assert_header)
 
 void
 __gmp_assert_fail (const char *filename, int linenum,
@@ -46,3 +44,4 @@ __gmp_assert_fail (const char *filename, int linenum,
   fprintf (stderr, "GNU MP assertion failed: %s\n", expr);
   abort();
 }
+__GMP_INTERN_DEFINE (__gmp_assert_fail)
diff --git a/compat.c b/compat.c
index 7251bef..518045a 100644
--- a/compat.c
+++ b/compat.c
@@ -17,8 +17,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
diff --git a/errno.c b/errno.c
index e5e160d..84e130c 100644
--- a/errno.c
+++ b/errno.c
@@ -21,11 +21,10 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdlib.h>
-#include "gmp.h"
 #include "gmp-impl.h"
 
 int gmp_errno = 0;
+__GMP_PUBLIC_DEFINE (gmp_errno)
 
 
 /* The deliberate divide by zero triggers an exception on most systems.  On
@@ -42,6 +41,7 @@ __gmp_exception (int error_bit)
   __gmp_junk = 10 / __gmp_0;
   abort ();
 }
+__GMP_INTERN_DEFINE(__gmp_exception)
 
 
 /* These functions minimize the amount of code required in functions raising
@@ -52,8 +52,11 @@ __gmp_sqrt_of_negative (void)
 {
   __gmp_exception (GMP_ERROR_SQRT_OF_NEGATIVE);
 }
+__GMP_INTERN_DEFINE (__gmp_sqrt_of_negative)
+
 void
 __gmp_divide_by_zero (void)
 {
   __gmp_exception (GMP_ERROR_DIVISION_BY_ZERO);
 }
+__GMP_INTERN_DEFINE (__gmp_divide_by_zero)
diff --git a/extract-dbl.c b/extract-dbl.c
index f81789a..5bb92e5 100644
--- a/extract-dbl.c
+++ b/extract-dbl.c
@@ -18,7 +18,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 #ifdef XDEBUG
@@ -299,3 +298,4 @@ __gmp_extract_double (mp_ptr rp, double d)
 
   return exp;
 }
+__GMP_INTERN_DEFINE (__gmp_extract_double)
diff --git a/gen-bases.c b/gen-bases.c
index 60cbd3f..947df12 100644
--- a/gen-bases.c
+++ b/gen-bases.c
@@ -150,7 +150,6 @@ table (int limb_bits, int nail_bits)
 
   printf ("/* This file generated by gen-bases.c - DO NOT EDIT. */\n");
   printf ("\n");
-  printf ("#include \"gmp.h\"\n");
   printf ("#include \"gmp-impl.h\"\n");
   printf ("\n");
   printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
@@ -191,6 +190,7 @@ table (int limb_bits, int nail_bits)
     }
 
   puts ("};");
+  puts ("__GMP_INTERN_DEFINE (mp_bases)");
 
   mpz_clear (r);
   mpz_clear (t);
diff --git a/gen-fib.c b/gen-fib.c
index b6c7745..b2b6858 100644
--- a/gen-fib.c
+++ b/gen-fib.c
@@ -86,7 +86,6 @@ table (int numb_bits)
 
   printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n");
   printf ("\n");
-  printf ("#include \"gmp.h\"\n");
   printf ("#include \"gmp-impl.h\"\n");
   printf ("\n");
   printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
@@ -103,6 +102,7 @@ table (int numb_bits)
       printf ("),  /* %d */\n", i-1);
     }
   printf ("};\n");
+  printf ("__GMP_INTERN_DEFINE (__gmp_fib_table)\n");
 }
 
 int
diff --git a/gen-rename.c b/gen-rename.c
index a4fd854..ccc4d22 100644
--- a/gen-rename.c
+++ b/gen-rename.c
@@ -16,17 +16,11 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "config.h"
-#include <stdio.h>
-#include <stdarg.h>
-#ifdef HAVE_OBSTACK_VPRINTF
-# include <obstack.h>
-#endif
-
 #define __GMP_WITHIN_CONFIGURE
+
 #define __GMP_PUBLIC_FULL(TYPE, API_NAME, ARGS, NT, ATTRS, ABI_NAME) \
   __GMP_XYZZY API_NAME ABI_NAME
 #define __GMP_PUBLIC_ALIAS_FULL(NEW_NAME, OLD_NAME, ABI_NAME) \
   __GMP_XYZZY NEW_NAME ABI_NAME
 
-#include "gmp.h"
+#include "gmp-impl.h"
diff --git a/gen-renamei.c b/gen-renamei.c
index 77356c6..bf86f75 100644
--- a/gen-renamei.c
+++ b/gen-renamei.c
@@ -16,11 +16,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "config.h"
-#include <stdio.h>
-#include <stdarg.h>
-#include <obstack.h>
-
 #define __GMP_WITHIN_CONFIGURE
 
 /* For GCC, we need to remember the ABI name we associated with a symbol.  */
@@ -34,6 +29,5 @@ along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
    __GMP_XYZZY API_NAME ABI_NAME
 #endif
 
-#include "gmp.h"
 #include "gmp-impl.h"
 #include "rand/randmt.h"
diff --git a/invalid.c b/invalid.c
index 24c6f13..91017c3 100644
--- a/invalid.c
+++ b/invalid.c
@@ -21,23 +21,16 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "config.h"
-
-#include <signal.h>
-#include <stdlib.h>
-
-#if HAVE_UNISTD_H
-#include <unistd.h>  /* for getpid */
-#endif
-
-#include "gmp.h"
 #include "gmp-impl.h"
-
+#include <signal.h>
 
 /* Incidentally, kill is not available on mingw, but that's ok, it has raise
    and we'll be using that.  */
 #if ! HAVE_RAISE
-#define raise(sig)   kill (getpid(), sig)
+# if HAVE_UNISTD_H
+#  include <unistd.h>  /* for getpid */
+# endif
+# define raise(sig)   kill (getpid(), sig)
 #endif
 
 
@@ -70,3 +63,4 @@ __gmp_invalid_operation (void)
   raise (SIGFPE);
   abort ();
 }
+__GMP_INTERN_DEFINE (__gmp_invalid_operation)
diff --git a/memory.c b/memory.c
index b9e858d..6fb85a9 100644
--- a/memory.c
+++ b/memory.c
@@ -18,10 +18,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>
-#include <stdlib.h> /* for malloc, realloc, free */
-
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -60,6 +56,7 @@ __gmp_default_allocate (size_t size)
 #endif
   return ret;
 }
+__GMP_INTERN_DEFINE (__gmp_default_allocate)
 
 void *
 __gmp_default_reallocate (void *oldptr, size_t old_size, size_t new_size)
@@ -108,6 +105,7 @@ __gmp_default_reallocate (void *oldptr, size_t old_size, size_t new_size)
 #endif
   return ret;
 }
+__GMP_INTERN_DEFINE (__gmp_default_reallocate)
 
 void
 __gmp_default_free (void *blk_ptr, size_t blk_size)
@@ -134,3 +132,4 @@ __gmp_default_free (void *blk_ptr, size_t blk_size)
 #endif
   free (blk_ptr);
 }
+__GMP_INTERN_DEFINE (__gmp_default_free)
diff --git a/mp_bpl.c b/mp_bpl.c
index 1fc1ca9..1b703e0 100644
--- a/mp_bpl.c
+++ b/mp_bpl.c
@@ -20,5 +20,7 @@ along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 #include "gmp-impl.h"
 
 const int mp_bits_per_limb = GMP_LIMB_BITS;
+__GMP_PUBLIC_DEFINE (mp_bits_per_limb)
+
 const int __gmp_0 = 0;
 int __gmp_junk;
diff --git a/mp_dv_tab.c b/mp_dv_tab.c
index 85487c2..2a70669 100644
--- a/mp_dv_tab.c
+++ b/mp_dv_tab.c
@@ -20,7 +20,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 /* Table to be indexed by character, to get its numerical value.  Assumes ASCII
@@ -65,3 +64,4 @@ const unsigned char __gmp_digit_value_tab[] =
   X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X,
   X, X, X, X, X, X, X, X, X, X, X, X, X, X, X, X
 };
+__GMP_INTERN_DEFINE (__gmp_digit_value_tab)
diff --git a/mp_get_fns.c b/mp_get_fns.c
index 8d7c69f..460b344 100644
--- a/mp_get_fns.c
+++ b/mp_get_fns.c
@@ -17,8 +17,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>  /* for NULL */
-#include "gmp.h"
 #include "gmp-impl.h"
 
 void
@@ -35,3 +33,4 @@ mp_get_memory_functions (void *(**alloc_func) (size_t),
   if (free_func != NULL)
     *free_func = __gmp_free_func;
 }
+__GMP_PUBLIC_DEFINE (mp_get_memory_functions)
diff --git a/mp_minv_tab.c b/mp_minv_tab.c
index a7f342b..4f92e41 100644
--- a/mp_minv_tab.c
+++ b/mp_minv_tab.c
@@ -21,7 +21,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -46,3 +45,4 @@ const unsigned char  binvert_limb_table[128] = {
   0x21, 0xCB, 0xED, 0xD7, 0x59, 0xC3, 0xE5, 0x0F,
   0x11, 0x3B, 0x5D, 0xC7, 0x49, 0x33, 0x55, 0xFF
 };
+__GMP_INTERN_DEFINE (binvert_limb_table)
diff --git a/mp_set_fns.c b/mp_set_fns.c
index 3d2aaf3..8f125f7 100644
--- a/mp_set_fns.c
+++ b/mp_set_fns.c
@@ -18,7 +18,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 void
@@ -37,3 +36,4 @@ mp_set_memory_functions (void *(*alloc_func) (size_t),
   __gmp_reallocate_func = realloc_func;
   __gmp_free_func = free_func;
 }
+__GMP_PUBLIC_DEFINE (mp_set_memory_functions)
diff --git a/nextprime.c b/nextprime.c
index f0b01d6..1cd0396 100644
--- a/nextprime.c
+++ b/nextprime.c
@@ -41,9 +41,7 @@ along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
      division.
 */
 
-#include "gmp.h"
 #include "gmp-impl.h"
-#include <string.h>		/* for memset */
 
 
 unsigned long int
@@ -145,6 +143,7 @@ gmp_nextprime (gmp_primesieve_t *ps)
   ps->d = 0;
   return gmp_nextprime (ps);
 }
+__GMP_INTERN_DEFINE (gmp_nextprime)
 
 void
 gmp_init_primesieve (gmp_primesieve_t *ps)
@@ -154,3 +153,4 @@ gmp_init_primesieve (gmp_primesieve_t *ps)
   ps->d = SIEVESIZE;
   ps->s[SIEVESIZE] = 0;		/* sentinel */
 }
+__GMP_INTERN_DEFINE (gmp_init_primesieve)
diff --git a/primesieve.c b/primesieve.c
index d1bf5a1..aeb8788 100644
--- a/primesieve.c
+++ b/primesieve.c
@@ -24,7 +24,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 /**************************************************************/
@@ -282,3 +281,5 @@ gmp_primesieve (mp_ptr bit_array, mp_limb_t n)
 #undef LOOP_ON_SIEVE_STOP
 #undef LOOP_ON_SIEVE_BEGIN
 #undef LOOP_ON_SIEVE_CONTINUE
+
+__GMP_INTERN_DEFINE (gmp_primesieve)
diff --git a/tal-debug.c b/tal-debug.c
index 7e0917f..3ba19a4 100644
--- a/tal-debug.c
+++ b/tal-debug.c
@@ -17,10 +17,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -77,6 +73,7 @@ __gmp_tmp_debug_mark (const char *file, int line,
   mark->line = line;
   mark->list = NULL;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_debug_mark)
 
 void *
 __gmp_tmp_debug_alloc (const char *file, int line, int dummy,
@@ -102,6 +99,7 @@ __gmp_tmp_debug_alloc (const char *file, int line, int dummy,
   mark->list = p;
   return p->block;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_debug_alloc)
 
 void
 __gmp_tmp_debug_free (const char *file, int line, int dummy,
@@ -138,3 +136,4 @@ __gmp_tmp_debug_free (const char *file, int line, int dummy,
 
   *markp = NULL;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_debug_free)
diff --git a/tal-notreent.c b/tal-notreent.c
index 662d4ea..4c0c324 100644
--- a/tal-notreent.c
+++ b/tal-notreent.c
@@ -18,7 +18,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -91,6 +90,7 @@ __gmp_tmp_alloc (unsigned long size)
   ASSERT (((unsigned) that % __TMP_ALIGN) == 0);
   return that;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_alloc)
 
 /* Typically called at function entry.  <mark> is assigned so that
    __gmp_tmp_free can later be used to reclaim all subsequently allocated
@@ -101,6 +101,7 @@ __gmp_tmp_mark (struct tmp_marker *mark)
   mark->which_chunk = current;
   mark->alloc_point = current->alloc_point;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_mark)
 
 /* Free everything allocated since <mark> was assigned by __gmp_tmp_mark */
 void
@@ -117,3 +118,4 @@ __gmp_tmp_free (struct tmp_marker *mark)
     }
   current->alloc_point = mark->alloc_point;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_free)
diff --git a/tal-reent.c b/tal-reent.c
index 87da7f3..a197628 100644
--- a/tal-reent.c
+++ b/tal-reent.c
@@ -17,8 +17,6 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include <stdio.h>
-#include "gmp.h"
 #include "gmp-impl.h"
 
 
@@ -56,6 +54,7 @@ __gmp_tmp_reentrant_alloc (struct tmp_reentrant_t **markp, size_t size)
   *markp = P;
   return p + HSIZ;
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_reentrant_alloc)
 
 void
 __gmp_tmp_reentrant_free (struct tmp_reentrant_t *mark)
@@ -69,3 +68,4 @@ __gmp_tmp_reentrant_free (struct tmp_reentrant_t *mark)
       mark = next;
     }
 }
+__GMP_INTERN_DEFINE (__gmp_tmp_reentrant_free)
diff --git a/version.c b/version.c
index da16b77..a6ee4f7 100644
--- a/version.c
+++ b/version.c
@@ -17,7 +17,7 @@ License for more details.
 You should have received a copy of the GNU Lesser General Public License
 along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.  */
 
-#include "gmp.h"
 #include "gmp-impl.h"
 
 const char * const gmp_version = VERSION;
+__GMP_PUBLIC_DEFINE (gmp_version)
-- 
1.8.1.2



More information about the gmp-devel mailing list