rand/lcrand.c, rand/rand.c: Replace dynamic assertions with static ones.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 29 Sep 2019 14:44:26 +0000 (15:44 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 29 Sep 2019 20:44:57 +0000 (21:44 +0100)
This adds a dependency on mLib 2.4.1.

configure.ac
debian/control
rand/lcrand.c
rand/rand.c

index b6c40ba..b4f7389 100644 (file)
@@ -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--------------------------------------------------------------------------
index c22c255..89903a1 100644 (file)
@@ -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 <mdw@distorted.org.uk>
 Standards-Version: 3.1.1
 
index d8c4a37..f0f01dd 100644 (file)
@@ -33,6 +33,7 @@
 #include <string.h>
 
 #include <mLib/bits.h>
+#include <mLib/macros.h>
 #include <mLib/sub.h>
 
 #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];
index c2540f7..5cca087 100644 (file)
@@ -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);