Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/lib/libkern We have popcount; no need to reimplement it.



details:   https://anonhg.NetBSD.org/src/rev/020f66b70986
branches:  trunk
changeset: 993290:020f66b70986
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Sep 03 18:52:33 2018 +0000

description:
We have popcount; no need to reimplement it.

diffstat:

 sys/lib/libkern/rngtest.c |  26 +++-----------------------
 1 files changed, 3 insertions(+), 23 deletions(-)

diffs (54 lines):

diff -r 0cc9d387cc88 -r 020f66b70986 sys/lib/libkern/rngtest.c
--- a/sys/lib/libkern/rngtest.c Mon Sep 03 18:51:30 2018 +0000
+++ b/sys/lib/libkern/rngtest.c Mon Sep 03 18:52:33 2018 +0000
@@ -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 @@
 #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 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 @@
 
        /* 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);



Home | Main Index | Thread Index | Old Index