diff options
author | sam <sam@FreeBSD.org> | 2003-06-25 14:46:01 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2003-06-25 14:46:01 +0000 |
commit | d3e57f6d4a76b5378435d50fcf60ad04f526047c (patch) | |
tree | ea13dfa08a8b33cb9a1e49558723fcd9738f0128 /sys | |
parent | 2c8caa6b18b6e8514f91ed5dff1205f0c9c2a478 (diff) | |
download | FreeBSD-src-d3e57f6d4a76b5378435d50fcf60ad04f526047c.zip FreeBSD-src-d3e57f6d4a76b5378435d50fcf60ad04f526047c.tar.gz |
o correct mib spelling: reset -> retest
o add #ifdef's needed to share code directly with -stable
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/rndtest/rndtest.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/dev/rndtest/rndtest.c b/sys/dev/rndtest/rndtest.c index 8c06b3a..15bbc09 100644 --- a/sys/dev/rndtest/rndtest.c +++ b/sys/dev/rndtest/rndtest.c @@ -71,7 +71,7 @@ static const struct rndtest_testfunc { SYSCTL_NODE(_kern, OID_AUTO, rndtest, CTLFLAG_RD, 0, "RNG test parameters"); static int rndtest_retest = 120; /* interval in seconds */ -SYSCTL_INT(_kern_rndtest, OID_AUTO, reset, CTLFLAG_RW, &rndtest_retest, +SYSCTL_INT(_kern_rndtest, OID_AUTO, retest, CTLFLAG_RW, &rndtest_retest, 0, "retest interval (seconds)"); static struct rndtest_stats rndstats; SYSCTL_STRUCT(_kern_rndtest, OID_AUTO, stats, CTLFLAG_RD, &rndstats, @@ -93,8 +93,12 @@ rndtest_attach(device_t dev) rsp->rs_discard = 1; rsp->rs_collect = 1; rsp->rs_parent = dev; +#if __FreeBSD_version < 500000 + callout_init(&rsp->rs_to); +#else /* NB: 1 means the callout runs w/o Giant locked */ callout_init(&rsp->rs_to, 1); +#endif } else device_printf(dev, "rndtest_init: no memory for state block\n"); return (rsp); @@ -110,11 +114,11 @@ rndtest_detach(struct rndtest_state *rsp) void rndtest_harvest(struct rndtest_state *rsp, void *buf, u_int len) { + size_t i; /* * If enabled, collect data and run tests when we have enough. */ if (rsp->rs_collect) { - size_t i; for (i = 0; i < len; i++) { *rsp->rs_current = ((u_char *) buf)[i]; if (++rsp->rs_current == rsp->rs_end) { @@ -140,8 +144,16 @@ rndtest_harvest(struct rndtest_state *rsp, void *buf, u_int len) */ if (rsp->rs_discard) rndstats.rst_discard += len; - else + else { +#if __FreeBSD_version < 500000 + /* XXX verify buffer is word aligned */ + u_int32_t *p = buf; + for (len /= sizeof (u_int32_t); len; len--) + add_true_randomness(*p++); +#else random_harvest(buf, len, len*NBBY, 0, RANDOM_PURE); +#endif + } } static void |