summaryrefslogtreecommitdiff
path: root/gmp-impl.h
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-09-18 00:11:33 +0200
committerKevin Ryde <user42@zip.com.au>2002-09-18 00:11:33 +0200
commit4d1cd678a96a0c9752a41126673436461cf47916 (patch)
treeaf487d5f9f97abe1b7efdf35c65160bf2d6ae811 /gmp-impl.h
parent4a09c296fce69d9582f467621cb9c3c6de0874e7 (diff)
downloadgmp-4d1cd678a96a0c9752a41126673436461cf47916.tar.gz
2002-09-18 Pedro Gimeno <pggimeno@wanadoo.es>
* gmp-impl.h (RNG_FNPTR, RNG_STATE): New macros. (gmp_randfnptr_t): New structure. (_gmp_rand): Now a macro not a function.
Diffstat (limited to 'gmp-impl.h')
-rw-r--r--gmp-impl.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/gmp-impl.h b/gmp-impl.h
index 1b7fb4b20..94101d00d 100644
--- a/gmp-impl.h
+++ b/gmp-impl.h
@@ -697,8 +697,22 @@ __GMP_DECLSPEC mp_limb_t mpn_submul_1c __GMP_PROTO ((mp_ptr, mp_srcptr, mp_size_
typedef __gmp_randstate_struct *gmp_randstate_ptr;
-#define _gmp_rand __gmp_rand
-__GMP_DECLSPEC void _gmp_rand _PROTO ((mp_ptr, gmp_randstate_t, unsigned long int));
+/* Pseudo-random number generator function pointers structure. */
+typedef struct {
+ int (*randseed_fn) (gmp_randstate_t rstate, mpz_srcptr seed);
+ void (*randget_fn) (gmp_randstate_t rstate, mp_ptr dest, unsigned long int nbits);
+ void (*randclear_fn) (gmp_randstate_t rstate);
+} gmp_randfnptr_t;
+
+/* Macro to obtain a pointer to the function pointers structure. */
+#define RNG_FNPTR(rstate) ((gmp_randfnptr_t *)((rstate)->_mp_algdata._mp_lc))
+
+/* Macro to obtain a void pointer to the generator's state */
+#define RNG_STATE(rstate) ((void *)((rstate)->_mp_seed->_mp_d))
+
+/* _gmp_rand function (as macro.) */
+#define _gmp_rand(rp, state, bits) \
+ (*RNG_FNPTR (state)->randget_fn) (state, rp, bits)
/* __gmp_rands is the global state for the old-style random functions, and