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