math: add nextafter*, nextoward* and scalb to gen
[libc-test] / src / math / gen / mplibm.c
1 #include "gen.h"
2
3 #include <stdio.h>
4 static int mpf1(struct t *s, float (*f)(float))
5 {
6         s->dy = 0;
7         setupfenv(s->r);
8         s->y = f(s->x);
9         s->e = getexcept();
10         return 0;
11 }
12
13 static int mpf2(struct t *s, float (*f)(float,float))
14 {
15         s->dy = 0;
16         setupfenv(s->r);
17         s->y = f(s->x, s->x2);
18         s->e = getexcept();
19         return 0;
20 }
21
22 static int mpd1(struct t *s, double (*f)(double))
23 {
24         s->dy = 0;
25         setupfenv(s->r);
26         s->y = f(s->x);
27         s->e = getexcept();
28 //printf("%La %d\n", s->y, s->e);
29         return 0;
30 }
31
32 static int mpd2(struct t *s, double (*f)(double, double))
33 {
34         s->dy = 0;
35         setupfenv(s->r);
36         s->y = f(s->x, s->x2);
37         s->e = getexcept();
38         return 0;
39 }
40
41 static int mpl1(struct t *s, long double (*f)(long double))
42 {
43         s->dy = 0;
44         setupfenv(s->r);
45         s->y = f(s->x);
46         s->e = getexcept();
47         return 0;
48 }
49
50 static int mpl2(struct t *s, long double (*f)(long double, long double))
51 {
52         setupfenv(s->r);
53         s->y = f(s->x, s->x2);
54         s->dy = 0;
55         s->e = getexcept();
56         return 0;
57 }
58
59
60 int mpacos(struct t *t) { return mpd1(t, acos); }
61 int mpacosf(struct t *t) { return mpf1(t, acosf); }
62 int mpacosl(struct t *t) { return mpl1(t, acosl); }
63 int mpacosh(struct t *t) { return mpd1(t, acosh); }
64 int mpacoshf(struct t *t) { return mpf1(t, acoshf); }
65 int mpacoshl(struct t *t) { return mpl1(t, acoshl); }
66 int mpasin(struct t *t) { return mpd1(t, asin); }
67 int mpasinf(struct t *t) { return mpf1(t, asinf); }
68 int mpasinl(struct t *t) { return mpl1(t, asinl); }
69 int mpasinh(struct t *t) { return mpd1(t, asinh); }
70 int mpasinhf(struct t *t) { return mpf1(t, asinhf); }
71 int mpasinhl(struct t *t) { return mpl1(t, asinhl); }
72 int mpatan(struct t *t) { return mpd1(t, atan); }
73 int mpatanf(struct t *t) { return mpf1(t, atanf); }
74 int mpatanl(struct t *t) { return mpl1(t, atanl); }
75 int mpatan2(struct t *t) { return mpd2(t, atan2); }
76 int mpatan2f(struct t *t) { return mpf2(t, atan2f); }
77 int mpatan2l(struct t *t) { return mpl2(t, atan2l); }
78 int mpatanh(struct t *t) { return mpd1(t, atanh); }
79 int mpatanhf(struct t *t) { return mpf1(t, atanhf); }
80 int mpatanhl(struct t *t) { return mpl1(t, atanhl); }
81 int mpcbrt(struct t *t) { return mpd1(t, cbrt); }
82 int mpcbrtf(struct t *t) { return mpf1(t, cbrtf); }
83 int mpcbrtl(struct t *t) { return mpl1(t, cbrtl); }
84 int mpceil(struct t *t) { return mpd1(t, ceil); }
85 int mpceilf(struct t *t) { return mpf1(t, ceilf); }
86 int mpceill(struct t *t) { return mpl1(t, ceill); }
87 int mpcopysign(struct t *t) { return mpd2(t, copysign); }
88 int mpcopysignf(struct t *t) { return mpf2(t, copysignf); }
89 int mpcopysignl(struct t *t) { return mpl2(t, copysignl); }
90 int mpcos(struct t *t) { return mpd1(t, cos); }
91 int mpcosf(struct t *t) { return mpf1(t, cosf); }
92 int mpcosl(struct t *t) { return mpl1(t, cosl); }
93 int mpcosh(struct t *t) { return mpd1(t, cosh); }
94 int mpcoshf(struct t *t) { return mpf1(t, coshf); }
95 int mpcoshl(struct t *t) { return mpl1(t, coshl); }
96 int mperf(struct t *t) { return mpd1(t, erf); }
97 int mperff(struct t *t) { return mpf1(t, erff); }
98 int mperfl(struct t *t) { return mpl1(t, erfl); }
99 int mperfc(struct t *t) { return mpd1(t, erfc); }
100 int mperfcf(struct t *t) { return mpf1(t, erfcf); }
101 int mperfcl(struct t *t) { return mpl1(t, erfcl); }
102 int mpexp(struct t *t) { return mpd1(t, exp); }
103 int mpexpf(struct t *t) { return mpf1(t, expf); }
104 int mpexpl(struct t *t) { return mpl1(t, expl); }
105 int mpexp2(struct t *t) { return mpd1(t, exp2); }
106 int mpexp2f(struct t *t) { return mpf1(t, exp2f); }
107 int mpexp2l(struct t *t) { return mpl1(t, exp2l); }
108 int mpexpm1(struct t *t) { return mpd1(t, expm1); }
109 int mpexpm1f(struct t *t) { return mpf1(t, expm1f); }
110 int mpexpm1l(struct t *t) { return mpl1(t, expm1l); }
111 int mpfabs(struct t *t) { return mpd1(t, fabs); }
112 int mpfabsf(struct t *t) { return mpf1(t, fabsf); }
113 int mpfabsl(struct t *t) { return mpl1(t, fabsl); }
114 int mpfdim(struct t *t) { return mpd2(t, fdim); }
115 int mpfdimf(struct t *t) { return mpf2(t, fdimf); }
116 int mpfdiml(struct t *t) { return mpl2(t, fdiml); }
117 int mpfloor(struct t *t) { return mpd1(t, floor); }
118 int mpfloorf(struct t *t) { return mpf1(t, floorf); }
119 int mpfloorl(struct t *t) { return mpl1(t, floorl); }
120 int mpfmax(struct t *t) { return mpd2(t, fmax); }
121 int mpfmaxf(struct t *t) { return mpf2(t, fmaxf); }
122 int mpfmaxl(struct t *t) { return mpl2(t, fmaxl); }
123 int mpfmin(struct t *t) { return mpd2(t, fmin); }
124 int mpfminf(struct t *t) { return mpf2(t, fminf); }
125 int mpfminl(struct t *t) { return mpl2(t, fminl); }
126 int mpfmod(struct t *t) { return mpd2(t, fmod); }
127 int mpfmodf(struct t *t) { return mpf2(t, fmodf); }
128 int mpfmodl(struct t *t) { return mpl2(t, fmodl); }
129 int mphypot(struct t *t) { return mpd2(t, hypot); }
130 int mphypotf(struct t *t) { return mpf2(t, hypotf); }
131 int mphypotl(struct t *t) { return mpl2(t, hypotl); }
132 int mplog(struct t *t) { return mpd1(t, log); }
133 int mplogf(struct t *t) { return mpf1(t, logf); }
134 int mplogl(struct t *t) { return mpl1(t, logl); }
135 int mplog10(struct t *t) { return mpd1(t, log10); }
136 int mplog10f(struct t *t) { return mpf1(t, log10f); }
137 int mplog10l(struct t *t) { return mpl1(t, log10l); }
138 int mplog1p(struct t *t) { return mpd1(t, log1p); }
139 int mplog1pf(struct t *t) { return mpf1(t, log1pf); }
140 int mplog1pl(struct t *t) { return mpl1(t, log1pl); }
141 int mplog2(struct t *t) { return mpd1(t, log2); }
142 int mplog2f(struct t *t) { return mpf1(t, log2f); }
143 int mplog2l(struct t *t) { return mpl1(t, log2l); }
144 int mplogb(struct t *t) { return mpd1(t, logb); }
145 int mplogbf(struct t *t) { return mpf1(t, logbf); }
146 int mplogbl(struct t *t) { return mpl1(t, logbl); }
147 int mpnearbyint(struct t *t) { return mpd1(t, nearbyint); }
148 int mpnearbyintf(struct t *t) { return mpf1(t, nearbyintf); }
149 int mpnearbyintl(struct t *t) { return mpl1(t, nearbyintl); }
150 int mpnextafter(struct t *t) { return mpd2(t, nextafter); }
151 int mpnextafterf(struct t *t) { return mpf2(t, nextafterf); }
152 int mpnextafterl(struct t *t) { return mpl2(t, nextafterl); }
153 int mpnexttoward(struct t *t)
154 {
155         feclearexcept(FE_ALL_EXCEPT);
156         t->y = nexttoward(t->x, t->x2);
157         t->e = getexcept();
158         t->dy = 0;
159         return 0;
160 }
161 int mpnexttowardf(struct t *t)
162 {
163         feclearexcept(FE_ALL_EXCEPT);
164         t->y = nexttowardf(t->x, t->x2);
165         t->e = getexcept();
166         t->dy = 0;
167         return 0;
168 }
169 int mpnexttowardl(struct t *t) { return mpl2(t, nexttowardl); }
170 int mppow(struct t *t) { return mpd2(t, pow); }
171 int mppowf(struct t *t) { return mpf2(t, powf); }
172 int mppowl(struct t *t) { return mpl2(t, powl); }
173 int mpremainder(struct t *t) { return mpd2(t, remainder); }
174 int mpremainderf(struct t *t) { return mpf2(t, remainderf); }
175 int mpremainderl(struct t *t) { return mpl2(t, remainderl); }
176 int mprint(struct t *t) { return mpd1(t, rint); }
177 int mprintf(struct t *t) { return mpf1(t, rintf); }
178 int mprintl(struct t *t) { return mpl1(t, rintl); }
179 int mpround(struct t *t) { return mpd1(t, round); }
180 int mproundf(struct t *t) { return mpf1(t, roundf); }
181 int mproundl(struct t *t) { return mpl1(t, roundl); }
182 int mpsin(struct t *t) { return mpd1(t, sin); }
183 int mpsinf(struct t *t) { return mpf1(t, sinf); }
184 int mpsinl(struct t *t) { return mpl1(t, sinl); }
185 int mpsinh(struct t *t) { return mpd1(t, sinh); }
186 int mpsinhf(struct t *t) { return mpf1(t, sinhf); }
187 int mpsinhl(struct t *t) { return mpl1(t, sinhl); }
188 int mpsqrt(struct t *t) { return mpd1(t, sqrt); }
189 int mpsqrtf(struct t *t) { return mpf1(t, sqrtf); }
190 int mpsqrtl(struct t *t) { return mpl1(t, sqrtl); }
191 int mptan(struct t *t) { return mpd1(t, tan); }
192 int mptanf(struct t *t) { return mpf1(t, tanf); }
193 int mptanl(struct t *t) { return mpl1(t, tanl); }
194 int mptanh(struct t *t) { return mpd1(t, tanh); }
195 int mptanhf(struct t *t) { return mpf1(t, tanhf); }
196 int mptanhl(struct t *t) { return mpl1(t, tanhl); }
197 int mptgamma(struct t *t) { return mpd1(t, tgamma); }
198 int mptgammaf(struct t *t) { return mpf1(t, tgammaf); }
199 int mptgammal(struct t *t) { return mpl1(t, tgammal); }
200 int mptrunc(struct t *t) { return mpd1(t, trunc); }
201 int mptruncf(struct t *t) { return mpf1(t, truncf); }
202 int mptruncl(struct t *t) { return mpl1(t, truncl); }
203 int mpj0(struct t *t) { return mpd1(t, j0); }
204 int mpj1(struct t *t) { return mpd1(t, j1); }
205 int mpy0(struct t *t) { return mpd1(t, y0); }
206 int mpy1(struct t *t) { return mpd1(t, y1); }
207 int mpscalb(struct t *t) { return mpd2(t, scalb); }
208 int mpscalbf(struct t *t) { return mpf2(t, scalbf); }
209 int mpj0f(struct t *t) { return mpf1(t, j0f); }
210 int mpj0l(struct t *t) { return -1;}//mpl1(t, j0l); }
211 int mpj1f(struct t *t) { return mpf1(t, j1f); }
212 int mpj1l(struct t *t) { return -1;}//mpl1(t, j1l); }
213 int mpy0f(struct t *t) { return mpf1(t, y0f); }
214 int mpy0l(struct t *t) { return -1;}//mpl1(t, y0l); }
215 int mpy1f(struct t *t) { return mpf1(t, y1f); }
216 int mpy1l(struct t *t) { return -1;}//mpl1(t, y1l); }
217 int mpexp10(struct t *t) { return mpd1(t, exp10); }
218 int mpexp10f(struct t *t) { return mpf1(t, exp10f); }
219 int mpexp10l(struct t *t) { return mpl1(t, exp10l); }
220 int mppow10(struct t *t) { return mpd1(t, pow10); }
221 int mppow10f(struct t *t) { return mpf1(t, pow10f); }
222 int mppow10l(struct t *t) { return mpl1(t, pow10l); }
223
224 int mpfrexp(struct t *t)
225 {
226         int i;
227
228         t->dy = 0;
229         setupfenv(t->r);
230         t->y = frexp(t->x, &i);
231         t->e = getexcept();
232         t->i = i;
233         return 0;
234 }
235
236 int mpfrexpf(struct t *t)
237 {
238         int i;
239
240         t->dy = 0;
241         setupfenv(t->r);
242         t->y = frexpf(t->x, &i);
243         t->e = getexcept();
244         t->i = i;
245         return 0;
246 }
247
248 int mpfrexpl(struct t *t)
249 {
250         int i;
251
252         t->dy = 0;
253         setupfenv(t->r);
254         t->y = frexpl(t->x, &i);
255         t->e = getexcept();
256         t->i = i;
257         return 0;
258 }
259
260 int mpldexp(struct t *t)
261 {
262         t->dy = 0;
263         setupfenv(t->r);
264         t->y = ldexp(t->x, t->i);
265         t->e = getexcept();
266         return 0;
267 }
268
269 int mpldexpf(struct t *t)
270 {
271         t->dy = 0;
272         setupfenv(t->r);
273         t->y = ldexpf(t->x, t->i);
274         t->e = getexcept();
275         return 0;
276 }
277
278 int mpldexpl(struct t *t)
279 {
280         t->dy = 0;
281         setupfenv(t->r);
282         t->y = ldexpl(t->x, t->i);
283         t->e = getexcept();
284         return 0;
285 }
286
287 int mpscalbn(struct t *t)
288 {
289         t->dy = 0;
290         setupfenv(t->r);
291         t->y = scalbn(t->x, t->i);
292         t->e = getexcept();
293         return 0;
294 }
295
296 int mpscalbnf(struct t *t)
297 {
298         t->dy = 0;
299         setupfenv(t->r);
300         t->y = scalbnf(t->x, t->i);
301         t->e = getexcept();
302         return 0;
303 }
304
305 int mpscalbnl(struct t *t)
306 {
307         t->dy = 0;
308         setupfenv(t->r);
309         t->y = scalbnl(t->x, t->i);
310         t->e = getexcept();
311         return 0;
312 }
313
314 int mpscalbln(struct t *t)
315 {
316         t->dy = 0;
317         setupfenv(t->r);
318         t->y = scalbln(t->x, t->i);
319         t->e = getexcept();
320         return 0;
321 }
322
323 int mpscalblnf(struct t *t)
324 {
325         t->dy = 0;
326         setupfenv(t->r);
327         t->y = scalblnf(t->x, t->i);
328         t->e = getexcept();
329         return 0;
330 }
331
332 int mpscalblnl(struct t *t)
333 {
334         t->dy = 0;
335         setupfenv(t->r);
336         t->y = scalblnl(t->x, t->i);
337         t->e = getexcept();
338         return 0;
339 }
340
341 int mplgamma(struct t *t)
342 {
343         t->dy = 0;
344         setupfenv(t->r);
345         t->y = lgamma(t->x);
346         t->e = getexcept();
347         t->i = signgam;
348         return 0;
349 }
350
351 int mplgammaf(struct t *t)
352 {
353         t->dy = 0;
354         setupfenv(t->r);
355         t->y = lgammaf(t->x);
356         t->e = getexcept();
357         t->i = signgam;
358         return 0;
359 }
360
361 int mplgammal(struct t *t)
362 {
363         t->dy = 0;
364         setupfenv(t->r);
365         t->y = lgammal(t->x);
366         t->e = getexcept();
367         t->i = signgam;
368         return 0;
369 }
370
371 int mplgamma_r(struct t *t)
372 {
373         int i;
374
375         t->dy = 0;
376         setupfenv(t->r);
377         t->y = lgamma_r(t->x, &i);
378         t->e = getexcept();
379         t->i = i;
380         return 0;
381 }
382
383 int mplgammaf_r(struct t *t)
384 {
385         int i;
386
387         t->dy = 0;
388         setupfenv(t->r);
389         t->y = lgammaf_r(t->x, &i);
390         t->e = getexcept();
391         t->i = i;
392         return 0;
393 }
394
395 int mplgammal_r(struct t *t)
396 {
397         int i;
398
399         t->dy = 0;
400         setupfenv(t->r);
401         t->y = lgammal_r(t->x, &i);
402         t->e = getexcept();
403         t->i = i;
404         return 0;
405 }
406
407 int mpilogb(struct t *t)
408 {
409         setupfenv(t->r);
410         t->i = ilogb(t->x);
411         t->e = getexcept();
412         return 0;
413 }
414 int mpilogbf(struct t *t)
415 {
416         setupfenv(t->r);
417         t->i = ilogbf(t->x);
418         t->e = getexcept();
419         return 0;
420 }
421 int mpilogbl(struct t *t)
422 {
423         setupfenv(t->r);
424         t->i = ilogbl(t->x);
425         t->e = getexcept();
426         return 0;
427 }
428