|
1 --- a/evutil_rand.c 2012-08-02 10:36:53.000000000 -0500 |
|
2 +++ b/evutil_rand.c 2013-02-20 13:01:45.000000000 -0600 |
|
3 @@ -58,27 +58,16 @@ evutil_secure_rng_global_setup_locks_(co |
|
4 static void |
|
5 ev_arc4random_buf(void *buf, size_t n) |
|
6 { |
|
7 #if defined(_EVENT_HAVE_ARC4RANDOM_BUF) && !defined(__APPLE__) |
|
8 return arc4random_buf(buf, n); |
|
9 #else |
|
10 unsigned char *b = buf; |
|
11 |
|
12 -#if defined(_EVENT_HAVE_ARC4RANDOM_BUF) |
|
13 - /* OSX 10.7 introducd arc4random_buf, so if you build your program |
|
14 - * there, you'll get surprised when older versions of OSX fail to run. |
|
15 - * To solve this, we can check whether the function pointer is set, |
|
16 - * and fall back otherwise. (OSX does this using some linker |
|
17 - * trickery.) |
|
18 - */ |
|
19 - if (arc4random_buf != NULL) { |
|
20 - return arc4random_buf(buf, n); |
|
21 - } |
|
22 -#endif |
|
23 /* Make sure that we start out with b at a 4-byte alignment; plenty |
|
24 * of CPUs care about this for 32-bit access. */ |
|
25 if (n >= 4 && ((ev_uintptr_t)b) & 3) { |
|
26 ev_uint32_t u = arc4random(); |
|
27 int n_bytes = 4 - (((ev_uintptr_t)b) & 3); |
|
28 memcpy(b, &u, n_bytes); |
|
29 b += n_bytes; |
|
30 n -= n_bytes; |