chiark / gitweb /
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 b6c40ba5b5a1646616690baf998ff860135b76c9..b4f73896e940f4fa3a5debd8a42fc14c488a37c2 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 c22c25597e93f7e4f3f177f95e60873ad6ab8759..89903a11369d8c368f005cdd47bb3c0ad003ef3c 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 d8c4a378267b5a5c957cb678b9a6150cceec3436..f0f01ddfccc6b421b0555e6430d5a85e9d379ed5 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 c2540f7e485a567c12453f1bfd54a90309ce498f..5cca087ef96eb63f5cad4c20560af0ba49c0a67c 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);