Changes in uspace/app/tester/float/softfloat1.c [000494d:c0f8909] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/float/softfloat1.c
r000494d rc0f8909 34 34 #include <mul.h> 35 35 #include <div.h> 36 #include <comparison.h> 36 37 #include <bool.h> 37 38 #include "../tester.h" … … 45 46 typedef void (* float_op_t)(float, float, float *, float_t *); 46 47 typedef void (* double_op_t)(double, double, double *, double_t *); 48 typedef void (* double_cmp_op_t)(double, double, cmptype_t *, cmptype_t *); 47 49 typedef void (* template_t)(void *, unsigned, unsigned, cmptype_t *, 48 50 cmptype_t *); … … 66 68 67 69 return -a; 70 } 71 72 static int dcmp(double a, double b) 73 { 74 if (a < b) 75 return -1; 76 else if (a > b) 77 return 1; 78 79 return 0; 68 80 } 69 81 … … 96 108 *pic = (cmptype_t) (c * PRECISION); 97 109 *pisc = (cmptype_t) (sc.val * PRECISION); 110 } 111 112 static void 113 double_compare_template(void *f, unsigned i, unsigned j, cmptype_t *pis, 114 cmptype_t *piss) 115 { 116 double_cmp_op_t op = (double_cmp_op_t) f; 117 118 op(dop_a[i], dop_b[j], pis, piss); 98 119 } 99 120 … … 221 242 } 222 243 244 static void 245 double_cmp_operator(double a, double b, cmptype_t *pis, cmptype_t *piss) 246 { 247 *pis = dcmp(a, b); 248 249 double_t sa; 250 double_t sb; 251 252 sa.val = a; 253 sb.val = b; 254 255 if (is_double_lt(sa.data, sb.data)) 256 *piss = -1; 257 else if (is_double_gt(sa.data, sb.data)) 258 *piss = 1; 259 else if (is_double_eq(sa.data, sb.data)) 260 *piss = 0; 261 else 262 *piss = 42; 263 } 264 223 265 const char *test_softfloat1(void) 224 266 { … … 249 291 TPRINTF("%s\n", err); 250 292 } 293 if (!test_template(double_compare_template, double_cmp_operator)) { 294 err = "Double comparison failed"; 295 TPRINTF("%s\n", err); 296 } 251 297 252 298 return err;
Note:
See TracChangeset
for help on using the changeset viewer.