1 /*
2  * Copyright (c) 1993 Martin Birgmeier
3  * All rights reserved.
4  *
5  * You may redistribute unmodified or modified versions of this source
6  * code provided that the above copyright notice and this and the
7  * following conditions are retained.
8  *
9  * This software is provided ``as is'', and comes with no warranties
10  * of any kind. I shall in no event be liable for anything that happens
11  * to anyone/anything when using this software.
12  */
13 
14 #include "rand48.h"
15 
16 unsigned short *
_seed48_r(struct _rand48 * r,unsigned short xseed[3])17 _seed48_r (struct _rand48 *r,
18        unsigned short xseed[3])
19 {
20   static NEWLIB_THREAD_LOCAL unsigned short sseed[3];
21 
22   sseed[0] = r->_seed[0];
23   sseed[1] = r->_seed[1];
24   sseed[2] = r->_seed[2];
25   r->_seed[0] = xseed[0];
26   r->_seed[1] = xseed[1];
27   r->_seed[2] = xseed[2];
28   r->_mult[0] = _RAND48_MULT_0;
29   r->_mult[1] = _RAND48_MULT_1;
30   r->_mult[2] = _RAND48_MULT_2;
31   r->_add = _RAND48_ADD;
32   return sseed;
33 }
34 
35 #ifndef _REENT_ONLY
36 unsigned short *
seed48(unsigned short xseed[3])37 seed48 (unsigned short xseed[3])
38 {
39   return _seed48_r (&_rand48, xseed);
40 }
41 #endif /* !_REENT_ONLY */
42