/* * Generate a 32-bit counter. This should be more machine dependent, * using cycle counters and the like when possible. */ static inline u_int32_t rndpseudo_counter(void) { struct timeval tv; #if defined(__HAVE_CPU_COUNTER) && !defined(_RUMPKERNEL) /* XXX: bad pooka */ if (cpu_hascounter()) return (cpu_counter32()); #endif microtime(&tv); return (tv.tv_sec * 1000000 + tv.tv_usec); }
static inline uint32_t cprng_counter(void) { struct timeval tv; #if defined(__HAVE_CPU_COUNTER) if (cpu_hascounter()) return cpu_counter32(); #endif if (__predict_false(cold)) { static int ctr; /* microtime unsafe if clock not running yet */ return ctr++; } getmicrotime(&tv); return (tv.tv_sec * 1000000 + tv.tv_usec); }