r41051 - /trunk/libmath-random-perl/debian/patches/random-seed.patch
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Fri Jul 31 01:46:37 UTC 2009
Author: jawnsy-guest
Date: Fri Jul 31 01:46:31 2009
New Revision: 41051
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41051
Log:
Rewrote my patch to use setall
Modified:
trunk/libmath-random-perl/debian/patches/random-seed.patch
Modified: trunk/libmath-random-perl/debian/patches/random-seed.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmath-random-perl/debian/patches/random-seed.patch?rev=41051&op=diff
==============================================================================
--- trunk/libmath-random-perl/debian/patches/random-seed.patch (original)
+++ trunk/libmath-random-perl/debian/patches/random-seed.patch Fri Jul 31 01:46:31 2009
@@ -10,18 +10,23 @@
Forwarded: yes
--- a/Random.pm
+++ b/Random.pm
-@@ -73,7 +73,7 @@
+@@ -73,7 +73,12 @@
### set seeds by default
-salfph(scalar(localtime()));
-+salfph(get_seed() || scalar(localtime));
++if ($] > 5.008001) {
++ set_default_seed();
++}
++else {
++ salfph(scalar localtime);
++}
#####################################################################
# RANDOM DEVIATE GENERATORS #
--- a/Random.xs
+++ b/Random.xs
-@@ -11,6 +11,28 @@
+@@ -11,6 +11,23 @@
#include "randlib.h"
#include "helper.h"
@@ -34,32 +39,25 @@
+#if PERL_VERSION_ATLEAST (5,8,1)
+/* For whatever reason, the random seeds need to be in 1..2^30; the below will
+ * be uniformly distributed assuming the seed value is uniformly distributed.
-+ *
-+ * This approach isn't cryptographically secure. Consider using /dev/random
-+ * or Math::TrulyRandom to get some real entropy.
+ */
-+#define Perl_get_seed (long)(Perl_seed(aTHX) % 1073741824L)
-+#else
-+/* If we don't support seeds, return 0 so we can fall back to localtime for
-+ * default seeding. There's a chance Perl_seed will return 0 and mask this,
-+ * but in that case the data should still be "random enough" anyway.
-+ */
-+#define Perl_get_seed 0L
-+#endif /* Perl_seed */
++#define default_seed_mechanism \
++ setall((long)(Perl_seed(aTHX) % 1073741824L), \
++ (long)(Perl_seed(aTHX) % 1073741824L));
++#else /* Perl < 5.8.1 */
++#define default_seed_mechanism not_here("Perl_seed");
++#endif
+
static int
not_here(s)
char *s;
-@@ -38,6 +60,12 @@
+@@ -38,6 +55,10 @@
MODULE = Math::Random PACKAGE = Math::Random
-+long
-+get_seed()
-+ CODE:
-+ RETVAL = Perl_get_seed;
-+ OUTPUT:
-+ RETVAL
++void
++set_default_seed()
++ CODE:
++ default_seed_mechanism;
double
genbet (aa,bb)
More information about the Pkg-perl-cvs-commits
mailing list