PandA-2024.02
libm-test.c
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2021-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
33 
34 #define _GNU_SOURCE
35 #include <math.h>
36 #include <stdlib.h>
37 
38 #if !defined(TEST_FLOAT) && !defined(TEST_DOUBLE)
39 #error Floating-point type test should be defined
40 #endif
41 
42 #ifdef TEST_FLOAT
43 #define F_TEST_F(func) \
44  FLOAT func##f_test(FLOAT a) \
45  { \
46  return func##f(a); \
47  }
48 
49 #define I_TEST_F(func) \
50  int func##f_test(FLOAT a) \
51  { \
52  return func##f(a); \
53  }
54 
55 #define F_TEST_FF(func) \
56  FLOAT func##f_test(FLOAT a, FLOAT b) \
57  { \
58  return func##f(a, b); \
59  }
60 
61 #define F_TEST_FI(func) \
62  FLOAT func##f_test(FLOAT a, int b) \
63  { \
64  return func##f(a, b); \
65  }
66 
67 #define F_TEST_FIP(func) \
68  FLOAT func##f_test(FLOAT a, int* pb) \
69  { \
70  return func##f(a, pb); \
71  }
72 #endif
73 
74 #ifdef TEST_DOUBLE
75 #define F_TEST_F(func) \
76  FLOAT func##_test(FLOAT a) \
77  { \
78  return func(a); \
79  }
80 
81 #define I_TEST_F(func) \
82  int func##_test(FLOAT a) \
83  { \
84  return func(a); \
85  }
86 
87 #define F_TEST_FF(func) \
88  FLOAT func##_test(FLOAT a, FLOAT b) \
89  { \
90  return func(a, b); \
91  }
92 
93 #define F_TEST_FI(func) \
94  FLOAT func##_test(FLOAT a, int b) \
95  { \
96  return func(a, b); \
97  }
98 
99 #define F_TEST_FIP(func) \
100  FLOAT func##_test(FLOAT a, int* pb) \
101  { \
102  return func(a, pb); \
103  }
104 #endif
105 
106 #define I_MULTITEST_F(func) \
107  int func##_test(FLOAT a) \
108  { \
109  return func(a); \
110  }
111 
112 #define B_MULTITEST_F(func) \
113  _Bool func##_test(FLOAT a) \
114  { \
115  return func(a); \
116  }
117 
118 F_TEST_F(acos)
119 F_TEST_F(acosh)
120 F_TEST_F(asin)
121 F_TEST_F(asinh)
122 F_TEST_F(atan)
123 F_TEST_FF(atan2)
124 F_TEST_F(atanh)
125 F_TEST_F(cbrt)
126 F_TEST_F(ceil)
127 F_TEST_FF(copysign)
128 F_TEST_F(cos)
129 F_TEST_F(cosh)
130 F_TEST_F(erf)
131 F_TEST_F(erfc)
132 F_TEST_F(exp)
133 F_TEST_F(expm1)
134 F_TEST_F(fabs)
135 F_TEST_F(floor)
136 F_TEST_FF(fmod)
137 I_MULTITEST_F(fpclassify)
138 F_TEST_FIP(frexp)
139 
140 FLOAT
141 #if TEST_FLOAT
142 gammaf_test
143 #else
145 #endif
146  (FLOAT a, int* pb)
147 {
148  signgam = 0;
149  FLOAT res;
150  res = FUNC(gamma)(a);
151  *pb = signgam;
152  return res;
153 }
154 
155 F_TEST_FF(hypot)
156 I_TEST_F(ilogb)
157 I_MULTITEST_F(isfinite)
158 I_MULTITEST_F(isnormal)
159 F_TEST_FI(ldexp)
160 
161 FLOAT
162 #if TEST_FLOAT
163 lgammaf_test
164 #else
166 #endif
167  (FLOAT a, int* pb)
168 {
169  signgam = 0;
170  FLOAT res;
171  res = FUNC(lgamma)(a);
172  *pb = signgam;
173  return res;
174 }
175 
176 F_TEST_F(log)
177 F_TEST_F(log1p)
178 F_TEST_F(log10)
179 F_TEST_F(logb)
180 
181 FLOAT
182 #if TEST_FLOAT
183 modff_test
184 #else
185 modf_test
186 #endif
187  (FLOAT a, FLOAT* pb)
188 {
189  return FUNC(modf)(a, pb);
190 }
191 
192 F_TEST_FF(pow)
193 F_TEST_FF(remainder)
194 F_TEST_F(rint)
195 F_TEST_FF(scalb)
196 F_TEST_FI(scalbn)
197 B_MULTITEST_F(signbit)
198 F_TEST_F(significand)
199 F_TEST_F(sin)
200 
201 void
202 #if TEST_FLOAT
203 sincosf_test
204 #else
206 #endif
207  (FLOAT a, FLOAT* pb, FLOAT* pc)
208 {
209  return FUNC(sincos)(a, pb, pc);
210 }
211 
212 F_TEST_F(sinh)
213 F_TEST_F(sqrt)
214 F_TEST_F(tan)
215 F_TEST_F(tanh)
216 F_TEST_F(tgamma)
FLOAT modf_test(FLOAT a, FLOAT *pb)
Definition: libm-test.c:187
#define FLOAT
Definition: test-float.c:35
#define I_MULTITEST_F(func)
Definition: libm-test.c:106
FLOAT lgamma_test(FLOAT a, int *pb)
Definition: libm-test.c:167
#define B_MULTITEST_F(func)
Definition: libm-test.c:112
FLOAT gamma_test(FLOAT a, int *pb)
Definition: libm-test.c:146
#define FUNC(n, i)
Definition: sha.c:46
uint32_t exp
void sincos_test(FLOAT a, FLOAT *pb, FLOAT *pc)
Definition: libm-test.c:207

Generated on Mon Feb 12 2024 13:02:49 for PandA-2024.02 by doxygen 1.8.13