Replace "timestamp" with "counter" in previous change, to avoid any
possible confusion that it has anything to do with accurate measurement of time. New names: __HAVE_CPU_COUNTER cpu_counter() cpu_hascounter()
This commit is contained in:
parent
f65502fc36
commit
bbca3924cd
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rnd.h,v 1.1 2000/06/05 21:15:22 sommerfeld Exp $ */
|
||||
/* $NetBSD: rnd.h,v 1.2 2000/06/06 01:33:17 sommerfeld Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -51,7 +51,7 @@
|
|||
#ifdef _KERNEL
|
||||
|
||||
static __inline int
|
||||
cpu_hastimestamp(void)
|
||||
cpu_hascounter(void)
|
||||
{
|
||||
#if I586_CPU || I686_CPU
|
||||
/*
|
||||
|
@ -68,7 +68,7 @@ cpu_hastimestamp(void)
|
|||
}
|
||||
|
||||
static __inline u_int32_t
|
||||
cpu_timestamp(void)
|
||||
cpu_counter(void)
|
||||
{
|
||||
return rdtsc();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.23 2000/06/05 21:15:22 sommerfeld Exp $ */
|
||||
/* $NetBSD: types.h,v 1.24 2000/06/06 01:33:17 sommerfeld Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -77,6 +77,6 @@ typedef int32_t register_t;
|
|||
|
||||
#define __HAVE_DEVICE_REGISTER
|
||||
#define __HAVE_NWSCONS
|
||||
#define __HAVE_CPU_TIMESTAMP
|
||||
#define __HAVE_CPU_COUNTER
|
||||
|
||||
#endif /* _MACHTYPES_H_ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rnd.c,v 1.19 2000/06/05 23:42:34 sommerfeld Exp $ */
|
||||
/* $NetBSD: rnd.c,v 1.20 2000/06/06 01:33:15 sommerfeld Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -52,7 +52,7 @@
|
|||
#include <sys/vnode.h>
|
||||
#include <sys/pool.h>
|
||||
|
||||
#ifdef __HAVE_CPU_TIMESTAMP
|
||||
#ifdef __HAVE_CPU_COUNTER
|
||||
#include <machine/rnd.h>
|
||||
#endif
|
||||
|
||||
|
@ -159,7 +159,7 @@ int rndpoll __P((dev_t, int, struct proc *));
|
|||
|
||||
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_timestamp(void);
|
||||
static inline u_int32_t rnd_counter(void);
|
||||
static void rnd_timeout(void *);
|
||||
|
||||
static int rnd_ready = 0;
|
||||
|
@ -168,17 +168,17 @@ static int rnd_have_entropy = 0;
|
|||
LIST_HEAD(, __rndsource_element) rnd_sources;
|
||||
|
||||
/*
|
||||
* Generate a 32-bit timestamp. This should be more machine dependant,
|
||||
* Generate a 32-bit counter. This should be more machine dependant,
|
||||
* using cycle counters and the like when possible.
|
||||
*/
|
||||
static inline u_int32_t
|
||||
rnd_timestamp()
|
||||
rnd_counter()
|
||||
{
|
||||
struct timeval tv;
|
||||
|
||||
#ifdef __HAVE_CPU_TIMESTAMP
|
||||
if (cpu_hastimestamp())
|
||||
return cpu_timestamp();
|
||||
#ifdef __HAVE_CPU_COUNTER
|
||||
if (cpu_hascounter())
|
||||
return cpu_counter();
|
||||
#endif
|
||||
microtime(&tv);
|
||||
|
||||
|
@ -761,7 +761,7 @@ rnd_attach_source(rs, name, type, flags)
|
|||
{
|
||||
u_int32_t ts;
|
||||
|
||||
ts = rnd_timestamp();
|
||||
ts = rnd_counter();
|
||||
|
||||
strcpy(rs->data.name, name);
|
||||
rs->data.last_time = ts;
|
||||
|
@ -852,10 +852,10 @@ rnd_add_uint32(rs, val)
|
|||
return;
|
||||
|
||||
/*
|
||||
* Pick the timestamp as soon as possible to avoid
|
||||
* Sample the counter as soon as possible to avoid
|
||||
* entropy overestimation.
|
||||
*/
|
||||
ts = rnd_timestamp();
|
||||
ts = rnd_counter();
|
||||
|
||||
/*
|
||||
* If the sample buffer is NULL, try to allocate one here. If this
|
||||
|
|
Loading…
Reference in New Issue