123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- #ifndef LIBM_TEST_SUPPORT_H
- #define LIBM_TEST_SUPPORT_H 1
- #include <complex.h>
- #include <math.h>
- #include <float.h>
- #include <fenv.h>
- #include <limits.h>
- #include <stdlib.h>
- #include <stdint.h>
- #include <stdio.h>
- #include <tininess.h>
- #include <math-tests.h>
- #include <nan-high-order-bit.h>
- extern const int flag_test_errno;
- extern const int flag_test_exceptions;
- extern const int flag_test_finite;
- extern const int flag_test_inline;
- extern const int flag_test_mathvec;
- extern const int snan_tests_arg;
- extern const char test_msg[];
- extern const char qtype_str[];
- extern const char doc[];
- #define NO_EXCEPTION 0x0
- #define INVALID_EXCEPTION 0x1
- #define DIVIDE_BY_ZERO_EXCEPTION 0x2
- #define OVERFLOW_EXCEPTION 0x4
- #define UNDERFLOW_EXCEPTION 0x8
- #define INEXACT_EXCEPTION 0x10
- #define INVALID_EXCEPTION_OK 0x20
- #define DIVIDE_BY_ZERO_EXCEPTION_OK 0x40
- #define OVERFLOW_EXCEPTION_OK 0x80
- #define UNDERFLOW_EXCEPTION_OK 0x100
- #define NO_INEXACT_EXCEPTION 0x200
- #define IGNORE_ZERO_INF_SIGN 0x400
- #define TEST_NAN_SIGN 0x800
- #define TEST_NAN_PAYLOAD 0x1000
- #define NO_TEST_INLINE 0x2000
- #define XFAIL_TEST 0x4000
- #define ERRNO_UNCHANGED 0x8000
- #define ERRNO_EDOM 0x10000
- #define ERRNO_ERANGE 0x20000
- #define IGNORE_RESULT 0x40000
- #define NON_FINITE 0x80000
- #define TEST_SNAN 0x100000
- #define NO_TEST_MATHVEC 0x200000
- #define __CONCATX(a,b) __CONCAT(a,b)
- #define TYPE_MIN __CONCATX (PREFIX, _MIN)
- #define TYPE_TRUE_MIN __CONCATX (PREFIX, _TRUE_MIN)
- #define TYPE_MAX __CONCATX (PREFIX, _MAX)
- #define MIN_EXP __CONCATX (PREFIX, _MIN_EXP)
- #define MAX_EXP __CONCATX (PREFIX, _MAX_EXP)
- #define MANT_DIG __CONCATX (PREFIX, _MANT_DIG)
- #define ARG_TYPE_MIN __CONCATX (ARG_PREFIX, _MIN)
- #define ARG_TYPE_TRUE_MIN __CONCATX (ARG_PREFIX, _TRUE_MIN)
- #define ARG_TYPE_MAX __CONCATX (ARG_PREFIX, _MAX)
- #define ARG_MIN_EXP __CONCATX (ARG_PREFIX, _MIN_EXP)
- #define ARG_MAX_EXP __CONCATX (ARG_PREFIX, _MAX_EXP)
- #define ARG_MANT_DIG __CONCATX (ARG_PREFIX, _MANT_DIG)
- #define TEST_COND_binary32 (MANT_DIG == 24 \
- && MIN_EXP == -125 \
- && MAX_EXP == 128)
- #define TEST_COND_binary64 (MANT_DIG == 53 \
- && MIN_EXP == -1021 \
- && MAX_EXP == 1024)
- #define TEST_COND_binary128 (MANT_DIG == 113 \
- && MIN_EXP == -16381 \
- && MAX_EXP == 16384)
- #define TEST_COND_ibm128 (MANT_DIG == 106)
- #define TEST_COND_arg_ibm128 (ARG_MANT_DIG == 106)
- #define TEST_COND_intel96 (MANT_DIG == 64 \
- && MIN_EXP == -16381 \
- && MAX_EXP == 16384)
- #define TEST_COND_m68k96 (MANT_DIG == 64 \
- && MIN_EXP == -16382 \
- && MAX_EXP == 16384)
- #ifdef ARG_FLOAT
- # define TEST_COND_ibm128_libgcc (TEST_COND_ibm128 || TEST_COND_arg_ibm128)
- #else
- # define TEST_COND_ibm128_libgcc TEST_COND_ibm128
- #endif
- #define XFAIL_IBM128_LIBGCC (TEST_COND_ibm128_libgcc ? XFAIL_TEST : 0)
- #if ((defined __x86_64__ || defined __i386__ || defined __ia64__) \
- && !__GNUC_PREREQ (7, 0))
- # define XFAIL_FLOAT128_PAYLOAD (TEST_COND_binary128 ? XFAIL_TEST : 0)
- #else
- # define XFAIL_FLOAT128_PAYLOAD 0
- #endif
- #if TEST_COND_ibm128
- # define PAYLOAD_DIG (DBL_MANT_DIG - 2)
- #else
- # define PAYLOAD_DIG (MANT_DIG - 2)
- #endif
- #define TEST_COND_arg_fmt(MAX_EXP, NUM_ONES, MIN_EXP, MAX_PREC) \
- (((MAX_EXP) < ARG_MAX_EXP) \
- && (!TEST_COND_arg_ibm128 \
- || (MAX_EXP) < ARG_MAX_EXP - 1 \
- || (NUM_ONES) <= 53) \
- && (MIN_EXP) >= ARG_MIN_EXP - ARG_MANT_DIG \
- && (MAX_PREC) <= ARG_MANT_DIG)
- #define UNDERFLOW_EXCEPTION_BEFORE_ROUNDING (TININESS_AFTER_ROUNDING \
- ? 0 \
- : UNDERFLOW_EXCEPTION)
- #if LONG_MAX == 0x7fffffff
- # define TEST_COND_long32 1
- # define TEST_COND_long64 0
- #else
- # define TEST_COND_long32 0
- # define TEST_COND_long64 1
- #endif
- #define TEST_COND_before_rounding (!TININESS_AFTER_ROUNDING)
- #define TEST_COND_after_rounding TININESS_AFTER_ROUNDING
- int enable_test (int);
- void init_max_error (const char *, int, int);
- void print_max_error (const char *);
- void print_complex_max_error (const char *);
- void check_float (const char *, FLOAT, FLOAT, int);
- void check_complex (const char *, CFLOAT, CFLOAT, int);
- void check_int (const char *, int, int, int);
- void check_long (const char *, long int, long int, int);
- void check_bool (const char *, int, int, int);
- void check_longlong (const char *, long long int, long long int, int);
- void check_intmax_t (const char *, intmax_t, intmax_t, int);
- void check_uintmax_t (const char *, uintmax_t, uintmax_t, int);
- void libm_test_init (int, char **);
- int libm_test_finish (void);
- #endif
|