1206917Smarius
2206917Smarius/*
3206917Smarius===============================================================================
4206917Smarius
5206917SmariusThis C source file is part of TestFloat, Release 2a, a package of programs
6206917Smariusfor testing the correctness of floating-point arithmetic complying to the
7206917SmariusIEC/IEEE Standard for Floating-Point.
8206917Smarius
9206917SmariusWritten by John R. Hauser.  More information is available through the Web
10206917Smariuspage `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11206917Smarius
12206917SmariusTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
13206917Smariushas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14206917SmariusTIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
15206917SmariusPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16206917SmariusAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17206917Smarius
18206917SmariusDerivative works are acceptable, even for commercial purposes, so long as
19206917Smarius(1) they include prominent notice that the work is derivative, and (2) they
20206917Smariusinclude prominent notice akin to these four paragraphs for those parts of
21206917Smariusthis code that are retained.
22206917Smarius
23206917Smarius===============================================================================
24206917Smarius*/
25206917Smarius
26207151Smarius#include <sys/cdefs.h>
27207151Smarius__FBSDID("$FreeBSD$");
28207151Smarius
29206917Smarius#include <stdlib.h>
30206917Smarius#include "milieu.h"
31206917Smarius#include "random.h"
32206917Smarius
33206917Smariusuint8 randomUint8( void )
34206917Smarius{
35206917Smarius
36207151Smarius    return (bits8) ( random()>>4 );
37206917Smarius
38206917Smarius}
39206917Smarius
40206917Smariusuint16 randomUint16( void )
41206917Smarius{
42206917Smarius
43207151Smarius    return ( random() & 0x0000ffff );
44206917Smarius
45206917Smarius}
46206917Smarius
47206917Smariusuint32 randomUint32( void )
48206917Smarius{
49206917Smarius
50207151Smarius    return ( ( (uint32) random()<<16) | ( (uint32) random() & 0x0000ffff) );
51206917Smarius}
52206917Smarius
53206917Smarius#ifdef BITS64
54206917Smarius
55206917Smariusuint64 randomUint64( void )
56206917Smarius{
57206917Smarius
58206917Smarius    return ( ( (uint64) randomUint32() )<<32 ) | randomUint32();
59206917Smarius
60206917Smarius}
61206917Smarius
62206917Smarius#endif
63206917Smarius
64