[Gmp-commit] /home/hgfiles/gmp: Move global random file to new 'rand' subdire...

mercurial at gmplib.org mercurial at gmplib.org
Thu Nov 11 09:56:45 CET 2010


details:   /home/hgfiles/gmp/rev/b9fe39699810
changeset: 13683:b9fe39699810
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Thu Nov 11 09:56:42 2010 +0100
description:
Move global random file to new 'rand' subdirectory.

diffstat:

 ChangeLog        |    8 +
 Makefile.am      |   16 +-
 configure.in     |    2 +-
 rand.c           |   64 --------
 rand/Makefile.am |   27 +++
 rand/rand.c      |   64 ++++++++
 rand/randbui.c   |   46 ++++++
 rand/randclr.c   |   27 +++
 rand/randdef.c   |   27 +++
 rand/randiset.c  |   28 +++
 rand/randlc2s.c  |   82 +++++++++++
 rand/randlc2x.c  |  322 +++++++++++++++++++++++++++++++++++++++++++
 rand/randmt.c    |  405 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 rand/randmt.h    |   40 +++++
 rand/randmts.c   |  157 +++++++++++++++++++++
 rand/randmui.c   |   75 ++++++++++
 rand/rands.c     |   31 ++++
 rand/randsd.c    |   28 +++
 rand/randsdui.c  |   33 ++++
 randbui.c        |   46 ------
 randclr.c        |   27 ---
 randdef.c        |   27 ---
 randiset.c       |   28 ---
 randlc2s.c       |   82 -----------
 randlc2x.c       |  322 -------------------------------------------
 randmt.c         |  405 -------------------------------------------------------
 randmt.h         |   40 -----
 randmts.c        |  157 ---------------------
 randmui.c        |   75 ----------
 rands.c          |   31 ----
 randsd.c         |   28 ---
 randsdui.c       |   33 ----
 32 files changed, 1411 insertions(+), 1372 deletions(-)

diffs (truncated from 2948 to 300 lines):

diff -r b4bed5bd8088 -r b9fe39699810 ChangeLog
--- a/ChangeLog	Thu Nov 11 08:31:02 2010 +0100
+++ b/ChangeLog	Thu Nov 11 09:56:42 2010 +0100
@@ -1,5 +1,13 @@
 2010-11-11  Torbjorn Granlund  <tege at gmplib.org>
 
+	* rand: New directory, move rand*.c and randmt.h here.
+	* rand/Makefile.am: New file.
+	* Makefile.am (SUBDIRS): Add rand.
+	(RANDOM_OBJECTS): New variable.
+	(libgmp_la_SOURCES): Remove random objects.
+	(libgmp_la_DEPENDENCIES): Add RANDOM_OBJECTS.
+	* configure.in (AC_OUTPUT): Add rand/Makefile.
+
 	* ansi2knr.1: File removed.
 	* ansi2knr.c: File removed.
 
diff -r b4bed5bd8088 -r b9fe39699810 Makefile.am
--- a/Makefile.am	Thu Nov 11 08:31:02 2010 +0100
+++ b/Makefile.am	Thu Nov 11 09:56:42 2010 +0100
@@ -92,7 +92,7 @@
 LIBMP_LT_AGE =      1
 
 
-SUBDIRS = tests mpn mpz mpq mpf printf scanf cxx mpbsd demos tune doc
+SUBDIRS = tests mpn mpz mpq mpf printf scanf rand cxx mpbsd demos tune doc
 
 EXTRA_DIST = configfsf.guess configfsf.sub .gdbinit INSTALL.autoconf
 
@@ -221,6 +221,12 @@
   scanf/scanf$U.lo scanf/sscanf$U.lo scanf/sscanffuns$U.lo	\
   scanf/vfscanf$U.lo scanf/vscanf$U.lo scanf/vsscanf$U.lo
 
+RANDOM_OBJECTS =							\
+  rand/rand$U.lo rand/randclr$U.lo rand/randdef$U.lo rand/randiset$U.lo	\
+  rand/randlc2s$U.lo rand/randlc2x$U.lo rand/randmt$U.lo		\
+  rand/randmts$U.lo rand/rands$U.lo rand/randsd$U.lo rand/randsdui$U.lo	\
+  rand/randbui$U.lo rand/randmui$U.lo
+
 # no $U for C++ files
 CXX_OBJECTS =								\
   cxx/isfuns.lo cxx/ismpf.lo cxx/ismpq.lo cxx/ismpz.lo cxx/ismpznw.lo	\
@@ -248,17 +254,15 @@
 # -export-symbols, since the tune and speed programs, and perhaps some of
 # the test programs, want to access undocumented symbols.
 
-libgmp_la_SOURCES = gmp-impl.h longlong.h randmt.h			\
+libgmp_la_SOURCES = gmp-impl.h longlong.h				\
   assert.c compat.c errno.c extract-dbl.c invalid.c memory.c		\
   mp_bpl.c mp_clz_tab.c mp_dv_tab.c mp_minv_tab.c mp_get_fns.c mp_set_fns.c \
-  rand.c randclr.c randdef.c randiset.c randlc2s.c randlc2x.c randmt.c	\
-  randmts.c rands.c randsd.c randsdui.c randbui.c randmui.c version.c	\
-  nextprime.c
+  version.c nextprime.c
 EXTRA_libgmp_la_SOURCES = tal-debug.c tal-notreent.c tal-reent.c
 libgmp_la_DEPENDENCIES = @TAL_OBJECT@		\
   $(MPF_OBJECTS) $(MPZ_OBJECTS) $(MPQ_OBJECTS)	\
   $(MPN_OBJECTS) @mpn_objs_in_libgmp@		\
-  $(PRINTF_OBJECTS)  $(SCANF_OBJECTS)
+  $(PRINTF_OBJECTS)  $(SCANF_OBJECTS) $(RANDOM_OBJECTS)
 libgmp_la_LIBADD = $(libgmp_la_DEPENDENCIES)
 libgmp_la_LDFLAGS = $(GMP_LDFLAGS) $(LIBGMP_LDFLAGS) \
   -version-info $(LIBGMP_LT_CURRENT):$(LIBGMP_LT_REVISION):$(LIBGMP_LT_AGE)
diff -r b4bed5bd8088 -r b9fe39699810 configure.in
--- a/configure.in	Thu Nov 11 08:31:02 2010 +0100
+++ b/configure.in	Thu Nov 11 09:56:42 2010 +0100
@@ -3391,7 +3391,7 @@
 
 AC_OUTPUT(Makefile							\
   mpbsd/Makefile mpf/Makefile mpn/Makefile mpq/Makefile			\
-  mpz/Makefile printf/Makefile scanf/Makefile cxx/Makefile		\
+  mpz/Makefile printf/Makefile scanf/Makefile rand/Makefile cxx/Makefile \
   tests/Makefile tests/devel/Makefile tests/mpbsd/Makefile		\
   tests/mpf/Makefile tests/mpn/Makefile tests/mpq/Makefile		\
   tests/mpz/Makefile tests/rand/Makefile tests/misc/Makefile		\
diff -r b4bed5bd8088 -r b9fe39699810 rand.c
--- a/rand.c	Thu Nov 11 08:31:02 2010 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/* gmp_randinit (state, algorithm, ...) -- Initialize a random state.
-
-Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
-
-This file is part of the GNU MP Library.
-
-The GNU MP Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-The GNU MP Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
-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
-#if HAVE_STDARG
-gmp_randinit (gmp_randstate_t rstate,
-	      gmp_randalg_t alg,
-	      ...)
-#else
-gmp_randinit (va_alist)
-     va_dcl
-#endif
-{
-  va_list ap;
-#if HAVE_STDARG
-  va_start (ap, alg);
-#else
-  __gmp_randstate_struct *rstate;
-  gmp_randalg_t alg;
-  va_start (ap);
-  rstate = va_arg (ap, __gmp_randstate_struct *);
-  alg = va_arg (ap, gmp_randalg_t);
-#endif
-
-  switch (alg) {
-  case GMP_RAND_ALG_LC:
-    if (! gmp_randinit_lc_2exp_size (rstate, va_arg (ap, unsigned long)))
-      gmp_errno |= GMP_ERROR_INVALID_ARGUMENT;
-    break;
-  default:
-    gmp_errno |= GMP_ERROR_UNSUPPORTED_ARGUMENT;
-    break;
-  }
-  va_end (ap);
-}
diff -r b4bed5bd8088 -r b9fe39699810 rand/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rand/Makefile.am	Thu Nov 11 09:56:42 2010 +0100
@@ -0,0 +1,27 @@
+## Process this file with automake to generate Makefile.in
+
+# Copyright 2001, 2002, 2010 Free Software Foundation, Inc.
+#
+# This file is part of the GNU MP Library.
+#
+# The GNU MP Library is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at your
+# option) any later version.
+#
+# The GNU MP Library is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+# 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/.
+
+
+INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir)
+
+noinst_LTLIBRARIES = librandom.la
+
+librandom_la_SOURCES = randmt.h						\
+  rand.c randclr.c randdef.c randiset.c randlc2s.c randlc2x.c randmt.c	\
+  randmts.c rands.c randsd.c randsdui.c randbui.c randmui.c
diff -r b4bed5bd8088 -r b9fe39699810 rand/rand.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rand/rand.c	Thu Nov 11 09:56:42 2010 +0100
@@ -0,0 +1,64 @@
+/* gmp_randinit (state, algorithm, ...) -- Initialize a random state.
+
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+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
+#if HAVE_STDARG
+gmp_randinit (gmp_randstate_t rstate,
+	      gmp_randalg_t alg,
+	      ...)
+#else
+gmp_randinit (va_alist)
+     va_dcl
+#endif
+{
+  va_list ap;
+#if HAVE_STDARG
+  va_start (ap, alg);
+#else
+  __gmp_randstate_struct *rstate;
+  gmp_randalg_t alg;
+  va_start (ap);
+  rstate = va_arg (ap, __gmp_randstate_struct *);
+  alg = va_arg (ap, gmp_randalg_t);
+#endif
+
+  switch (alg) {
+  case GMP_RAND_ALG_LC:
+    if (! gmp_randinit_lc_2exp_size (rstate, va_arg (ap, unsigned long)))
+      gmp_errno |= GMP_ERROR_INVALID_ARGUMENT;
+    break;
+  default:
+    gmp_errno |= GMP_ERROR_UNSUPPORTED_ARGUMENT;
+    break;
+  }
+  va_end (ap);
+}
diff -r b4bed5bd8088 -r b9fe39699810 rand/randbui.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rand/randbui.c	Thu Nov 11 09:56:42 2010 +0100
@@ -0,0 +1,46 @@
+/* gmp_urandomb_ui -- random bits returned in a ulong.
+
+Copyright 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of the GNU MP Library.
+
+The GNU MP Library is free software; you can redistribute it and/or modify
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 3 of the License, or (at your
+option) any later version.
+
+The GNU MP Library is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+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"
+
+
+/* Currently bits>=BITS_PER_ULONG is quietly truncated to BITS_PER_ULONG,
+   maybe this should raise an exception or something.  */
+
+unsigned long
+gmp_urandomb_ui (gmp_randstate_ptr rstate, unsigned long bits)
+{
+  mp_limb_t  a[LIMBS_PER_ULONG];
+
+  /* start with zeros, since if bits==0 then _gmp_rand will store nothing at
+     all, or if bits <= GMP_NUMB_BITS then it will store only a[0] */
+  a[0] = 0;
+#if LIMBS_PER_ULONG > 1
+  a[1] = 0;
+#endif
+
+  _gmp_rand (a, rstate, MIN (bits, BITS_PER_ULONG));
+
+#if LIMBS_PER_ULONG == 1
+  return a[0];
+#else
+  return a[0] | (a[1] << GMP_NUMB_BITS);
+#endif
+}
diff -r b4bed5bd8088 -r b9fe39699810 rand/randclr.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rand/randclr.c	Thu Nov 11 09:56:42 2010 +0100
@@ -0,0 +1,27 @@
+/* gmp_randclear (state) -- Clear and deallocate random state STATE.
+
+Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+


More information about the gmp-commit mailing list