app-crypt/dieharder: fix random on 64bit
authorAlon Bar-Lev <alonbl@gentoo.org>
Thu, 7 Feb 2019 21:02:46 +0000 (23:02 +0200)
committerAlon Bar-Lev <alonbl@gentoo.org>
Thu, 7 Feb 2019 21:03:18 +0000 (23:03 +0200)
Closes: https://bugs.gentoo.org/show_bug.cgi?id=677386
Thanks: vm666
Signed-off-by: Alon Bar-Lev <alonbl@gentoo.org>
Package-Manager: Portage-2.3.51, Repoman-2.3.11

app-crypt/dieharder/dieharder-3.31.1-r2.ebuild [new file with mode: 0644]
app-crypt/dieharder/files/dieharder-3.31.1-urandom-64bit.patch [new file with mode: 0644]

diff --git a/app-crypt/dieharder/dieharder-3.31.1-r2.ebuild b/app-crypt/dieharder/dieharder-3.31.1-r2.ebuild
new file mode 100644 (file)
index 0000000..5a949f9
--- /dev/null
@@ -0,0 +1,56 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+DESCRIPTION="An advanced suite for testing the randomness of RNG's"
+HOMEPAGE="http://www.phy.duke.edu/~rgb/General/dieharder.php"
+SRC_URI="http://www.phy.duke.edu/~rgb/General/${PN}/${P}.tgz"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~sparc ~x86"
+IUSE="doc"
+RESTRICT="test"
+
+RDEPEND="sci-libs/gsl"
+DEPEND="${RDEPEND}
+       doc? ( dev-tex/latex2html )"
+
+DOCS=(
+       NOTES
+)
+HTML_DOCS=()
+
+PATCHES=(
+       "${FILESDIR}/${P}-build.patch"
+       "${FILESDIR}/${P}-urandom-64bit.patch"
+)
+
+pkg_setup() {
+       use doc && DOCS+=(
+               ChangeLog
+               manual/dieharder.pdf manual/dieharder.ps
+       )
+       use doc && HTML_DOCS+=(
+               dieharder.html
+       )
+}
+
+src_compile() {
+       emake -j1
+       use doc && emake -C manual
+}
+
+src_test() {
+       "${S}/dieharder/dieharder" -g 501 -a
+}
+
+src_install() {
+       default
+
+       docinto "dieharder"
+       dodoc dieharder/README dieharder/NOTES
+       docinto "libdieharder"
+       dodoc libdieharder/README libdieharder/NOTES
+}
diff --git a/app-crypt/dieharder/files/dieharder-3.31.1-urandom-64bit.patch b/app-crypt/dieharder/files/dieharder-3.31.1-urandom-64bit.patch
new file mode 100644 (file)
index 0000000..c5615b6
--- /dev/null
@@ -0,0 +1,87 @@
+diff -ru dieharder-3.31.1/libdieharder/rng_dev_arandom.c dieharder-3.31.1_fixed/libdieharder/rng_dev_arandom.c
+--- dieharder-3.31.1/libdieharder/rng_dev_arandom.c    2011-10-14 15:41:37.000000000 +0200
++++ dieharder-3.31.1_fixed/libdieharder/rng_dev_arandom.c      2014-01-03 22:51:30.010534418 +0100
+@@ -6,6 +6,7 @@
+  */
+ #include <dieharder/libdieharder.h>
++#include <stdint.h>
+ static unsigned long int dev_arandom_get (void *vstate);
+ static double dev_arandom_get_double (void *vstate);
+@@ -21,7 +22,7 @@
+ dev_arandom_get (void *vstate)
+ {
+   dev_arandom_state_t *state = (dev_arandom_state_t *) vstate;
+-  unsigned long int j;
++  uint32_t j;
+   if(state->fp != NULL) {
+     fread(&j,sizeof(j),1,state->fp);
+@@ -36,7 +37,7 @@
+ static double
+ dev_arandom_get_double (void *vstate)
+ {
+-  return dev_arandom_get (vstate) / (double) UINT_MAX;
++  return dev_arandom_get (vstate) / (double) UINT32_MAX;
+ }
+ static void
+diff -ru dieharder-3.31.1/libdieharder/rng_dev_random.c dieharder-3.31.1_fixed/libdieharder/rng_dev_random.c
+--- dieharder-3.31.1/libdieharder/rng_dev_random.c     2011-10-14 15:41:37.000000000 +0200
++++ dieharder-3.31.1_fixed/libdieharder/rng_dev_random.c       2014-01-03 22:50:57.852321485 +0100
+@@ -6,6 +6,7 @@
+  */
+ #include <dieharder/libdieharder.h>
++#include <stdint.h>
+ static unsigned long int dev_random_get (void *vstate);
+ static double dev_random_get_double (void *vstate);
+@@ -21,7 +22,7 @@
+ dev_random_get (void *vstate)
+ {
+   dev_random_state_t *state = (dev_random_state_t *) vstate;
+-  unsigned long int j;
++  uint32_t j;
+   if(state->fp != NULL) {
+     fread(&j,sizeof(j),1,state->fp);
+@@ -36,7 +37,7 @@
+ static double
+ dev_random_get_double (void *vstate)
+ {
+-  return dev_random_get (vstate) / (double) UINT_MAX;
++  return dev_random_get (vstate) / (double) UINT32_MAX;
+ }
+ static void
+diff -ru dieharder-3.31.1/libdieharder/rng_dev_urandom.c dieharder-3.31.1_fixed/libdieharder/rng_dev_urandom.c
+--- dieharder-3.31.1/libdieharder/rng_dev_urandom.c    2011-10-14 15:41:37.000000000 +0200
++++ dieharder-3.31.1_fixed/libdieharder/rng_dev_urandom.c      2014-01-03 23:06:24.124239582 +0100
+@@ -3,6 +3,7 @@
+  */
+ #include <dieharder/libdieharder.h>
++#include <stdint.h>
+ /*
+  * This is a wrapping of the /dev/random hardware rng
+@@ -21,7 +22,7 @@
+ dev_urandom_get (void *vstate)
+ {
+   dev_urandom_state_t *state = (dev_urandom_state_t *) vstate;
+-  unsigned long int j;
++  uint32_t j;
+   if(state->fp != NULL) {
+     fread(&j,sizeof(j),1,state->fp);
+@@ -36,7 +37,7 @@
+ static double
+ dev_urandom_get_double (void *vstate)
+ {
+-  return dev_urandom_get (vstate) / (double) UINT_MAX;
++  return dev_urandom_get (vstate) / (double) UINT32_MAX;
+ }
+ static void