random.c revision 207151
1221828Sgrehan
2221828Sgrehan/*
3221828Sgrehan===============================================================================
4221828Sgrehan
5221828SgrehanThis C source file is part of TestFloat, Release 2a, a package of programs
6221828Sgrehanfor testing the correctness of floating-point arithmetic complying to the
7221828SgrehanIEC/IEEE Standard for Floating-Point.
8221828Sgrehan
9221828SgrehanWritten by John R. Hauser.  More information is available through the Web
10221828Sgrehanpage `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11221828Sgrehan
12221828SgrehanTHIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
13221828Sgrehanhas been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14221828SgrehanTIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
15221828SgrehanPERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16221828SgrehanAND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17221828Sgrehan
18221828SgrehanDerivative works are acceptable, even for commercial purposes, so long as
19221828Sgrehan(1) they include prominent notice that the work is derivative, and (2) they
20221828Sgrehaninclude prominent notice akin to these four paragraphs for those parts of
21221828Sgrehanthis code that are retained.
22221828Sgrehan
23221828Sgrehan===============================================================================
24221828Sgrehan*/
25221828Sgrehan
26221828Sgrehan#include <sys/cdefs.h>
27221828Sgrehan__FBSDID("$FreeBSD: head/tools/test/testfloat/random.c 207151 2010-04-24 12:11:41Z marius $");
28221828Sgrehan
29221828Sgrehan#include <stdlib.h>
30221828Sgrehan#include "milieu.h"
31221828Sgrehan#include "random.h"
32221828Sgrehan
33221828Sgrehanuint8 randomUint8( void )
34221828Sgrehan{
35256072Sneel
36256072Sneel    return (bits8) ( random()>>4 );
37256072Sneel
38221828Sgrehan}
39221828Sgrehan
40256072Sneeluint16 randomUint16( void )
41221828Sgrehan{
42256072Sneel
43256072Sneel    return ( random() & 0x0000ffff );
44241362Sneel
45256072Sneel}
46221828Sgrehan
47221828Sgrehanuint32 randomUint32( void )
48221828Sgrehan{
49221828Sgrehan
50221828Sgrehan    return ( ( (uint32) random()<<16) | ( (uint32) random() & 0x0000ffff) );
51221828Sgrehan}
52221828Sgrehan
53221828Sgrehan#ifdef BITS64
54221828Sgrehan
55221828Sgrehanuint64 randomUint64( void )
56221828Sgrehan{
57221828Sgrehan
58256072Sneel    return ( ( (uint64) randomUint32() )<<32 ) | randomUint32();
59256072Sneel
60256072Sneel}
61221828Sgrehan
62256072Sneel#endif
63256072Sneel
64256072Sneel