rand.c (252608) | rand.c (252648) |
---|---|
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 --- 19 unchanged lines hidden (view full) --- 28 * 29 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>. 30 */ 31 32#if defined(LIBC_SCCS) && !defined(lint) 33static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93"; 34#endif /* LIBC_SCCS and not lint */ 35#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 --- 19 unchanged lines hidden (view full) --- 28 * 29 * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>. 30 */ 31 32#if defined(LIBC_SCCS) && !defined(lint) 33static char sccsid[] = "@(#)rand.c 8.1 (Berkeley) 6/14/93"; 34#endif /* LIBC_SCCS and not lint */ 35#include <sys/cdefs.h> |
36__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 252608 2013-07-03 21:21:54Z ache $"); | 36__FBSDID("$FreeBSD: head/lib/libc/stdlib/rand.c 252648 2013-07-03 23:27:04Z ache $"); |
37 38#include "namespace.h" 39#include <sys/param.h> 40#include <sys/sysctl.h> 41#include <sys/types.h> 42#include <stdlib.h> 43#include "un-namespace.h" 44 --- 40 unchanged lines hidden (view full) --- 85{ 86 u_long val = (u_long) *ctx; 87#ifndef USE_WEAK_SEEDING 88 /* Transform to [1, 0x7ffffffe] range. */ 89 val = (val % 0x7ffffffe) + 1; 90#endif 91 int r = do_rand(&val); 92 | 37 38#include "namespace.h" 39#include <sys/param.h> 40#include <sys/sysctl.h> 41#include <sys/types.h> 42#include <stdlib.h> 43#include "un-namespace.h" 44 --- 40 unchanged lines hidden (view full) --- 85{ 86 u_long val = (u_long) *ctx; 87#ifndef USE_WEAK_SEEDING 88 /* Transform to [1, 0x7ffffffe] range. */ 89 val = (val % 0x7ffffffe) + 1; 90#endif 91 int r = do_rand(&val); 92 |
93 *ctx = (unsigned int) val; | 93#ifdef USE_WEAK_SEEDING 94 *ctx = (unsigned int)val; 95#else 96 *ctx = (unsigned int)(val - 1); 97#endif |
94 return (r); 95} 96 97 98static u_long next = 1; 99 100int 101rand() --- 69 unchanged lines hidden --- | 98 return (r); 99} 100 101 102static u_long next = 1; 103 104int 105rand() --- 69 unchanged lines hidden --- |