defined(_M_IX86) || \
defined(__INTEL_COMPILER)
+extern int ottery_valgrind_;
/** Helper: invoke the RDRAND instruction to get 4 random bytes in the output
* value. Return 0 on success, and an error on failure. */
static int
uint32_t *up = (uint32_t *) out;
(void) cfg;
(void) state;
- if (! (ottery_get_cpu_capabilities_() & OTTERY_CPUCAP_RAND))
+ if (! (ottery_get_cpu_capabilities_() & OTTERY_CPUCAP_RAND) || ottery_valgrind_)
return OTTERY_ERR_INIT_STRONG_RNG;
while (outlen >= 4) {
if ((err = rdrand(up)))
/** Flag: true iff ottery_global_state_ is initialized. */
static int ottery_global_state_initialized_ = 0;
+int ottery_valgrind_ = 0;
/** A global state to use for the ottery_* functions that don't take a
* state. */
static struct ottery_state ottery_global_state_;
int n = ottery_st_init(&ottery_global_state_, cfg);
if (n == 0)
ottery_global_state_initialized_ = 1;
+ if (getenv("VALGRIND")) {
+ ottery_valgrind_ = 1;
+ }
return n;
}