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 RTEMS_HAS_HARDWARE_FP |
---|
32 | #error "This CPU does not have RTEMS_HAS_HARDWARE_FP defined" |
---|
33 | #endif |
---|
34 | |
---|
35 | #if ( RTEMS_HAS_HARDWARE_FP == FALSE ) |
---|
36 | |
---|
37 | /* |
---|
38 | * The following is useless except to avoid some warnings. |
---|
39 | */ |
---|
40 | |
---|
41 | #define FP_DECLARE unsigned int fp01 = 0; |
---|
42 | #define FP_LOAD( _factor ) fp01 = 2; |
---|
43 | #define FP_CHECK( _factor ) \ |
---|
44 | if ( fp01 != 2 ) \ |
---|
45 | printf("%" PRIu32 ": single integer is wrong -- (%d != 2) \n", \ |
---|
46 | task_index, fp01 ); \ |
---|
47 | |
---|
48 | #else |
---|
49 | |
---|
50 | #define FP_DECLARE \ |
---|
51 | double fp01 = 1.0; \ |
---|
52 | double fp02 = 2.0; \ |
---|
53 | double fp03 = 3.0; \ |
---|
54 | double fp04 = 4.0; \ |
---|
55 | double fp05 = 5.0; \ |
---|
56 | double fp06 = 6.0; \ |
---|
57 | double fp07 = 7.0; \ |
---|
58 | double fp08 = 8.0; \ |
---|
59 | double fp09 = 9.0; \ |
---|
60 | double fp10 = 10.0; \ |
---|
61 | double fp11 = 11.0; \ |
---|
62 | double fp12 = 12.0; \ |
---|
63 | double fp13 = 13.0; \ |
---|
64 | double fp14 = 14.0; \ |
---|
65 | double fp15 = 15.0; \ |
---|
66 | double fp16 = 16.0; \ |
---|
67 | double fp17 = 17.0; \ |
---|
68 | double fp18 = 18.0; \ |
---|
69 | double fp19 = 19.0; \ |
---|
70 | double fp20 = 20.0; \ |
---|
71 | double fp21 = 21.0; \ |
---|
72 | double fp22 = 22.0; \ |
---|
73 | double fp23 = 23.0; \ |
---|
74 | double fp24 = 24.0; \ |
---|
75 | double fp25 = 25.0; \ |
---|
76 | double fp26 = 26.0; \ |
---|
77 | double fp27 = 27.0; \ |
---|
78 | double fp28 = 28.0; \ |
---|
79 | double fp29 = 29.0; \ |
---|
80 | double fp30 = 30.0; \ |
---|
81 | double fp31 = 31.0; \ |
---|
82 | double fp32 = 32.0 |
---|
83 | |
---|
84 | #define FP_LOAD( _factor ) \ |
---|
85 | do { \ |
---|
86 | fp01 += _factor; \ |
---|
87 | fp02 += _factor; \ |
---|
88 | fp03 += _factor; \ |
---|
89 | fp04 += _factor; \ |
---|
90 | fp05 += _factor; \ |
---|
91 | fp06 += _factor; \ |
---|
92 | fp07 += _factor; \ |
---|
93 | fp08 += _factor; \ |
---|
94 | fp09 += _factor; \ |
---|
95 | fp10 += _factor; \ |
---|
96 | fp11 += _factor; \ |
---|
97 | fp12 += _factor; \ |
---|
98 | fp13 += _factor; \ |
---|
99 | fp14 += _factor; \ |
---|
100 | fp15 += _factor; \ |
---|
101 | fp16 += _factor; \ |
---|
102 | fp17 += _factor; \ |
---|
103 | fp18 += _factor; \ |
---|
104 | fp19 += _factor; \ |
---|
105 | fp20 += _factor; \ |
---|
106 | fp21 += _factor; \ |
---|
107 | fp22 += _factor; \ |
---|
108 | fp23 += _factor; \ |
---|
109 | fp24 += _factor; \ |
---|
110 | fp25 += _factor; \ |
---|
111 | fp26 += _factor; \ |
---|
112 | fp27 += _factor; \ |
---|
113 | fp28 += _factor; \ |
---|
114 | fp29 += _factor; \ |
---|
115 | fp30 += _factor; \ |
---|
116 | fp31 += _factor; \ |
---|
117 | fp32 += _factor; \ |
---|
118 | } while (0) |
---|
119 | |
---|
120 | #define EPSILON (0.0005) |
---|
121 | #define FPABS(d) (((d) < 0.0) ? -(d) : (d)) |
---|
122 | #define FPNEQ(a,b) (FPABS((a)-(b)) > EPSILON) |
---|
123 | |
---|
124 | #define FP_CHECK_ONE( _v, _base, _factor ) \ |
---|
125 | if ( FPNEQ( (_v), ((_base) + (_factor)) ) ) { \ |
---|
126 | printf("%" PRIu32 ": " #_v " wrong -- (%g not %g)\n", \ |
---|
127 | task_index, (_v), (_base + _factor)); \ |
---|
128 | } |
---|
129 | |
---|
130 | |
---|
131 | #define FP_CHECK( _factor ) \ |
---|
132 | do { \ |
---|
133 | FP_CHECK_ONE( fp01, 1.0, (_factor) ); \ |
---|
134 | FP_CHECK_ONE( fp02, 2.0, (_factor) ); \ |
---|
135 | FP_CHECK_ONE( fp03, 3.0, (_factor) ); \ |
---|
136 | FP_CHECK_ONE( fp04, 4.0, (_factor) ); \ |
---|
137 | FP_CHECK_ONE( fp05, 5.0, (_factor) ); \ |
---|
138 | FP_CHECK_ONE( fp06, 6.0, (_factor) ); \ |
---|
139 | FP_CHECK_ONE( fp07, 7.0, (_factor) ); \ |
---|
140 | FP_CHECK_ONE( fp08, 8.0, (_factor) ); \ |
---|
141 | FP_CHECK_ONE( fp09, 9.0, (_factor) ); \ |
---|
142 | FP_CHECK_ONE( fp10, 10.0, (_factor) ); \ |
---|
143 | FP_CHECK_ONE( fp11, 11.0, (_factor) ); \ |
---|
144 | FP_CHECK_ONE( fp12, 12.0, (_factor) ); \ |
---|
145 | FP_CHECK_ONE( fp13, 13.0, (_factor) ); \ |
---|
146 | FP_CHECK_ONE( fp14, 14.0, (_factor) ); \ |
---|
147 | FP_CHECK_ONE( fp15, 15.0, (_factor) ); \ |
---|
148 | FP_CHECK_ONE( fp16, 16.0, (_factor) ); \ |
---|
149 | FP_CHECK_ONE( fp17, 17.0, (_factor) ); \ |
---|
150 | FP_CHECK_ONE( fp18, 18.0, (_factor) ); \ |
---|
151 | FP_CHECK_ONE( fp19, 19.0, (_factor) ); \ |
---|
152 | FP_CHECK_ONE( fp20, 20.0, (_factor) ); \ |
---|
153 | FP_CHECK_ONE( fp21, 21.0, (_factor) ); \ |
---|
154 | FP_CHECK_ONE( fp22, 22.0, (_factor) ); \ |
---|
155 | FP_CHECK_ONE( fp23, 23.0, (_factor) ); \ |
---|
156 | FP_CHECK_ONE( fp24, 24.0, (_factor) ); \ |
---|
157 | FP_CHECK_ONE( fp25, 25.0, (_factor) ); \ |
---|
158 | FP_CHECK_ONE( fp26, 26.0, (_factor) ); \ |
---|
159 | FP_CHECK_ONE( fp27, 27.0, (_factor) ); \ |
---|
160 | FP_CHECK_ONE( fp28, 28.0, (_factor) ); \ |
---|
161 | FP_CHECK_ONE( fp29, 29.0, (_factor) ); \ |
---|
162 | FP_CHECK_ONE( fp30, 30.0, (_factor) ); \ |
---|
163 | FP_CHECK_ONE( fp31, 31.0, (_factor) ); \ |
---|
164 | FP_CHECK_ONE( fp32, 32.0, (_factor) ); \ |
---|
165 | } while (0) |
---|
166 | |
---|
167 | #endif |
---|
168 | |
---|
169 | #endif |
---|