1 /* 2 * Copyright (c) 1994 Cygnus Support. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * and/or other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * at Cygnus Support, Inc. Cygnus Support, Inc. may not be used to 11 * endorse or promote products derived from this software without 12 * specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 #define _GNU_SOURCE 18 #define HAVE_FLOAT 1 19 #define X(x) (char *)x 20 21 #include <math.h> 22 #include <float.h> 23 //#include <ieeefp.h> 24 #include <stdio.h> 25 #include <stdint.h> 26 27 /* FIXME FIXME FIXME: 28 Neither of __ieee_{float,double}_shape_type seem to be used anywhere 29 except in libm/test. If that is the case, please delete these from here. 30 If that is not the case, please insert documentation here describing why 31 they're needed. */ 32 33 #ifdef __IEEE_BIG_ENDIAN 34 35 typedef union 36 { 37 double value; 38 struct 39 { 40 unsigned int sign : 1; 41 unsigned int exponent: 11; 42 unsigned int fraction0:4; 43 unsigned int fraction1:16; 44 unsigned int fraction2:16; 45 unsigned int fraction3:16; 46 47 } number; 48 struct 49 { 50 unsigned int sign : 1; 51 unsigned int exponent: 11; 52 unsigned int quiet:1; 53 unsigned int function0:3; 54 unsigned int function1:16; 55 unsigned int function2:16; 56 unsigned int function3:16; 57 } nan; 58 struct 59 { 60 uint32_t msw; 61 uint32_t lsw; 62 } parts; 63 int32_t aslong[2]; 64 } __ieee_double_shape_type; 65 66 #else 67 68 typedef union 69 { 70 double value; 71 struct 72 { 73 #ifdef __SMALL_BITFIELDS 74 unsigned int fraction3:16; 75 unsigned int fraction2:16; 76 unsigned int fraction1:16; 77 unsigned int fraction0: 4; 78 #else 79 unsigned int fraction1:32; 80 unsigned int fraction0:20; 81 #endif 82 unsigned int exponent :11; 83 unsigned int sign : 1; 84 } number; 85 struct 86 { 87 #ifdef __SMALL_BITFIELDS 88 unsigned int function3:16; 89 unsigned int function2:16; 90 unsigned int function1:16; 91 unsigned int function0:3; 92 #else 93 unsigned int function1:32; 94 unsigned int function0:19; 95 #endif 96 unsigned int quiet:1; 97 unsigned int exponent: 11; 98 unsigned int sign : 1; 99 } nan; 100 struct 101 { 102 uint32_t lsw; 103 uint32_t msw; 104 } parts; 105 106 int32_t aslong[2]; 107 108 } __ieee_double_shape_type; 109 110 #endif /* __IEEE_LITTLE_ENDIAN */ 111 112 #ifdef __IEEE_BIG_ENDIAN 113 114 typedef union 115 { 116 float value; 117 struct 118 { 119 unsigned int sign : 1; 120 unsigned int exponent: 8; 121 unsigned int fraction0: 7; 122 unsigned int fraction1: 16; 123 } number; 124 struct 125 { 126 unsigned int sign:1; 127 unsigned int exponent:8; 128 unsigned int quiet:1; 129 unsigned int function0:6; 130 unsigned int function1:16; 131 } nan; 132 uint32_t p1; 133 134 } __ieee_float_shape_type; 135 136 #else 137 138 typedef union 139 { 140 float value; 141 struct 142 { 143 unsigned int fraction0: 7; 144 unsigned int fraction1: 16; 145 unsigned int exponent: 8; 146 unsigned int sign : 1; 147 } number; 148 struct 149 { 150 unsigned int function1:16; 151 unsigned int function0:6; 152 unsigned int quiet:1; 153 unsigned int exponent:8; 154 unsigned int sign:1; 155 } nan; 156 int32_t p1; 157 158 } __ieee_float_shape_type; 159 160 #endif /* __IEEE_LITTLE_ENDIAN */ 161 162 extern int inacc; 163 extern int redo; 164 extern int reduce; 165 extern int verbose; 166 167 void checkf(); 168 void enter(); 169 170 171 double translate_from(); 172 173 typedef struct 174 { 175 uint32_t msw, lsw; 176 } question_struct_type; 177 178 179 typedef struct 180 { 181 char error_bit; 182 char errno_val; 183 char merror; 184 int line; 185 186 question_struct_type qs[3]; 187 } one_line_type; 188 189 190 #define MVEC_START(x) one_line_type x[] = { 191 #define MVEC_END 0,}; 192 193 194 int mag_of_error (double, double); 195 int fmag_of_error (float, float); 196 197 198 #define ERROR_PERFECT 20 199 #define ERROR_FAIL -1 200 201 #define AAAA 15 202 #define AAA 10 203 #define AA 6 204 #define A 5 205 #define B 3 206 #define C 1 207 #define VECOPEN(x,f) \ 208 {\ 209 char buffer[100];\ 210 sprintf(buffer,"%s_vec.c",x);\ 211 f = fopen(buffer,"w");\ 212 fprintf(f,"#include \"test.h\"\n");\ 213 fprintf(f," one_line_type %s_vec[] = {\n", x);\ 214 } 215 216 #define VECCLOSE(f,name,args)\ 217 {\ 218 fprintf(f,"0,};\n"); \ 219 fprintf(f,"test_%s(int m) {run_vector_1(m,%s_vec,(char *)(%s),\"%s\",\"%s\"); } \n",\ 220 name,\ 221 name,name,name,args);\ 222 fclose(f);\ 223 } 224 225 226 227 typedef struct 228 { 229 int line; 230 231 char *string; 232 double value; 233 int endscan; 234 } double_type; 235 236 #define ENDSCAN_MASK 0x7f 237 #define ENDSCAN_IS_ZERO 0x80 238 #define ENDSCAN_IS_INF 0x80 239 240 typedef struct { 241 long int value; 242 char end; 243 char errno_val; 244 } int_scan_type; 245 246 typedef struct 247 { 248 int line; 249 int_scan_type octal; 250 int_scan_type decimal; 251 int_scan_type hex; 252 int_scan_type normal; 253 int_scan_type alphabetical; 254 char *string; 255 } int_type; 256 257 258 typedef struct 259 { 260 int line; 261 double value; 262 char *estring; 263 int e1; 264 int e2; 265 int e3; 266 char *fstring; 267 int f1; 268 int f2; 269 int f3; 270 char *gstring; 271 int g1; 272 char *gfstring; 273 } ddouble_type; 274 275 typedef struct 276 { 277 int line; 278 double value; 279 char *result; 280 char *format_string; 281 int mag; 282 } sprint_double_type; 283 284 285 typedef struct 286 { 287 int line; 288 int value; 289 char *result; 290 char *format_string; 291 } sprint_int_type; 292 293 294 void test_ieee (void); 295 void test_math2 (void); 296 void test_math (int vector); 297 void test_string (void); 298 void test_is (void); 299 void test_cvt (void); 300 301 void line (int); 302 303 void test_mok (double, double, int); 304 void test_mfok (float, float, int); 305 void test_iok (int, int); 306 void test_eok (int, int); 307 void test_sok (char *, char*); 308 void test_scok (char *, char*, int); 309 void test_scok2 (char *, char*, char*, int); 310 void newfunc (const char *); 311 312 void 313 run_vector_1 (int vector, 314 one_line_type *p, 315 char *func, 316 char *name, 317 char *args); 318 void 319 test_acos(int vector); 320 321 void 322 test_acosf(int vector); 323 324 void 325 test_acosh(int vector); 326 327 void 328 test_acoshf(int vector); 329 330 void 331 test_asin(int vector); 332 333 void 334 test_asinf(int vector); 335 336 void 337 test_asinh(int vector); 338 339 void 340 test_asinhf(int vector); 341 342 void 343 test_atan(int vector); 344 345 void 346 test_atan2(int vector); 347 348 void 349 test_atan2f(int vector); 350 351 void 352 test_atanf(int vector); 353 354 void 355 test_atanh(int vector); 356 357 void 358 test_atanhf(int vector); 359 360 void 361 test_ceil(int vector); 362 363 void 364 test_ceilf(int vector); 365 366 void 367 test_copysign(int vector); 368 369 void 370 test_copysignf(int vector); 371 372 void 373 test_cos(int vector); 374 375 void 376 test_cosf(int vector); 377 378 void 379 test_cosh(int vector); 380 381 void 382 test_coshf(int vector); 383 384 void 385 test_erf(int vector); 386 387 void 388 test_erfc(int vector); 389 390 void 391 test_erfcf(int vector); 392 393 void 394 test_erff(int vector); 395 396 void 397 test_exp(int vector); 398 399 void 400 test_expf(int vector); 401 402 void 403 test_fabs(int vector); 404 405 void 406 test_fabsf(int vector); 407 408 void 409 test_floor(int vector); 410 411 void 412 test_floorf(int vector); 413 414 void 415 test_fmod(int vector); 416 417 void 418 test_fmodf(int vector); 419 420 void 421 test_gamma(int vector); 422 423 void 424 test_gammaf(int vector); 425 426 void 427 test_hypot(int vector); 428 429 void 430 test_hypotf(int vector); 431 432 void 433 test_issignaling(int vector); 434 435 void 436 test_j0(int vector); 437 438 void 439 test_j0f(int vector); 440 441 void 442 test_j1(int vector); 443 444 void 445 test_j1f(int vector); 446 447 void 448 test_jn(int vector); 449 450 void 451 test_jnf(int vector); 452 453 void 454 test_log(int vector); 455 456 void 457 test_log10(int vector); 458 459 void 460 test_log10f(int vector); 461 462 void 463 test_log1p(int vector); 464 465 void 466 test_log1pf(int vector); 467 468 void 469 test_log2(int vector); 470 471 void 472 test_log2f(int vector); 473 474 void 475 test_logf(int vector); 476 477 void 478 test_modf(int vector); 479 480 void 481 test_modff(int vector); 482 483 void 484 test_pow_vec(int vector); 485 486 void 487 test_powf_vec(int vector); 488 489 void 490 test_scalb(int vector); 491 492 void 493 test_scalbf(int vector); 494 495 void 496 test_scalbn(int vector); 497 498 void 499 test_scalbnf(int vector); 500 501 void 502 test_sin(int vector); 503 504 void 505 test_sinf(int vector); 506 507 void 508 test_sinh(int vector); 509 510 void 511 test_sinhf(int vector); 512 513 void 514 test_sqrt(int vector); 515 516 void 517 test_sqrtf(int vector); 518 519 void 520 test_tan(int vector); 521 522 void 523 test_tanf(int vector); 524 525 void 526 test_tanh(int vector); 527 528 void 529 test_tanhf(int vector); 530 531 void 532 test_trunc(int vector); 533 534 void 535 test_truncf(int vector); 536 537 void 538 test_y0(int vector); 539 540 void 541 test_y0f(int vector); 542 543 void 544 test_y1(int vector); 545 546 void 547 test_y1f(int vector); 548 549 void 550 test_y1f(int vector); 551 552 void 553 test_ynf(int vector); 554 555