Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Cosmetic changes.
details: https://anonhg.NetBSD.org/src/rev/6b437fded3a3
branches: trunk
changeset: 514696:6b437fded3a3
user: enami <enami%NetBSD.org@localhost>
date: Sun Sep 09 00:32:52 2001 +0000
description:
Cosmetic changes.
diffstat:
sys/dev/rnd.c | 277 ++++++++++++++++++++++-------------------------------
sys/dev/rndpool.c | 99 +++++++-----------
sys/sys/rnd.h | 77 +++++++-------
3 files changed, 194 insertions(+), 259 deletions(-)
diffs (truncated from 1066 to 300 lines):
diff -r 417a99140685 -r 6b437fded3a3 sys/dev/rnd.c
--- a/sys/dev/rnd.c Sat Sep 08 23:29:05 2001 +0000
+++ b/sys/dev/rnd.c Sun Sep 09 00:32:52 2001 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd.c,v 1.22 2001/07/07 17:04:02 thorpej Exp $ */
+/* $NetBSD: rnd.c,v 1.23 2001/09/09 00:32:52 enami Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -57,34 +57,36 @@
#endif
#ifdef RND_DEBUG
-#define DPRINTF(l,x) if (rnd_debug & (l)) printf x
-int rnd_debug = 0;
+#define DPRINTF(l,x) if (rnd_debug & (l)) printf x
+int rnd_debug = 0;
#else
-#define DPRINTF(l,x)
+#define DPRINTF(l,x)
#endif
-#define RND_DEBUG_WRITE 0x0001
-#define RND_DEBUG_READ 0x0002
-#define RND_DEBUG_IOCTL 0x0004
-#define RND_DEBUG_SNOOZE 0x0008
+#define RND_DEBUG_WRITE 0x0001
+#define RND_DEBUG_READ 0x0002
+#define RND_DEBUG_IOCTL 0x0004
+#define RND_DEBUG_SNOOZE 0x0008
/*
* list devices attached
*/
-/* #define RND_VERBOSE */
+#if 0
+#define RND_VERBOSE
+#endif
/*
* Use the extraction time as a somewhat-random source
*/
#ifndef RND_USE_EXTRACT_TIME
-#define RND_USE_EXTRACT_TIME 1
+#define RND_USE_EXTRACT_TIME 1
#endif
/*
* The size of a temporary buffer, malloc()ed when needed, and used for
* reading and writing data.
*/
-#define RND_TEMP_BUFFER_SIZE 128
+#define RND_TEMP_BUFFER_SIZE 128
/*
* This is a little bit of state information attached to each device that we
@@ -92,10 +94,10 @@
* is full it will be "detached" from the source and added to the entropy
* pool after entropy is distilled as much as possible.
*/
-#define RND_SAMPLE_COUNT 64 /* collect N samples, then compress */
+#define RND_SAMPLE_COUNT 64 /* collect N samples, then compress */
typedef struct _rnd_sample_t {
- SIMPLEQ_ENTRY(_rnd_sample_t) next;
- rndsource_t *source;
+ SIMPLEQ_ENTRY(_rnd_sample_t) next;
+ rndsource_t *source;
int cursor;
int entropy;
u_int32_t ts[RND_SAMPLE_COUNT];
@@ -117,8 +119,8 @@
/*
* Set when there are readers blocking on data from us
*/
-#define RND_READWAITING 0x00000001
-volatile u_int32_t rnd_status;
+#define RND_READWAITING 0x00000001
+volatile u_int32_t rnd_status;
/*
* Memory pool; accessed only at splhigh().
@@ -133,7 +135,7 @@
* (rnd_samples, see above), and processed in a timeout routine; therefore,
* all other accesses to the random pool must be at splsoftclock() as well.
*/
-rndpool_t rnd_pool;
+rndpool_t rnd_pool;
/*
* This source is used to easily "remove" queue entries when the source
@@ -160,7 +162,7 @@
static inline void rnd_wakeup_readers(void);
static inline u_int32_t rnd_estimate_entropy(rndsource_t *, u_int32_t);
static inline u_int32_t rnd_counter(void);
-static void rnd_timeout(void *);
+static void rnd_timeout(void *);
static int rnd_ready = 0;
static int rnd_have_entropy = 0;
@@ -172,9 +174,9 @@
* using cycle counters and the like when possible.
*/
static inline u_int32_t
-rnd_counter()
+rnd_counter(void)
{
- struct timeval tv;
+ struct timeval tv;
#ifdef __HAVE_CPU_COUNTER
if (cpu_hascounter())
@@ -182,7 +184,7 @@
#endif
microtime(&tv);
- return tv.tv_sec * 1000000 + tv.tv_usec;
+ return (tv.tv_sec * 1000000 + tv.tv_usec);
}
/*
@@ -191,8 +193,9 @@
* Must be called at splsoftclock().
*/
static inline void
-rnd_wakeup_readers()
+rnd_wakeup_readers(void)
{
+
/*
* If we have added new bits, and now have enough to do something,
* wake up sleeping readers.
@@ -200,7 +203,7 @@
if (rndpool_get_entropy_count(&rnd_pool) > RND_ENTROPY_THRESHOLD * 8) {
if (rnd_status & RND_READWAITING) {
DPRINTF(RND_DEBUG_SNOOZE,
- ("waking up pending readers.\n"));
+ ("waking up pending readers.\n"));
rnd_status &= ~RND_READWAITING;
wakeup(&rnd_selq);
}
@@ -219,13 +222,9 @@
* non-zero. If any of these are zero, return zero.
*/
static inline u_int32_t
-rnd_estimate_entropy(rs, t)
- rndsource_t *rs;
- u_int32_t t;
+rnd_estimate_entropy(rndsource_t *rs, u_int32_t t)
{
- int32_t delta;
- int32_t delta2;
- int32_t delta3;
+ int32_t delta, delta2, delta3;
/*
* If the time counter has overflowed, calculate the real difference.
@@ -259,18 +258,17 @@
* might have something.
*/
if (delta == 0 || delta2 == 0 || delta3 == 0)
- return 0;
+ return (0);
- return 1;
+ return (1);
}
/*
- * attach the random device, and initialize the global random pool
+ * Attach the random device, and initialize the global random pool
* for our use.
*/
void
-rndattach(num)
- int num;
+rndattach(int num)
{
rnd_init();
@@ -287,7 +285,7 @@
SIMPLEQ_INIT(&rnd_samples);
pool_init(&rnd_mempool, sizeof(rnd_sample_t), 0, 0, 0, "rndsample",
- 0, NULL, NULL, 0);
+ 0, NULL, NULL, 0);
rndpool_init(&rnd_pool);
@@ -299,10 +297,7 @@
}
int
-rndopen(dev, flags, ifmt, p)
- dev_t dev;
- int flags, ifmt;
- struct proc *p;
+rndopen(dev_t dev, int flags, int ifmt, struct proc *p)
{
if (rnd_ready == 0)
@@ -327,32 +322,22 @@
}
int
-rndclose(dev, flags, ifmt, p)
- dev_t dev;
- int flags, ifmt;
- struct proc *p;
+rndclose(dev_t dev, int flags, int ifmt, struct proc *p)
{
return (0);
}
int
-rndread(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
+rndread(dev_t dev, struct uio *uio, int ioflag)
{
- int ret;
- u_int32_t nread;
- int n;
- int s;
- u_int8_t *buf;
- u_int32_t mode;
- u_int32_t entcnt;
+ u_int8_t *buf;
+ u_int32_t entcnt, mode, nread;
+ int n, ret, s;
DPRINTF(RND_DEBUG_READ,
- ("Random: Read of %d requested, flags 0x%08x\n",
- uio->uio_resid, ioflag));
+ ("Random: Read of %d requested, flags 0x%08x\n",
+ uio->uio_resid, ioflag));
if (uio->uio_resid == 0)
return (0);
@@ -410,7 +395,7 @@
rnd_status |= RND_READWAITING;
ret = tsleep(&rnd_selq, PRIBIO|PCATCH,
- "rndread", 0);
+ "rndread", 0);
if (ret)
goto out;
@@ -419,7 +404,7 @@
nread = rnd_extract_data(buf, n, mode);
/*
- * copy (possibly partial) data to the user.
+ * Copy (possibly partial) data to the user.
* If an error occurs, or this is a partial
* read, bail out.
*/
@@ -434,18 +419,13 @@
}
int
-rndwrite(dev, uio, ioflag)
- dev_t dev;
- struct uio *uio;
- int ioflag;
+rndwrite(dev_t dev, struct uio *uio, int ioflag)
{
- u_int8_t *buf;
- int ret;
- int n;
- int s;
+ u_int8_t *buf;
+ int n, ret, s;
DPRINTF(RND_DEBUG_WRITE,
- ("Random: Write of %d requested\n", uio->uio_resid));
+ ("Random: Write of %d requested\n", uio->uio_resid));
if (uio->uio_resid == 0)
return (0);
@@ -468,7 +448,7 @@
rndpool_add_data(&rnd_pool, buf, n, 0);
splx(s);
- DPRINTF(RND_DEBUG_WRITE, ("Random: Copied in %d bytes\n", n));
+ DPRINTF(RND_DEBUG_WRITE, ("Random: Copied in %d bytes\n", n));
}
free(buf, M_TEMP);
@@ -476,31 +456,24 @@
}
int
-rndioctl(dev, cmd, addr, flag, p)
- dev_t dev;
- u_long cmd;
- caddr_t addr;
- int flag;
- struct proc *p;
Home |
Main Index |
Thread Index |
Old Index