]>
Commit | Line | Data |
---|---|---|
1f2f436a A |
1 | --- random.c.bsdnew 2009-11-13 14:11:50.000000000 -0800 |
2 | +++ random.c 2009-11-13 14:11:51.000000000 -0800 | |
3 | @@ -33,6 +33,14 @@ static char sccsid[] = "@(#)random.c 8.2 | |
3d9156a7 | 4 | #include <sys/cdefs.h> |
1f2f436a | 5 | __FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.25 2007/01/09 00:28:10 imp Exp $"); |
3d9156a7 A |
6 | |
7 | +/* | |
8 | + * We always compile with __DARWIN_UNIX03 set to one, relying on the fact that | |
9 | + * (for non-LP64) sizeof(int) == sizeof(long) == sizeof(size_t), so that we | |
10 | + * don't have to have two different versions of the prototypes. For LP64, | |
11 | + * we only support the POSIX-compatible prototypes. | |
12 | + */ | |
13 | +#undef __DARWIN_UNIX03 | |
14 | +#define __DARWIN_UNIX03 1 | |
15 | #include "namespace.h" | |
16 | #include <sys/time.h> /* for srandomdev() */ | |
17 | #include <fcntl.h> /* for srandomdev() */ | |
1f2f436a | 18 | @@ -216,7 +224,7 @@ static int rand_deg = DEG_3; |
3d9156a7 A |
19 | static int rand_sep = SEP_3; |
20 | static uint32_t *end_ptr = &randtbl[DEG_3 + 1]; | |
21 | ||
22 | -static inline uint32_t good_rand(int32_t); | |
23 | +static inline uint32_t good_rand(int32_t) __attribute__((always_inline)); | |
24 | ||
25 | static inline uint32_t good_rand (x) | |
26 | int32_t x; | |
1f2f436a | 27 | @@ -265,7 +273,7 @@ static inline uint32_t good_rand (x) |
3d9156a7 A |
28 | */ |
29 | void | |
30 | srandom(x) | |
31 | - unsigned long x; | |
32 | + unsigned x; | |
33 | { | |
34 | int i, lim; | |
35 | ||
1f2f436a | 36 | @@ -353,9 +361,9 @@ srandomdev() |
3d9156a7 A |
37 | */ |
38 | char * | |
39 | initstate(seed, arg_state, n) | |
40 | - unsigned long seed; /* seed for R.N.G. */ | |
41 | + unsigned seed; /* seed for R.N.G. */ | |
42 | char *arg_state; /* pointer to state array */ | |
43 | - long n; /* # bytes of state info */ | |
44 | + size_t n; /* # bytes of state info */ | |
45 | { | |
46 | char *ostate = (char *)(&state[-1]); | |
47 | uint32_t *int_arg_state = (uint32_t *)arg_state; | |
1f2f436a | 48 | @@ -421,7 +429,7 @@ initstate(seed, arg_state, n) |
3d9156a7 A |
49 | */ |
50 | char * | |
51 | setstate(arg_state) | |
52 | - char *arg_state; /* pointer to state array */ | |
53 | + const char *arg_state; /* pointer to state array */ | |
54 | { | |
55 | uint32_t *new_state = (uint32_t *)arg_state; | |
56 | uint32_t type = new_state[0] % MAX_TYPES; |