xref: /freebsd/lib/libc/gen/mrand48.c (revision 8ab00b8fbc01315e36f6210e0ce1c3d5a356931f)
14b4b7d05SGarrett Wollman /*
24b4b7d05SGarrett Wollman  * Copyright (c) 1993 Martin Birgmeier
34b4b7d05SGarrett Wollman  * All rights reserved.
44b4b7d05SGarrett Wollman  *
54b4b7d05SGarrett Wollman  * You may redistribute unmodified or modified versions of this source
64b4b7d05SGarrett Wollman  * code provided that the above copyright notice and this and the
74b4b7d05SGarrett Wollman  * following conditions are retained.
84b4b7d05SGarrett Wollman  *
94b4b7d05SGarrett Wollman  * This software is provided ``as is'', and comes with no warranties
104b4b7d05SGarrett Wollman  * of any kind. I shall in no event be liable for anything that happens
114b4b7d05SGarrett Wollman  * to anyone/anything when using this software.
124b4b7d05SGarrett Wollman  */
134b4b7d05SGarrett Wollman 
14333fc21eSDavid E. O'Brien #include <sys/cdefs.h>
15333fc21eSDavid E. O'Brien __FBSDID("$FreeBSD$");
16333fc21eSDavid E. O'Brien 
17*8ab00b8fSEd Schouten #include <stdint.h>
18*8ab00b8fSEd Schouten 
194b4b7d05SGarrett Wollman #include "rand48.h"
204b4b7d05SGarrett Wollman 
214b4b7d05SGarrett Wollman extern unsigned short _rand48_seed[3];
224b4b7d05SGarrett Wollman 
234b4b7d05SGarrett Wollman long
244b4b7d05SGarrett Wollman mrand48(void)
254b4b7d05SGarrett Wollman {
26*8ab00b8fSEd Schouten 
274b4b7d05SGarrett Wollman 	_dorand48(_rand48_seed);
28*8ab00b8fSEd Schouten 	return ((int32_t)(((uint32_t)_rand48_seed[2] << 16) |
29*8ab00b8fSEd Schouten 	    (uint32_t)_rand48_seed[1]));
304b4b7d05SGarrett Wollman }
31