1 | /* fptest.h |
---|
2 | * |
---|
3 | * This include file contains the CPU dependent implementation |
---|
4 | * of the following routines needed to test RTEMS floating |
---|
5 | * point support: |
---|
6 | * FP_load( &context ) |
---|
7 | * FP_check( &context ) |
---|
8 | * |
---|
9 | * FP_load - loads the specified floating point context |
---|
10 | * FP_check - checks the specified floating point context |
---|
11 | * |
---|
12 | * NOTE: These routines are VERY CPU dependent and are thus |
---|
13 | * located in in the CPU dependent include file |
---|
14 | * fptest.h. These routines form the core of the |
---|
15 | * floating point context switch test. |
---|
16 | * |
---|
17 | * COPYRIGHT (c) 1989-1999. |
---|
18 | * On-Line Applications Research Corporation (OAR). |
---|
19 | * |
---|
20 | * The license and distribution terms for this file may be |
---|
21 | * found in the file LICENSE in this distribution or at |
---|
22 | * http://www.rtems.org/license/LICENSE. |
---|
23 | */ |
---|
24 | |
---|
25 | |
---|
26 | #ifndef __FPTEST_h |
---|
27 | #define __FPTEST_h |
---|
28 | |
---|
29 | #include <stdio.h> |
---|
30 | |
---|
31 | #ifndef CPU_HARDWARE_FP |
---|
32 | #error "This CPU does not have CPU_HARDWARE_FP defined" |
---|
33 | #endif |
---|
34 | |
---|
35 | #if ( CPU_HARDWARE_FP == FALSE ) |
---|
36 | |
---|
37 | #define FP_DECLARE |
---|
38 | #define FP_LOAD( _factor ) |
---|
39 | #define FP_CHECK( _factor ) 0 |
---|
40 | |
---|
41 | #else |
---|
42 | |
---|
43 | #define FP_DECLARE \ |
---|
44 | double fp01 = 1.0; \ |
---|
45 | double fp02 = 2.0; \ |
---|
46 | double fp03 = 3.0; \ |
---|
47 | double fp04 = 4.0; \ |
---|
48 | double fp05 = 5.0; \ |
---|
49 | double fp06 = 6.0; \ |
---|
50 | double fp07 = 7.0; \ |
---|
51 | double fp08 = 8.0; \ |
---|
52 | double fp09 = 9.0; \ |
---|
53 | double fp10 = 10.0; \ |
---|
54 | double fp11 = 11.0; \ |
---|
55 | double fp12 = 12.0; \ |
---|
56 | double fp13 = 13.0; \ |
---|
57 | double fp14 = 14.0; \ |
---|
58 | double fp15 = 15.0; \ |
---|
59 | double fp16 = 16.0; \ |
---|
60 | double fp17 = 17.0; \ |
---|
61 | double fp18 = 18.0; \ |
---|
62 | double fp19 = 19.0; \ |
---|
63 | double fp20 = 20.0; \ |
---|
64 | double fp21 = 21.0; \ |
---|
65 | double fp22 = 22.0; \ |
---|
66 | double fp23 = 23.0; \ |
---|
67 | double fp24 = 24.0; \ |
---|
68 | double fp25 = 25.0; \ |
---|
69 | double fp26 = 26.0; \ |
---|
70 | double fp27 = 27.0; \ |
---|
71 | double fp28 = 28.0; \ |
---|
72 | double fp29 = 29.0; \ |
---|
73 | double fp30 = 30.0; \ |
---|
74 | double fp31 = 31.0; \ |
---|
75 | double fp32 = 32.0 |
---|
76 | |
---|
77 | #define FP_LOAD( _factor ) \ |
---|
78 | do { \ |
---|
79 | fp01 += _factor; \ |
---|
80 | fp02 += _factor; \ |
---|
81 | fp03 += _factor; \ |
---|
82 | fp04 += _factor; \ |
---|
83 | fp05 += _factor; \ |
---|
84 | fp06 += _factor; \ |
---|
85 | fp07 += _factor; \ |
---|
86 | fp08 += _factor; \ |
---|
87 | fp09 += _factor; \ |
---|
88 | fp10 += _factor; \ |
---|
89 | fp11 += _factor; \ |
---|
90 | fp12 += _factor; \ |
---|
91 | fp13 += _factor; \ |
---|
92 | fp14 += _factor; \ |
---|
93 | fp15 += _factor; \ |
---|
94 | fp16 += _factor; \ |
---|
95 | fp17 += _factor; \ |
---|
96 | fp18 += _factor; \ |
---|
97 | fp19 += _factor; \ |
---|
98 | fp20 += _factor; \ |
---|
99 | fp21 += _factor; \ |
---|
100 | fp22 += _factor; \ |
---|
101 | fp23 += _factor; \ |
---|
102 | fp24 += _factor; \ |
---|
103 | fp25 += _factor; \ |
---|
104 | fp26 += _factor; \ |
---|
105 | fp27 += _factor; \ |
---|
106 | fp28 += _factor; \ |
---|
107 | fp29 += _factor; \ |
---|
108 | fp30 += _factor; \ |
---|
109 | fp31 += _factor; \ |
---|
110 | fp32 += _factor; \ |
---|
111 | } while (0) |
---|
112 | |
---|
113 | #define EPSILON (0.0005) |
---|
114 | #define FPABS(d) (((d) < 0.0) ? -(d) : (d)) |
---|
115 | #define FPNEQ(a,b) (FPABS((a)-(b)) > EPSILON) |
---|
116 | |
---|
117 | #define FP_CHECK_ONE( _v, _base, _factor ) \ |
---|
118 | if ( FPNEQ( (_v), ((_base) + (_factor)) ) ) { \ |
---|
119 | printf("%" PRIu32 ": " #_v " wrong -- (%g not %g)\n", \ |
---|
120 | task_index, (_v), (_base + _factor)); \ |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | #define FP_CHECK( _factor ) \ |
---|
125 | do { \ |
---|
126 | FP_CHECK_ONE( fp01, 1.0, (_factor) ); \ |
---|
127 | FP_CHECK_ONE( fp02, 2.0, (_factor) ); \ |
---|
128 | FP_CHECK_ONE( fp03, 3.0, (_factor) ); \ |
---|
129 | FP_CHECK_ONE( fp04, 4.0, (_factor) ); \ |
---|
130 | FP_CHECK_ONE( fp05, 5.0, (_factor) ); \ |
---|
131 | FP_CHECK_ONE( fp06, 6.0, (_factor) ); \ |
---|
132 | FP_CHECK_ONE( fp07, 7.0, (_factor) ); \ |
---|
133 | FP_CHECK_ONE( fp08, 8.0, (_factor) ); \ |
---|
134 | FP_CHECK_ONE( fp09, 9.0, (_factor) ); \ |
---|
135 | FP_CHECK_ONE( fp10, 10.0, (_factor) ); \ |
---|
136 | FP_CHECK_ONE( fp11, 11.0, (_factor) ); \ |
---|
137 | FP_CHECK_ONE( fp12, 12.0, (_factor) ); \ |
---|
138 | FP_CHECK_ONE( fp13, 13.0, (_factor) ); \ |
---|
139 | FP_CHECK_ONE( fp14, 14.0, (_factor) ); \ |
---|
140 | FP_CHECK_ONE( fp15, 15.0, (_factor) ); \ |
---|
141 | FP_CHECK_ONE( fp16, 16.0, (_factor) ); \ |
---|
142 | FP_CHECK_ONE( fp17, 17.0, (_factor) ); \ |
---|
143 | FP_CHECK_ONE( fp18, 18.0, (_factor) ); \ |
---|
144 | FP_CHECK_ONE( fp19, 19.0, (_factor) ); \ |
---|
145 | FP_CHECK_ONE( fp20, 20.0, (_factor) ); \ |
---|
146 | FP_CHECK_ONE( fp21, 21.0, (_factor) ); \ |
---|
147 | FP_CHECK_ONE( fp22, 22.0, (_factor) ); \ |
---|
148 | FP_CHECK_ONE( fp23, 23.0, (_factor) ); \ |
---|
149 | FP_CHECK_ONE( fp24, 24.0, (_factor) ); \ |
---|
150 | FP_CHECK_ONE( fp25, 25.0, (_factor) ); \ |
---|
151 | FP_CHECK_ONE( fp26, 26.0, (_factor) ); \ |
---|
152 | FP_CHECK_ONE( fp27, 27.0, (_factor) ); \ |
---|
153 | FP_CHECK_ONE( fp28, 28.0, (_factor) ); \ |
---|
154 | FP_CHECK_ONE( fp29, 29.0, (_factor) ); \ |
---|
155 | FP_CHECK_ONE( fp30, 30.0, (_factor) ); \ |
---|
156 | FP_CHECK_ONE( fp31, 31.0, (_factor) ); \ |
---|
157 | FP_CHECK_ONE( fp32, 32.0, (_factor) ); \ |
---|
158 | } while (0) |
---|
159 | |
---|
160 | #endif |
---|
161 | |
---|
162 | #endif |
---|