[PATCH 14/20] Convert the rand subdirectory to __GMP_*_DEFINE and include changes
Richard Henderson
rth at twiddle.net
Mon Mar 4 19:41:44 CET 2013
---
gen-renamei.c | 1 +
rand/rand.c | 12 +-----------
rand/randbui.c | 2 +-
rand/randclr.c | 2 +-
rand/randdef.c | 2 +-
rand/randiset.c | 2 +-
rand/randlc2s.c | 3 +--
rand/randlc2x.c | 2 +-
rand/randmt.c | 10 +++++-----
rand/randmt.h | 14 +++++++++-----
rand/randmts.c | 2 +-
rand/randmui.c | 3 +--
rand/rands.c | 3 +--
rand/randsd.c | 2 +-
rand/randsdui.c | 2 +-
15 files changed, 27 insertions(+), 35 deletions(-)
diff --git a/gen-renamei.c b/gen-renamei.c
index 6dd12d7..77356c6 100644
--- a/gen-renamei.c
+++ b/gen-renamei.c
@@ -36,3 +36,4 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include "gmp.h"
#include "gmp-impl.h"
+#include "rand/randmt.h"
diff --git a/rand/rand.c b/rand/rand.c
index 31969b2..368c832 100644
--- a/rand/rand.c
+++ b/rand/rand.c
@@ -17,17 +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 "config.h"
-
-#include <stdio.h> /* for NULL */
-
-#if HAVE_STDARG
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
-#include "gmp.h"
#include "gmp-impl.h"
void
@@ -62,3 +51,4 @@ gmp_randinit (va_alist)
}
va_end (ap);
}
+__GMP_PUBLIC_DEFINE (gmp_randinit)
diff --git a/rand/randbui.c b/rand/randbui.c
index 5fc49b2..c26867b 100644
--- a/rand/randbui.c
+++ b/rand/randbui.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
@@ -44,3 +43,4 @@ gmp_urandomb_ui (gmp_randstate_ptr rstate, unsigned long bits)
return a[0] | (a[1] << GMP_NUMB_BITS);
#endif
}
+__GMP_PUBLIC_DEFINE (gmp_urandomb_ui)
diff --git a/rand/randclr.c b/rand/randclr.c
index a4e8242..e34fdd2 100644
--- a/rand/randclr.c
+++ b/rand/randclr.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
void
@@ -25,3 +24,4 @@ gmp_randclear (gmp_randstate_t rstate)
{
(*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randclear_fn) (rstate);
}
+__GMP_PUBLIC_DEFINE (gmp_randclear)
diff --git a/rand/randdef.c b/rand/randdef.c
index 171a0bd..d5e3a9f 100644
--- a/rand/randdef.c
+++ b/rand/randdef.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
void
@@ -25,3 +24,4 @@ gmp_randinit_default (gmp_randstate_t rstate)
{
gmp_randinit_mt (rstate);
}
+__GMP_PUBLIC_DEFINE (gmp_randinit_default)
diff --git a/rand/randiset.c b/rand/randiset.c
index f140a33..a4ebd35 100644
--- a/rand/randiset.c
+++ b/rand/randiset.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
@@ -26,3 +25,4 @@ gmp_randinit_set (gmp_randstate_ptr dst, gmp_randstate_srcptr src)
{
(*((gmp_randfnptr_t *) RNG_FNPTR (src))->randiset_fn) (dst, src);
}
+__GMP_PUBLIC_DEFINE (gmp_randinit_set)
diff --git a/rand/randlc2s.c b/rand/randlc2s.c
index 4dcde73..e31f214 100644
--- a/rand/randlc2s.c
+++ b/rand/randlc2s.c
@@ -18,8 +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> /* for NULL */
-#include "gmp.h"
#include "gmp-impl.h"
@@ -80,3 +78,4 @@ gmp_randinit_lc_2exp_size (gmp_randstate_t rstate, mp_bitcnt_t size)
mpz_clear (a);
return 1;
}
+__GMP_PUBLIC_DEFINE (gmp_randinit_lc_2exp_size)
diff --git a/rand/randlc2x.c b/rand/randlc2x.c
index de89a78..b7cc872 100644
--- a/rand/randlc2x.c
+++ b/rand/randlc2x.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
@@ -320,3 +319,4 @@ gmp_randinit_lc_2exp (gmp_randstate_t rstate,
p->_mp_m2exp = m2exp;
}
+__GMP_PUBLIC_DEFINE (gmp_randinit_lc_2exp)
diff --git a/rand/randmt.c b/rand/randmt.c
index 3137bb5..725084e 100644
--- a/rand/randmt.c
+++ b/rand/randmt.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> /* for NULL */
-
-#include "gmp.h"
#include "gmp-impl.h"
#include "randmt.h"
@@ -175,6 +172,7 @@ __gmp_mt_recalc_buffer (gmp_uint_least32_t mt[])
y = (mt[N - 1] & 0x80000000) | (mt[0] & 0x7FFFFFFF);
mt[N - 1] = mt[M - 1] ^ (y >> 1) ^ ((y & 0x01) != 0 ? MATRIX_A : 0);
}
+__GMP_INTERN_DEFINE (__gmp_mt_recalc_buffer)
/* Get nbits bits of output from the generator into dest.
@@ -342,6 +340,7 @@ __gmp_randget_mt (gmp_randstate_t rstate, mp_ptr dest, unsigned long int nbits)
#endif /* GMP_NUMB_BITS != 64 */
#endif /* GMP_NUMB_BITS != 32 */
}
+__GMP_INTERN_DEFINE (__gmp_randget_mt)
void
__gmp_randclear_mt (gmp_randstate_t rstate)
@@ -349,8 +348,7 @@ __gmp_randclear_mt (gmp_randstate_t rstate)
(*__gmp_free_func) ((void *) RNG_STATE (rstate),
ALLOC (rstate->_mp_seed) * BYTES_PER_MP_LIMB);
}
-
-void __gmp_randiset_mt (gmp_randstate_ptr, gmp_randstate_srcptr);
+__GMP_INTERN_DEFINE (__gmp_randclear_mt)
static const gmp_randfnptr_t Mersenne_Twister_Generator_Noseed = {
NULL,
@@ -381,6 +379,7 @@ __gmp_randiset_mt (gmp_randstate_ptr dst, gmp_randstate_srcptr src)
dstp->mti = srcp->mti;
}
+__GMP_INTERN_DEFINE (__gmp_randiset_mt)
void
__gmp_randinit_mt_noseed (gmp_randstate_ptr dst)
@@ -403,3 +402,4 @@ __gmp_randinit_mt_noseed (gmp_randstate_ptr dst)
dstp->mti = WARM_UP % N;
}
+__GMP_INTERN_DEFINE (__gmp_randinit_mt_noseed)
diff --git a/rand/randmt.h b/rand/randmt.h
index 2f26956..64b4529 100644
--- a/rand/randmt.h
+++ b/rand/randmt.h
@@ -33,8 +33,12 @@ typedef struct
int mti; /* Index of current value. */
} gmp_rand_mt_struct;
-
-void __gmp_mt_recalc_buffer (gmp_uint_least32_t *);
-void __gmp_randget_mt (gmp_randstate_t, mp_ptr, unsigned long int);
-void __gmp_randclear_mt (gmp_randstate_t);
-void __gmp_randiset_mt (gmp_randstate_ptr, gmp_randstate_srcptr);
+#undef __GMP_ABI_PREFIX
+#define __GMP_ABI_PREFIX
+
+__GMP_INTERN (void, __gmp_mt_recalc_buffer, (gmp_uint_least32_t *));
+__GMP_INTERN (void, __gmp_randget_mt,
+ (gmp_randstate_t, mp_ptr, unsigned long int));
+__GMP_INTERN (void, __gmp_randclear_mt, (gmp_randstate_t));
+__GMP_INTERN (void, __gmp_randiset_mt,
+ (gmp_randstate_ptr, gmp_randstate_srcptr));
diff --git a/rand/randmts.c b/rand/randmts.c
index 55fdfa1..8ba1f8e 100644
--- a/rand/randmts.c
+++ b/rand/randmts.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
#include "randmt.h"
@@ -152,3 +151,4 @@ gmp_randinit_mt (gmp_randstate_t rstate)
__gmp_randinit_mt_noseed (rstate);
RNG_FNPTR (rstate) = (void *) &Mersenne_Twister_Generator;
}
+__GMP_PUBLIC_DEFINE (gmp_randinit_mt)
diff --git a/rand/randmui.c b/rand/randmui.c
index f349d35..e4b01bc 100644
--- a/rand/randmui.c
+++ b/rand/randmui.c
@@ -17,9 +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"
-#include "longlong.h"
/* If n is a power of 2 then the test ret<n is always true and the loop is
@@ -73,3 +71,4 @@ gmp_urandomm_ui (gmp_randstate_ptr rstate, unsigned long n)
done:
return ret;
}
+__GMP_PUBLIC_DEFINE (gmp_urandomm_ui)
diff --git a/rand/rands.c b/rand/rands.c
index 93eb3e7..b2fe1c5 100644
--- a/rand/rands.c
+++ b/rand/rands.c
@@ -22,10 +22,9 @@ 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"
/* Use this via the RANDS macro in gmp-impl.h */
-char __gmp_rands_initialized = 0;
+char __gmp_rands_initialized;
gmp_randstate_t __gmp_rands;
diff --git a/rand/randsd.c b/rand/randsd.c
index 077382e..fca3fc1 100644
--- a/rand/randsd.c
+++ b/rand/randsd.c
@@ -17,7 +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 "gmp.h"
#include "gmp-impl.h"
void
@@ -26,3 +25,4 @@ gmp_randseed (gmp_randstate_t rstate,
{
(*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randseed_fn) (rstate, seed);
}
+__GMP_PUBLIC_DEFINE (gmp_randseed)
diff --git a/rand/randsdui.c b/rand/randsdui.c
index 9039eda..46af538 100644
--- a/rand/randsdui.c
+++ b/rand/randsdui.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
@@ -31,3 +30,4 @@ gmp_randseed_ui (gmp_randstate_t rstate,
MPZ_FAKE_UI (zseed, zlimbs, seed);
gmp_randseed (rstate, zseed);
}
+__GMP_PUBLIC_DEFINE (gmp_randseed_ui)
--
1.8.1.2
More information about the gmp-devel
mailing list