xref: /freebsd/contrib/arm-optimized-routines/math/test/rtest/intern.h (revision 072a4ba82a01476eaee33781ccd241033eefcf0b)
131914882SAlex Richardson /*
231914882SAlex Richardson  * intern.h
331914882SAlex Richardson  *
431914882SAlex Richardson  * Copyright (c) 1999-2019, Arm Limited.
5*072a4ba8SAndrew Turner  * SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception
631914882SAlex Richardson  */
731914882SAlex Richardson 
831914882SAlex Richardson #ifndef mathtest_intern_h
931914882SAlex Richardson #define mathtest_intern_h
1031914882SAlex Richardson 
1131914882SAlex Richardson #include <mpfr.h>
1231914882SAlex Richardson #include <mpc.h>
1331914882SAlex Richardson 
1431914882SAlex Richardson #include "types.h"
1531914882SAlex Richardson #include "wrappers.h"
1631914882SAlex Richardson 
1731914882SAlex Richardson /* Generic function pointer. */
1831914882SAlex Richardson typedef void (*funcptr)(void);
1931914882SAlex Richardson 
2031914882SAlex Richardson /* Pointers to test function types. */
2131914882SAlex Richardson typedef int    (*testfunc1)(mpfr_t, mpfr_t, mpfr_rnd_t);
2231914882SAlex Richardson typedef int    (*testfunc2)(mpfr_t, mpfr_t, mpfr_t, mpfr_rnd_t);
2331914882SAlex Richardson typedef int    (*testrred)(mpfr_t, mpfr_t, int *);
2431914882SAlex Richardson typedef char * (*testsemi1)(uint32 *, uint32 *);
2531914882SAlex Richardson typedef char * (*testsemi2)(uint32 *, uint32 *, uint32 *);
2631914882SAlex Richardson typedef char * (*testsemi2f)(uint32 *, uint32 *, uint32 *);
2731914882SAlex Richardson typedef char * (*testldexp)(uint32 *, uint32 *, uint32 *);
2831914882SAlex Richardson typedef char * (*testfrexp)(uint32 *, uint32 *, uint32 *);
2931914882SAlex Richardson typedef char * (*testmodf)(uint32 *, uint32 *, uint32 *);
3031914882SAlex Richardson typedef char * (*testclassify)(uint32 *, uint32 *);
3131914882SAlex Richardson typedef char * (*testclassifyf)(uint32 *, uint32 *);
3231914882SAlex Richardson 
3331914882SAlex Richardson typedef int    (*testfunc1c)(mpc_t, mpc_t, mpc_rnd_t);
3431914882SAlex Richardson typedef int    (*testfunc2c)(mpc_t, mpc_t, mpc_t, mpc_rnd_t);
3531914882SAlex Richardson 
3631914882SAlex Richardson typedef int    (*testfunc1cr)(mpfr_t, mpc_t, mpfr_rnd_t);
3731914882SAlex Richardson 
3831914882SAlex Richardson /* Pointer to a function that generates random test cases. */
3931914882SAlex Richardson typedef void (*casegen)(uint32 *, uint32, uint32);
4031914882SAlex Richardson 
4131914882SAlex Richardson /*
4231914882SAlex Richardson  * List of testable functions, their types, and their testable range.
4331914882SAlex Richardson  */
4431914882SAlex Richardson enum {
4531914882SAlex Richardson     args1,                             /* afloat-based, one argument */
4631914882SAlex Richardson     args1f,                            /* same as args1 but in single prec */
4731914882SAlex Richardson     args2,                             /* afloat-based, two arguments */
4831914882SAlex Richardson     args2f,                            /* same as args2 but in single prec */
4931914882SAlex Richardson     rred,                              /* afloat-based, one arg, aux return */
5031914882SAlex Richardson     rredf,                             /* same as rred but in single prec */
5131914882SAlex Richardson     semi1,                             /* seminumerical, one argument */
5231914882SAlex Richardson     semi1f,                            /* seminumerical, 1 arg, float */
5331914882SAlex Richardson     semi2,                             /* seminumerical, two arguments */
5431914882SAlex Richardson     semi2f,                            /* seminumerical, 2 args, floats */
5531914882SAlex Richardson     t_ldexp,                           /* dbl * int -> dbl */
5631914882SAlex Richardson     t_ldexpf,                          /* sgl * int -> sgl */
5731914882SAlex Richardson     t_frexp,                           /* dbl -> dbl * int */
5831914882SAlex Richardson     t_frexpf,                          /* sgl -> sgl * int */
5931914882SAlex Richardson     t_modf,                            /* dbl -> dbl * dbl */
6031914882SAlex Richardson     t_modff,                           /* sgl -> sgl * sgl */
6131914882SAlex Richardson     classify,                          /* classify double: dbl -> int */
6231914882SAlex Richardson     classifyf,                         /* classify float: flt -> int */
6331914882SAlex Richardson     compare,                           /* compare doubles, returns int */
6431914882SAlex Richardson     comparef,                          /* compare floats, returns int */
6531914882SAlex Richardson 
6631914882SAlex Richardson     args1c,                            /* acomplex-base, one argument */
6731914882SAlex Richardson     args2c,
6831914882SAlex Richardson     args1fc,
6931914882SAlex Richardson     args2fc,
7031914882SAlex Richardson     args1cr,                           /* dbl-complex -> complex */
7131914882SAlex Richardson     args1fcr                           /* sgl-complex -> complex */
7231914882SAlex Richardson };
7331914882SAlex Richardson 
7431914882SAlex Richardson typedef struct __testable Testable;
7531914882SAlex Richardson struct __testable {
7631914882SAlex Richardson     char *name;
7731914882SAlex Richardson     funcptr func;
7831914882SAlex Richardson     int type;
7931914882SAlex Richardson     wrapperfunc wrappers[MAXWRAPPERS];
8031914882SAlex Richardson     casegen cases; /* complex functions use the same casegen for both real and complex args */
8131914882SAlex Richardson     uint32 caseparam1, caseparam2;
8231914882SAlex Richardson };
8331914882SAlex Richardson 
8431914882SAlex Richardson extern Testable functions[];
8531914882SAlex Richardson extern const int nfunctions;
8631914882SAlex Richardson 
8731914882SAlex Richardson extern void init_pi(void);
8831914882SAlex Richardson 
8931914882SAlex Richardson int nargs_(Testable* f);
9031914882SAlex Richardson 
9131914882SAlex Richardson #endif
92