rand.c (75845) | rand.c (75862) |
---|---|
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 --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>. 34 * | 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 --- 18 unchanged lines hidden (view full) --- 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>. 34 * |
35 * $FreeBSD: head/lib/libc/stdlib/rand.c 75845 2001-04-23 02:29:10Z ache $ | 35 * $FreeBSD: head/lib/libc/stdlib/rand.c 75862 2001-04-23 10:14:28Z ache $ |
36 */ 37 38#if defined(LIBC_SCCS) && !defined(lint) 39static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93"; 40#endif /* LIBC_SCCS and not lint */ 41 42#include <sys/time.h> /* for sranddev() */ 43#include <sys/types.h> --- 81 unchanged lines hidden (view full) --- 125 _close(fd); 126 } 127 128 if (!done) { 129 struct timeval tv; 130 unsigned long junk; 131 132 gettimeofday(&tv, NULL); | 36 */ 37 38#if defined(LIBC_SCCS) && !defined(lint) 39static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93"; 40#endif /* LIBC_SCCS and not lint */ 41 42#include <sys/time.h> /* for sranddev() */ 43#include <sys/types.h> --- 81 unchanged lines hidden (view full) --- 125 _close(fd); 126 } 127 128 if (!done) { 129 struct timeval tv; 130 unsigned long junk; 131 132 gettimeofday(&tv, NULL); |
133 next = getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk; | 133 next = (getpid() << 16) ^ tv.tv_sec ^ tv.tv_usec ^ junk; |
134 } 135} 136 137 138#ifdef TEST 139 140main() 141{ --- 24 unchanged lines hidden --- | 134 } 135} 136 137 138#ifdef TEST 139 140main() 141{ --- 24 unchanged lines hidden --- |