Deleted Added
full compact
rand.c (110321) rand.c (110421)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32 *
33 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
38#endif /* LIBC_SCCS and not lint */
39#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32 *
33 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93";
38#endif /* LIBC_SCCS and not lint */
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 110321 2003-02-04 11:24:08Z ache $");
40__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 110421 2003-02-05 21:25:50Z ache $");
41
42#include "namespace.h"
43#include <sys/time.h> /* for sranddev() */
44#include <sys/types.h>
45#include <fcntl.h> /* for sranddev() */
46#include <stdlib.h>
47#include <unistd.h> /* for sranddev() */
48#include "un-namespace.h"

--- 44 unchanged lines hidden (view full) ---

93 u_long val = (u_long) *ctx;
94 int r = do_rand(&val);
95
96 *ctx = (unsigned int) val;
97 return (r);
98}
99
100
41
42#include "namespace.h"
43#include <sys/time.h> /* for sranddev() */
44#include <sys/types.h>
45#include <fcntl.h> /* for sranddev() */
46#include <stdlib.h>
47#include <unistd.h> /* for sranddev() */
48#include "un-namespace.h"

--- 44 unchanged lines hidden (view full) ---

93 u_long val = (u_long) *ctx;
94 int r = do_rand(&val);
95
96 *ctx = (unsigned int) val;
97 return (r);
98}
99
100
101static u_long next = 1;
101static u_long next = 892053144; /* after srand(1), NSHUFF counted */
102
103int
104rand()
105{
102
103int
104rand()
105{
106 return do_rand(&next);
106 return (do_rand(&next));
107}
108
109void
110srand(seed)
111u_int seed;
112{
113 int i;
114
115 next = seed;
116 for (i = 0; i < NSHUFF; i++)
107}
108
109void
110srand(seed)
111u_int seed;
112{
113 int i;
114
115 next = seed;
116 for (i = 0; i < NSHUFF; i++)
117 (void)do_rand(&next);
117 (void)rand();
118}
119
120
121/*
122 * sranddev:
123 *
124 * Many programs choose the seed value in a totally predictable manner.
125 * This often causes problems. We seed the generator using the much more

--- 53 unchanged lines hidden ---
118}
119
120
121/*
122 * sranddev:
123 *
124 * Many programs choose the seed value in a totally predictable manner.
125 * This often causes problems. We seed the generator using the much more

--- 53 unchanged lines hidden ---