Module Name: src Committed By: riastradh Date: Mon Sep 3 18:52:34 UTC 2018
Modified Files: src/sys/lib/libkern: rngtest.c Log Message: We have popcount; no need to reimplement it. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/lib/libkern/rngtest.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/lib/libkern/rngtest.c diff -u src/sys/lib/libkern/rngtest.c:1.3 src/sys/lib/libkern/rngtest.c:1.4 --- src/sys/lib/libkern/rngtest.c:1.3 Mon Mar 28 15:20:16 2016 +++ src/sys/lib/libkern/rngtest.c Mon Sep 3 18:52:33 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: rngtest.c,v 1.3 2016/03/28 15:20:16 riastradh Exp $ */ +/* $NetBSD: rngtest.c,v 1.4 2018/09/03 18:52:33 riastradh Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -142,7 +142,7 @@ the GNU Public License. #include <lib/libkern/libkern.h> #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: rngtest.c,v 1.3 2016/03/28 15:20:16 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rngtest.c,v 1.4 2018/09/03 18:52:33 riastradh Exp $"); #ifndef _KERNEL static inline int @@ -169,26 +169,6 @@ const int maxones = MAXONES; const long long minpoke = (MINPOKE * PRECISION); const long long maxpoke = (MAXPOKE * PRECISION); -/* Population count of 1's in a byte */ -const unsigned char Popcount[] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8 -}; - /* end of run */ static void endrun(rngtest_t *const rc, const int last, int run) @@ -221,7 +201,7 @@ rngtest(rngtest_t *const rc) /* monobit test */ for (p = rc->rt_b, c = 0; p < &rc->rt_b[sizeof rc->rt_b]; ++p) - c += Popcount[*p]; + c += popcount(*p); if (c <= minones || maxones <= c) { printf("Kernel RNG \"%s\" monobit test FAILURE: %d ones\n", rc->rt_name, c);