]> git.saurik.com Git - apple/libc.git/blame - stdlib/FreeBSD/random.c.patch
Libc-391.4.1.tar.gz
[apple/libc.git] / stdlib / FreeBSD / random.c.patch
CommitLineData
3d9156a7
A
1--- random.c.orig 2004-12-01 20:08:48.000000000 -0800
2+++ random.c 2004-12-01 20:12:11.000000000 -0800
3@@ -37,6 +37,14 @@
4 #include <sys/cdefs.h>
5 __FBSDID("$FreeBSD: src/lib/libc/stdlib/random.c,v 1.24 2004/01/20 03:02:18 das Exp $");
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() */
18@@ -220,7 +228,7 @@
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;
27@@ -269,7 +277,7 @@
28 */
29 void
30 srandom(x)
31- unsigned long x;
32+ unsigned x;
33 {
34 int i, lim;
35
36@@ -357,9 +365,9 @@
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;
48@@ -425,7 +433,7 @@
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;