]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/test/testfloat/random.c
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / test / testfloat / random.c
1
2 /*
3 ===============================================================================
4
5 This C source file is part of TestFloat, Release 2a, a package of programs
6 for testing the correctness of floating-point arithmetic complying to the
7 IEC/IEEE Standard for Floating-Point.
8
9 Written by John R. Hauser.  More information is available through the Web
10 page `http://HTTP.CS.Berkeley.EDU/~jhauser/arithmetic/TestFloat.html'.
11
12 THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
13 has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
14 TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
15 PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY
16 AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE.
17
18 Derivative works are acceptable, even for commercial purposes, so long as
19 (1) they include prominent notice that the work is derivative, and (2) they
20 include prominent notice akin to these four paragraphs for those parts of
21 this code that are retained.
22
23 ===============================================================================
24 */
25
26 #include <sys/cdefs.h>
27 __FBSDID("$FreeBSD$");
28
29 #include <stdlib.h>
30 #include "milieu.h"
31 #include "random.h"
32
33 uint8 randomUint8( void )
34 {
35
36     return (bits8) ( random()>>4 );
37
38 }
39
40 uint16 randomUint16( void )
41 {
42
43     return ( random() & 0x0000ffff );
44
45 }
46
47 uint32 randomUint32( void )
48 {
49
50     return ( ( (uint32) random()<<16) | ( (uint32) random() & 0x0000ffff) );
51 }
52
53 #ifdef BITS64
54
55 uint64 randomUint64( void )
56 {
57
58     return ( ( (uint64) randomUint32() )<<32 ) | randomUint32();
59
60 }
61
62 #endif
63