From: Mark Wooding Date: Sun, 29 Sep 2019 14:44:26 +0000 (+0100) Subject: rand/lcrand.c, rand/rand.c: Replace dynamic assertions with static ones. X-Git-Tag: 2.6.0~61 X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/commitdiff_plain/79bc45d029fd0283e76c3774070ec05710351ce9?hp=4e5ba4306db8cb64a87ad37084c0bf64c03563e1 rand/lcrand.c, rand/rand.c: Replace dynamic assertions with static ones. This adds a dependency on mLib 2.4.1. --- diff --git a/configure.ac b/configure.ac index b6c40ba5..b4f73896 100644 --- a/configure.ac +++ b/configure.ac @@ -423,7 +423,7 @@ dnl Set the master libraries we need. AC_SUBST([CATACOMB_LIBS]) dnl Necessary support libraries. -PKG_CHECK_MODULES([mLib], [mLib >= 2.3.0]) +PKG_CHECK_MODULES([mLib], [mLib >= 2.4.1]) AM_CFLAGS="$AM_CFLAGS $mLib_CFLAGS" dnl-------------------------------------------------------------------------- diff --git a/debian/control b/debian/control index c22c2559..89903a11 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: catacomb Section: libs Priority: extra Build-Depends: debhelper (>= 10), python, valgrind [!armel], pkg-config, - mlib-dev (>= 2.3.0) + mlib-dev (>= 2.4.1) Maintainer: Mark Wooding Standards-Version: 3.1.1 diff --git a/rand/lcrand.c b/rand/lcrand.c index d8c4a378..f0f01ddf 100644 --- a/rand/lcrand.c +++ b/rand/lcrand.c @@ -33,6 +33,7 @@ #include #include +#include #include #include "grand.h" @@ -106,15 +107,11 @@ uint32 lcrand(uint32 x) /* --- Now reduce mod p --- * * - * I'm using shifts and adds to do the multiply step here. This needs to - * be changed if @D@ ever becomes something other than 5. + * I'm using shifts and adds to do the multiply step here. */ -#if D != 5 -# error "Change shift sequence!" -#endif - { + STATIC_ASSERT(D == 5, "Shift sequence doesn't match prime"); uint32 q; q = yy[1]; diff --git a/rand/rand.c b/rand/rand.c index c2540f7e..5cca087e 100644 --- a/rand/rand.c +++ b/rand/rand.c @@ -251,9 +251,7 @@ void rand_add(rand_pool *r, const void *p, size_t sz, unsigned goodbits) const octet *c = p; int i, rot; -#if RAND_POOLSZ != 128 -# error Polynomial in rand_add is out of date. Fix it. -#endif + STATIC_ASSERT(RAND_POOLSZ == 128, "Polynomial doesn't match pool size"); RAND_RESOLVE(r);