xref: /netbsd-src/lib/libc/stdlib/lrand48.c (revision 9818090a902ee133b531c6f759a84ca4c1019904)
1*9818090aSmatt /*	$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $	*/
24e067afcSperry 
3933a7b3aSbrezak /*
4933a7b3aSbrezak  * Copyright (c) 1993 Martin Birgmeier
5933a7b3aSbrezak  * All rights reserved.
6933a7b3aSbrezak  *
7933a7b3aSbrezak  * You may redistribute unmodified or modified versions of this source
8933a7b3aSbrezak  * code provided that the above copyright notice and this and the
9933a7b3aSbrezak  * following conditions are retained.
10933a7b3aSbrezak  *
11933a7b3aSbrezak  * This software is provided ``as is'', and comes with no warranties
12933a7b3aSbrezak  * of any kind. I shall in no event be liable for anything that happens
13933a7b3aSbrezak  * to anyone/anything when using this software.
14933a7b3aSbrezak  */
15933a7b3aSbrezak 
1688c3eadbSlukem #include <sys/cdefs.h>
1788c3eadbSlukem #if defined(LIBC_SCCS) && !defined(lint)
18*9818090aSmatt __RCSID("$NetBSD: lrand48.c,v 1.9 2013/10/22 08:08:51 matt Exp $");
1988c3eadbSlukem #endif /* LIBC_SCCS and not lint */
2088c3eadbSlukem 
2143fa6fe3Sjtc #include "namespace.h"
22933a7b3aSbrezak #include "rand48.h"
23933a7b3aSbrezak 
2443fa6fe3Sjtc #ifdef __weak_alias
__weak_alias(lrand48,_lrand48)2560549036Smycroft __weak_alias(lrand48,_lrand48)
2643fa6fe3Sjtc #endif
27933a7b3aSbrezak 
28933a7b3aSbrezak long
29933a7b3aSbrezak lrand48(void)
30933a7b3aSbrezak {
31d2b1e8e4Sjtc 	__dorand48(__rand48_seed);
32*9818090aSmatt 	return __rand48_seed[2] * 32768 + (__rand48_seed[1] >> 1);
33933a7b3aSbrezak }
34