mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Merge remote-tracking branch 'origin/patches-2.0'
This commit is contained in:
commit
5419803d3a
@ -56,10 +56,12 @@ evutil_secure_rng_global_setup_locks_(const int enable_locks)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef _EVENT_HAVE_ARC4RANDOM_BUF
|
||||
static void
|
||||
arc4random_buf(void *buf, size_t n)
|
||||
ev_arc4random_buf(void *buf, size_t n)
|
||||
{
|
||||
#ifdef _EVENT_HAVE_ARC4RANDOM_BUF
|
||||
return arc4random_buf(buf, n);
|
||||
#else
|
||||
unsigned char *b = buf;
|
||||
/* Make sure that we start out with b at a 4-byte alignment; plenty
|
||||
* of CPUs care about this for 32-bit access. */
|
||||
@ -79,8 +81,8 @@ arc4random_buf(void *buf, size_t n)
|
||||
ev_uint32_t u = arc4random();
|
||||
memcpy(b, &u, n);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#else /* !_EVENT_HAVE_ARC4RANDOM { */
|
||||
|
||||
@ -123,12 +125,18 @@ evutil_secure_rng_init(void)
|
||||
return val;
|
||||
}
|
||||
|
||||
static void
|
||||
ev_arc4random_buf(void *buf, size_t n)
|
||||
{
|
||||
arc4random_buf(buf, n);
|
||||
}
|
||||
|
||||
#endif /* } !_EVENT_HAVE_ARC4RANDOM */
|
||||
|
||||
void
|
||||
evutil_secure_rng_get_bytes(void *buf, size_t n)
|
||||
{
|
||||
arc4random_buf(buf, n);
|
||||
ev_arc4random_buf(buf, n);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user