xref: /minix3/lib/libc/stdlib/lrand48.c (revision 84d9c625bfea59e274550651111ae9edfdc40fbd)
1*84d9c625SLionel Sambuc /*	$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $	*/
22fe8fb19SBen Gras 
32fe8fb19SBen Gras /*
42fe8fb19SBen Gras  * Copyright (c) 1993 Martin Birgmeier
52fe8fb19SBen Gras  * All rights reserved.
62fe8fb19SBen Gras  *
72fe8fb19SBen Gras  * You may redistribute unmodified or modified versions of this source
82fe8fb19SBen Gras  * code provided that the above copyright notice and this and the
92fe8fb19SBen Gras  * following conditions are retained.
102fe8fb19SBen Gras  *
112fe8fb19SBen Gras  * This software is provided ``as is'', and comes with no warranties
122fe8fb19SBen Gras  * of any kind. I shall in no event be liable for anything that happens
132fe8fb19SBen Gras  * to anyone/anything when using this software.
142fe8fb19SBen Gras  */
152fe8fb19SBen Gras 
162fe8fb19SBen Gras #include <sys/cdefs.h>
172fe8fb19SBen Gras #if defined(LIBC_SCCS) && !defined(lint)
18*84d9c625SLionel Sambuc __RCSID("$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $");
192fe8fb19SBen Gras #endif /* LIBC_SCCS and not lint */
202fe8fb19SBen Gras 
212fe8fb19SBen Gras #include "namespace.h"
222fe8fb19SBen Gras #include "rand48.h"
232fe8fb19SBen Gras 
242fe8fb19SBen Gras #ifdef __weak_alias
__weak_alias(lrand48,_lrand48)252fe8fb19SBen Gras __weak_alias(lrand48,_lrand48)
262fe8fb19SBen Gras #endif
272fe8fb19SBen Gras 
282fe8fb19SBen Gras long
292fe8fb19SBen Gras lrand48(void)
302fe8fb19SBen Gras {
312fe8fb19SBen Gras 	__dorand48(__rand48_seed);
32*84d9c625SLionel Sambuc 	return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1);
332fe8fb19SBen Gras }
34