xref: /third_party/musl/libc-test/src/math/gen/mplibm.c (revision 570af302)
1570af302Sopenharmony_ci#include "gen.h"
2570af302Sopenharmony_ci
3570af302Sopenharmony_cistatic int mpf1(struct t *s, float (*f)(float))
4570af302Sopenharmony_ci{
5570af302Sopenharmony_ci	s->dy = 0;
6570af302Sopenharmony_ci	setupfenv(s->r);
7570af302Sopenharmony_ci	s->y = f(s->x);
8570af302Sopenharmony_ci	s->e = getexcept();
9570af302Sopenharmony_ci	return 0;
10570af302Sopenharmony_ci}
11570af302Sopenharmony_ci
12570af302Sopenharmony_cistatic int mpf2(struct t *s, float (*f)(float,float))
13570af302Sopenharmony_ci{
14570af302Sopenharmony_ci	s->dy = 0;
15570af302Sopenharmony_ci	setupfenv(s->r);
16570af302Sopenharmony_ci	s->y = f(s->x, s->x2);
17570af302Sopenharmony_ci	s->e = getexcept();
18570af302Sopenharmony_ci	return 0;
19570af302Sopenharmony_ci}
20570af302Sopenharmony_ci
21570af302Sopenharmony_cistatic int mpd1(struct t *s, double (*f)(double))
22570af302Sopenharmony_ci{
23570af302Sopenharmony_ci	s->dy = 0;
24570af302Sopenharmony_ci	setupfenv(s->r);
25570af302Sopenharmony_ci	s->y = f(s->x);
26570af302Sopenharmony_ci	s->e = getexcept();
27570af302Sopenharmony_ci	return 0;
28570af302Sopenharmony_ci}
29570af302Sopenharmony_ci
30570af302Sopenharmony_cistatic int mpd2(struct t *s, double (*f)(double, double))
31570af302Sopenharmony_ci{
32570af302Sopenharmony_ci	s->dy = 0;
33570af302Sopenharmony_ci	setupfenv(s->r);
34570af302Sopenharmony_ci	s->y = f(s->x, s->x2);
35570af302Sopenharmony_ci	s->e = getexcept();
36570af302Sopenharmony_ci	return 0;
37570af302Sopenharmony_ci}
38570af302Sopenharmony_ci
39570af302Sopenharmony_cistatic int mpl1(struct t *s, long double (*f)(long double))
40570af302Sopenharmony_ci{
41570af302Sopenharmony_ci	s->dy = 0;
42570af302Sopenharmony_ci	setupfenv(s->r);
43570af302Sopenharmony_ci	s->y = f(s->x);
44570af302Sopenharmony_ci	s->e = getexcept();
45570af302Sopenharmony_ci	return 0;
46570af302Sopenharmony_ci}
47570af302Sopenharmony_ci
48570af302Sopenharmony_cistatic int mpl2(struct t *s, long double (*f)(long double, long double))
49570af302Sopenharmony_ci{
50570af302Sopenharmony_ci	setupfenv(s->r);
51570af302Sopenharmony_ci	s->y = f(s->x, s->x2);
52570af302Sopenharmony_ci	s->dy = 0;
53570af302Sopenharmony_ci	s->e = getexcept();
54570af302Sopenharmony_ci	return 0;
55570af302Sopenharmony_ci}
56570af302Sopenharmony_ci
57570af302Sopenharmony_cistatic double sinpi(double x) { return sin(3.141592653589793238*x); }
58570af302Sopenharmony_ciint mpsinpi(struct t *t) { return mpd1(t, sinpi); }
59570af302Sopenharmony_ci
60570af302Sopenharmony_ci
61570af302Sopenharmony_ci#define OP(n,op,t) static t n(t x, t y) { t z = x op y; return z; }
62570af302Sopenharmony_ciOP(add,+,double)
63570af302Sopenharmony_ciOP(addf,+,float)
64570af302Sopenharmony_ciOP(addl,+,long double)
65570af302Sopenharmony_ciOP(mul,*,double)
66570af302Sopenharmony_ciOP(mulf,*,float)
67570af302Sopenharmony_ciOP(mull,*,long double)
68570af302Sopenharmony_ciOP(div,/,double)
69570af302Sopenharmony_ciOP(divf,/,float)
70570af302Sopenharmony_ciOP(divl,/,long double)
71570af302Sopenharmony_ciint mpadd(struct t *t) { return mpd2(t, add); }
72570af302Sopenharmony_ciint mpaddf(struct t *t) { return mpf2(t, addf); }
73570af302Sopenharmony_ciint mpaddl(struct t *t) { return mpl2(t, addl); }
74570af302Sopenharmony_ciint mpmul(struct t *t) { return mpd2(t, mul); }
75570af302Sopenharmony_ciint mpmulf(struct t *t) { return mpf2(t, mulf); }
76570af302Sopenharmony_ciint mpmull(struct t *t) { return mpl2(t, mull); }
77570af302Sopenharmony_ciint mpdiv(struct t *t) { return mpd2(t, div); }
78570af302Sopenharmony_ciint mpdivf(struct t *t) { return mpf2(t, divf); }
79570af302Sopenharmony_ciint mpdivl(struct t *t) { return mpl2(t, divl); }
80570af302Sopenharmony_ci
81570af302Sopenharmony_ciint mpacos(struct t *t) { return mpd1(t, acos); }
82570af302Sopenharmony_ciint mpacosf(struct t *t) { return mpf1(t, acosf); }
83570af302Sopenharmony_ciint mpacosl(struct t *t) { return mpl1(t, acosl); }
84570af302Sopenharmony_ciint mpacosh(struct t *t) { return mpd1(t, acosh); }
85570af302Sopenharmony_ciint mpacoshf(struct t *t) { return mpf1(t, acoshf); }
86570af302Sopenharmony_ciint mpacoshl(struct t *t) { return mpl1(t, acoshl); }
87570af302Sopenharmony_ciint mpasin(struct t *t) { return mpd1(t, asin); }
88570af302Sopenharmony_ciint mpasinf(struct t *t) { return mpf1(t, asinf); }
89570af302Sopenharmony_ciint mpasinl(struct t *t) { return mpl1(t, asinl); }
90570af302Sopenharmony_ciint mpasinh(struct t *t) { return mpd1(t, asinh); }
91570af302Sopenharmony_ciint mpasinhf(struct t *t) { return mpf1(t, asinhf); }
92570af302Sopenharmony_ciint mpasinhl(struct t *t) { return mpl1(t, asinhl); }
93570af302Sopenharmony_ciint mpatan(struct t *t) { return mpd1(t, atan); }
94570af302Sopenharmony_ciint mpatanf(struct t *t) { return mpf1(t, atanf); }
95570af302Sopenharmony_ciint mpatanl(struct t *t) { return mpl1(t, atanl); }
96570af302Sopenharmony_ciint mpatan2(struct t *t) { return mpd2(t, atan2); }
97570af302Sopenharmony_ciint mpatan2f(struct t *t) { return mpf2(t, atan2f); }
98570af302Sopenharmony_ciint mpatan2l(struct t *t) { return mpl2(t, atan2l); }
99570af302Sopenharmony_ciint mpatanh(struct t *t) { return mpd1(t, atanh); }
100570af302Sopenharmony_ciint mpatanhf(struct t *t) { return mpf1(t, atanhf); }
101570af302Sopenharmony_ciint mpatanhl(struct t *t) { return mpl1(t, atanhl); }
102570af302Sopenharmony_ciint mpcbrt(struct t *t) { return mpd1(t, cbrt); }
103570af302Sopenharmony_ciint mpcbrtf(struct t *t) { return mpf1(t, cbrtf); }
104570af302Sopenharmony_ciint mpcbrtl(struct t *t) { return mpl1(t, cbrtl); }
105570af302Sopenharmony_ciint mpceil(struct t *t) { return mpd1(t, ceil); }
106570af302Sopenharmony_ciint mpceilf(struct t *t) { return mpf1(t, ceilf); }
107570af302Sopenharmony_ciint mpceill(struct t *t) { return mpl1(t, ceill); }
108570af302Sopenharmony_ciint mpcopysign(struct t *t) { return mpd2(t, copysign); }
109570af302Sopenharmony_ciint mpcopysignf(struct t *t) { return mpf2(t, copysignf); }
110570af302Sopenharmony_ciint mpcopysignl(struct t *t) { return mpl2(t, copysignl); }
111570af302Sopenharmony_ciint mpcos(struct t *t) { return mpd1(t, cos); }
112570af302Sopenharmony_ciint mpcosf(struct t *t) { return mpf1(t, cosf); }
113570af302Sopenharmony_ciint mpcosl(struct t *t) { return mpl1(t, cosl); }
114570af302Sopenharmony_ciint mpcosh(struct t *t) { return mpd1(t, cosh); }
115570af302Sopenharmony_ciint mpcoshf(struct t *t) { return mpf1(t, coshf); }
116570af302Sopenharmony_ciint mpcoshl(struct t *t) { return mpl1(t, coshl); }
117570af302Sopenharmony_ciint mperf(struct t *t) { return mpd1(t, erf); }
118570af302Sopenharmony_ciint mperff(struct t *t) { return mpf1(t, erff); }
119570af302Sopenharmony_ciint mperfl(struct t *t) { return mpl1(t, erfl); }
120570af302Sopenharmony_ciint mperfc(struct t *t) { return mpd1(t, erfc); }
121570af302Sopenharmony_ciint mperfcf(struct t *t) { return mpf1(t, erfcf); }
122570af302Sopenharmony_ciint mperfcl(struct t *t) { return mpl1(t, erfcl); }
123570af302Sopenharmony_ciint mpexp(struct t *t) { return mpd1(t, exp); }
124570af302Sopenharmony_ciint mpexpf(struct t *t) { return mpf1(t, expf); }
125570af302Sopenharmony_ciint mpexpl(struct t *t) { return mpl1(t, expl); }
126570af302Sopenharmony_ciint mpexp2(struct t *t) { return mpd1(t, exp2); }
127570af302Sopenharmony_ciint mpexp2f(struct t *t) { return mpf1(t, exp2f); }
128570af302Sopenharmony_ciint mpexp2l(struct t *t) { return mpl1(t, exp2l); }
129570af302Sopenharmony_ciint mpexpm1(struct t *t) { return mpd1(t, expm1); }
130570af302Sopenharmony_ciint mpexpm1f(struct t *t) { return mpf1(t, expm1f); }
131570af302Sopenharmony_ciint mpexpm1l(struct t *t) { return mpl1(t, expm1l); }
132570af302Sopenharmony_ciint mpfabs(struct t *t) { return mpd1(t, fabs); }
133570af302Sopenharmony_ciint mpfabsf(struct t *t) { return mpf1(t, fabsf); }
134570af302Sopenharmony_ciint mpfabsl(struct t *t) { return mpl1(t, fabsl); }
135570af302Sopenharmony_ciint mpfdim(struct t *t) { return mpd2(t, fdim); }
136570af302Sopenharmony_ciint mpfdimf(struct t *t) { return mpf2(t, fdimf); }
137570af302Sopenharmony_ciint mpfdiml(struct t *t) { return mpl2(t, fdiml); }
138570af302Sopenharmony_ciint mpfloor(struct t *t) { return mpd1(t, floor); }
139570af302Sopenharmony_ciint mpfloorf(struct t *t) { return mpf1(t, floorf); }
140570af302Sopenharmony_ciint mpfloorl(struct t *t) { return mpl1(t, floorl); }
141570af302Sopenharmony_ciint mpfmax(struct t *t) { return mpd2(t, fmax); }
142570af302Sopenharmony_ciint mpfmaxf(struct t *t) { return mpf2(t, fmaxf); }
143570af302Sopenharmony_ciint mpfmaxl(struct t *t) { return mpl2(t, fmaxl); }
144570af302Sopenharmony_ciint mpfmin(struct t *t) { return mpd2(t, fmin); }
145570af302Sopenharmony_ciint mpfminf(struct t *t) { return mpf2(t, fminf); }
146570af302Sopenharmony_ciint mpfminl(struct t *t) { return mpl2(t, fminl); }
147570af302Sopenharmony_ciint mpfmod(struct t *t) { return mpd2(t, fmod); }
148570af302Sopenharmony_ciint mpfmodf(struct t *t) { return mpf2(t, fmodf); }
149570af302Sopenharmony_ciint mpfmodl(struct t *t) { return mpl2(t, fmodl); }
150570af302Sopenharmony_ciint mphypot(struct t *t) { return mpd2(t, hypot); }
151570af302Sopenharmony_ciint mphypotf(struct t *t) { return mpf2(t, hypotf); }
152570af302Sopenharmony_ciint mphypotl(struct t *t) { return mpl2(t, hypotl); }
153570af302Sopenharmony_ciint mplog(struct t *t) { return mpd1(t, log); }
154570af302Sopenharmony_ciint mplogf(struct t *t) { return mpf1(t, logf); }
155570af302Sopenharmony_ciint mplogl(struct t *t) { return mpl1(t, logl); }
156570af302Sopenharmony_ciint mplog10(struct t *t) { return mpd1(t, log10); }
157570af302Sopenharmony_ciint mplog10f(struct t *t) { return mpf1(t, log10f); }
158570af302Sopenharmony_ciint mplog10l(struct t *t) { return mpl1(t, log10l); }
159570af302Sopenharmony_ciint mplog1p(struct t *t) { return mpd1(t, log1p); }
160570af302Sopenharmony_ciint mplog1pf(struct t *t) { return mpf1(t, log1pf); }
161570af302Sopenharmony_ciint mplog1pl(struct t *t) { return mpl1(t, log1pl); }
162570af302Sopenharmony_ciint mplog2(struct t *t) { return mpd1(t, log2); }
163570af302Sopenharmony_ciint mplog2f(struct t *t) { return mpf1(t, log2f); }
164570af302Sopenharmony_ciint mplog2l(struct t *t) { return mpl1(t, log2l); }
165570af302Sopenharmony_ciint mplogb(struct t *t) { return mpd1(t, logb); }
166570af302Sopenharmony_ciint mplogbf(struct t *t) { return mpf1(t, logbf); }
167570af302Sopenharmony_ciint mplogbl(struct t *t) { return mpl1(t, logbl); }
168570af302Sopenharmony_ciint mpnearbyint(struct t *t) { return mpd1(t, nearbyint); }
169570af302Sopenharmony_ciint mpnearbyintf(struct t *t) { return mpf1(t, nearbyintf); }
170570af302Sopenharmony_ciint mpnearbyintl(struct t *t) { return mpl1(t, nearbyintl); }
171570af302Sopenharmony_ciint mpnextafter(struct t *t) { return mpd2(t, nextafter); }
172570af302Sopenharmony_ciint mpnextafterf(struct t *t) { return mpf2(t, nextafterf); }
173570af302Sopenharmony_ciint mpnextafterl(struct t *t) { return mpl2(t, nextafterl); }
174570af302Sopenharmony_ciint mpnexttoward(struct t *t)
175570af302Sopenharmony_ci{
176570af302Sopenharmony_ci	feclearexcept(FE_ALL_EXCEPT);
177570af302Sopenharmony_ci	t->y = nexttoward(t->x, t->x2);
178570af302Sopenharmony_ci	t->e = getexcept();
179570af302Sopenharmony_ci	t->dy = 0;
180570af302Sopenharmony_ci	return 0;
181570af302Sopenharmony_ci}
182570af302Sopenharmony_ciint mpnexttowardf(struct t *t)
183570af302Sopenharmony_ci{
184570af302Sopenharmony_ci	feclearexcept(FE_ALL_EXCEPT);
185570af302Sopenharmony_ci	t->y = nexttowardf(t->x, t->x2);
186570af302Sopenharmony_ci	t->e = getexcept();
187570af302Sopenharmony_ci	t->dy = 0;
188570af302Sopenharmony_ci	return 0;
189570af302Sopenharmony_ci}
190570af302Sopenharmony_ciint mpnexttowardl(struct t *t) { return mpl2(t, nexttowardl); }
191570af302Sopenharmony_ciint mppow(struct t *t) { return mpd2(t, pow); }
192570af302Sopenharmony_ciint mppowf(struct t *t) { return mpf2(t, powf); }
193570af302Sopenharmony_ciint mppowl(struct t *t) { return mpl2(t, powl); }
194570af302Sopenharmony_ciint mpremainder(struct t *t) { return mpd2(t, remainder); }
195570af302Sopenharmony_ciint mpremainderf(struct t *t) { return mpf2(t, remainderf); }
196570af302Sopenharmony_ciint mpremainderl(struct t *t) { return mpl2(t, remainderl); }
197570af302Sopenharmony_ciint mprint(struct t *t) { return mpd1(t, rint); }
198570af302Sopenharmony_ciint mprintf(struct t *t) { return mpf1(t, rintf); }
199570af302Sopenharmony_ciint mprintl(struct t *t) { return mpl1(t, rintl); }
200570af302Sopenharmony_ciint mpround(struct t *t) { return mpd1(t, round); }
201570af302Sopenharmony_ciint mproundf(struct t *t) { return mpf1(t, roundf); }
202570af302Sopenharmony_ciint mproundl(struct t *t) { return mpl1(t, roundl); }
203570af302Sopenharmony_ciint mpsin(struct t *t) { return mpd1(t, sin); }
204570af302Sopenharmony_ciint mpsinf(struct t *t) { return mpf1(t, sinf); }
205570af302Sopenharmony_ciint mpsinl(struct t *t) { return mpl1(t, sinl); }
206570af302Sopenharmony_ciint mpsinh(struct t *t) { return mpd1(t, sinh); }
207570af302Sopenharmony_ciint mpsinhf(struct t *t) { return mpf1(t, sinhf); }
208570af302Sopenharmony_ciint mpsinhl(struct t *t) { return mpl1(t, sinhl); }
209570af302Sopenharmony_ciint mpsqrt(struct t *t) { return mpd1(t, sqrt); }
210570af302Sopenharmony_ciint mpsqrtf(struct t *t) { return mpf1(t, sqrtf); }
211570af302Sopenharmony_ciint mpsqrtl(struct t *t) { return mpl1(t, sqrtl); }
212570af302Sopenharmony_ciint mptan(struct t *t) { return mpd1(t, tan); }
213570af302Sopenharmony_ciint mptanf(struct t *t) { return mpf1(t, tanf); }
214570af302Sopenharmony_ciint mptanl(struct t *t) { return mpl1(t, tanl); }
215570af302Sopenharmony_ciint mptanh(struct t *t) { return mpd1(t, tanh); }
216570af302Sopenharmony_ciint mptanhf(struct t *t) { return mpf1(t, tanhf); }
217570af302Sopenharmony_ciint mptanhl(struct t *t) { return mpl1(t, tanhl); }
218570af302Sopenharmony_ciint mptgamma(struct t *t) { return mpd1(t, tgamma); }
219570af302Sopenharmony_ciint mptgammaf(struct t *t) { return mpf1(t, tgammaf); }
220570af302Sopenharmony_ciint mptgammal(struct t *t) { return mpl1(t, tgammal); }
221570af302Sopenharmony_ciint mptrunc(struct t *t) { return mpd1(t, trunc); }
222570af302Sopenharmony_ciint mptruncf(struct t *t) { return mpf1(t, truncf); }
223570af302Sopenharmony_ciint mptruncl(struct t *t) { return mpl1(t, truncl); }
224570af302Sopenharmony_ciint mpj0(struct t *t) { return mpd1(t, j0); }
225570af302Sopenharmony_ciint mpj1(struct t *t) { return mpd1(t, j1); }
226570af302Sopenharmony_ciint mpy0(struct t *t) { return mpd1(t, y0); }
227570af302Sopenharmony_ciint mpy1(struct t *t) { return mpd1(t, y1); }
228570af302Sopenharmony_ciint mpscalb(struct t *t) { return mpd2(t, scalb); }
229570af302Sopenharmony_ciint mpscalbf(struct t *t) { return mpf2(t, scalbf); }
230570af302Sopenharmony_ciint mpj0f(struct t *t) { return mpf1(t, j0f); }
231570af302Sopenharmony_ciint mpj0l(struct t *t) { return -1;}//mpl1(t, j0l); }
232570af302Sopenharmony_ciint mpj1f(struct t *t) { return mpf1(t, j1f); }
233570af302Sopenharmony_ciint mpj1l(struct t *t) { return -1;}//mpl1(t, j1l); }
234570af302Sopenharmony_ciint mpy0f(struct t *t) { return mpf1(t, y0f); }
235570af302Sopenharmony_ciint mpy0l(struct t *t) { return -1;}//mpl1(t, y0l); }
236570af302Sopenharmony_ciint mpy1f(struct t *t) { return mpf1(t, y1f); }
237570af302Sopenharmony_ciint mpy1l(struct t *t) { return -1;}//mpl1(t, y1l); }
238570af302Sopenharmony_ciint mpexp10(struct t *t) { return mpd1(t, exp10); }
239570af302Sopenharmony_ciint mpexp10f(struct t *t) { return mpf1(t, exp10f); }
240570af302Sopenharmony_ciint mpexp10l(struct t *t) { return mpl1(t, exp10l); }
241570af302Sopenharmony_ciint mppow10(struct t *t) { return mpd1(t, pow10); }
242570af302Sopenharmony_ciint mppow10f(struct t *t) { return mpf1(t, pow10f); }
243570af302Sopenharmony_ciint mppow10l(struct t *t) { return mpl1(t, pow10l); }
244570af302Sopenharmony_ci
245570af302Sopenharmony_ci#define mp_fi_f(n) \
246570af302Sopenharmony_ciint mp##n(struct t *t) \
247570af302Sopenharmony_ci{ \
248570af302Sopenharmony_ci	t->dy = 0; \
249570af302Sopenharmony_ci	setupfenv(t->r); \
250570af302Sopenharmony_ci	t->y = n(t->x, t->i); \
251570af302Sopenharmony_ci	t->e = getexcept(); \
252570af302Sopenharmony_ci	return 0; \
253570af302Sopenharmony_ci}
254570af302Sopenharmony_ci
255570af302Sopenharmony_cimp_fi_f(ldexp)
256570af302Sopenharmony_cimp_fi_f(ldexpf)
257570af302Sopenharmony_cimp_fi_f(ldexpl)
258570af302Sopenharmony_cimp_fi_f(scalbn)
259570af302Sopenharmony_cimp_fi_f(scalbnf)
260570af302Sopenharmony_cimp_fi_f(scalbnl)
261570af302Sopenharmony_cimp_fi_f(scalbln)
262570af302Sopenharmony_cimp_fi_f(scalblnf)
263570af302Sopenharmony_cimp_fi_f(scalblnl)
264570af302Sopenharmony_ci
265570af302Sopenharmony_ci#define mp_f_fi(n) \
266570af302Sopenharmony_ciint mp##n(struct t *t) \
267570af302Sopenharmony_ci{ \
268570af302Sopenharmony_ci	int i; \
269570af302Sopenharmony_ci	t->dy = 0; \
270570af302Sopenharmony_ci	setupfenv(t->r); \
271570af302Sopenharmony_ci	t->y = n(t->x, &i); \
272570af302Sopenharmony_ci	t->e = getexcept(); \
273570af302Sopenharmony_ci	t->i = i; \
274570af302Sopenharmony_ci	return 0; \
275570af302Sopenharmony_ci}
276570af302Sopenharmony_ci
277570af302Sopenharmony_cimp_f_fi(frexp)
278570af302Sopenharmony_cimp_f_fi(frexpf)
279570af302Sopenharmony_cimp_f_fi(frexpl)
280570af302Sopenharmony_cimp_f_fi(lgamma_r)
281570af302Sopenharmony_cimp_f_fi(lgammaf_r)
282570af302Sopenharmony_cimp_f_fi(lgammal_r)
283570af302Sopenharmony_ci
284570af302Sopenharmony_ciint mplgamma(struct t *t)
285570af302Sopenharmony_ci{
286570af302Sopenharmony_ci	t->dy = 0;
287570af302Sopenharmony_ci	setupfenv(t->r);
288570af302Sopenharmony_ci	t->y = lgamma(t->x);
289570af302Sopenharmony_ci	t->e = getexcept();
290570af302Sopenharmony_ci	t->i = signgam;
291570af302Sopenharmony_ci	return 0;
292570af302Sopenharmony_ci}
293570af302Sopenharmony_ci
294570af302Sopenharmony_ciint mplgammaf(struct t *t)
295570af302Sopenharmony_ci{
296570af302Sopenharmony_ci	t->dy = 0;
297570af302Sopenharmony_ci	setupfenv(t->r);
298570af302Sopenharmony_ci	t->y = lgammaf(t->x);
299570af302Sopenharmony_ci	t->e = getexcept();
300570af302Sopenharmony_ci	t->i = signgam;
301570af302Sopenharmony_ci	return 0;
302570af302Sopenharmony_ci}
303570af302Sopenharmony_ci
304570af302Sopenharmony_ciint mplgammal(struct t *t)
305570af302Sopenharmony_ci{
306570af302Sopenharmony_ci	t->dy = 0;
307570af302Sopenharmony_ci	setupfenv(t->r);
308570af302Sopenharmony_ci	t->y = lgammal(t->x);
309570af302Sopenharmony_ci	t->e = getexcept();
310570af302Sopenharmony_ci	t->i = signgam;
311570af302Sopenharmony_ci	return 0;
312570af302Sopenharmony_ci}
313570af302Sopenharmony_ci
314570af302Sopenharmony_ci#define mp_f_i(n) \
315570af302Sopenharmony_ciint mp##n(struct t *t) \
316570af302Sopenharmony_ci{ \
317570af302Sopenharmony_ci	setupfenv(t->r); \
318570af302Sopenharmony_ci	t->i = n(t->x); \
319570af302Sopenharmony_ci	t->e = getexcept(); \
320570af302Sopenharmony_ci	return 0; \
321570af302Sopenharmony_ci}
322570af302Sopenharmony_ci
323570af302Sopenharmony_cimp_f_i(ilogb)
324570af302Sopenharmony_cimp_f_i(ilogbf)
325570af302Sopenharmony_cimp_f_i(ilogbl)
326570af302Sopenharmony_cimp_f_i(llrint)
327570af302Sopenharmony_cimp_f_i(llrintf)
328570af302Sopenharmony_cimp_f_i(llrintl)
329570af302Sopenharmony_cimp_f_i(lrint)
330570af302Sopenharmony_cimp_f_i(lrintf)
331570af302Sopenharmony_cimp_f_i(lrintl)
332570af302Sopenharmony_cimp_f_i(llround)
333570af302Sopenharmony_cimp_f_i(llroundf)
334570af302Sopenharmony_cimp_f_i(llroundl)
335570af302Sopenharmony_cimp_f_i(lround)
336570af302Sopenharmony_cimp_f_i(lroundf)
337570af302Sopenharmony_cimp_f_i(lroundl)
338570af302Sopenharmony_ci
339570af302Sopenharmony_ciint mpmodf(struct t *t)
340570af302Sopenharmony_ci{
341570af302Sopenharmony_ci	double y2;
342570af302Sopenharmony_ci
343570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
344570af302Sopenharmony_ci	setupfenv(t->r);
345570af302Sopenharmony_ci	t->y = modf(t->x, &y2);
346570af302Sopenharmony_ci	t->y2 = y2;
347570af302Sopenharmony_ci	t->e = getexcept();
348570af302Sopenharmony_ci	return 0;
349570af302Sopenharmony_ci}
350570af302Sopenharmony_ci
351570af302Sopenharmony_ciint mpmodff(struct t *t)
352570af302Sopenharmony_ci{
353570af302Sopenharmony_ci	float y2;
354570af302Sopenharmony_ci
355570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
356570af302Sopenharmony_ci	setupfenv(t->r);
357570af302Sopenharmony_ci	t->y = modff(t->x, &y2);
358570af302Sopenharmony_ci	t->y2 = y2;
359570af302Sopenharmony_ci	t->e = getexcept();
360570af302Sopenharmony_ci	return 0;
361570af302Sopenharmony_ci}
362570af302Sopenharmony_ci
363570af302Sopenharmony_ciint mpmodfl(struct t *t)
364570af302Sopenharmony_ci{
365570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
366570af302Sopenharmony_ci	setupfenv(t->r);
367570af302Sopenharmony_ci	t->y = modfl(t->x, &t->y2);
368570af302Sopenharmony_ci	t->e = getexcept();
369570af302Sopenharmony_ci	return 0;
370570af302Sopenharmony_ci}
371570af302Sopenharmony_ci
372570af302Sopenharmony_ciint mpsincos(struct t *t)
373570af302Sopenharmony_ci{
374570af302Sopenharmony_ci	double y, y2;
375570af302Sopenharmony_ci
376570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
377570af302Sopenharmony_ci	setupfenv(t->r);
378570af302Sopenharmony_ci	sincos(t->x, &y, &y2);
379570af302Sopenharmony_ci	t->y = y;
380570af302Sopenharmony_ci	t->y2 = y2;
381570af302Sopenharmony_ci	t->e = getexcept();
382570af302Sopenharmony_ci	return 0;
383570af302Sopenharmony_ci}
384570af302Sopenharmony_ci
385570af302Sopenharmony_ciint mpsincosf(struct t *t)
386570af302Sopenharmony_ci{
387570af302Sopenharmony_ci	float y, y2;
388570af302Sopenharmony_ci
389570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
390570af302Sopenharmony_ci	setupfenv(t->r);
391570af302Sopenharmony_ci	sincosf(t->x, &y, &y2);
392570af302Sopenharmony_ci	t->y = y;
393570af302Sopenharmony_ci	t->y2 = y2;
394570af302Sopenharmony_ci	t->e = getexcept();
395570af302Sopenharmony_ci	return 0;
396570af302Sopenharmony_ci}
397570af302Sopenharmony_ci
398570af302Sopenharmony_ciint mpsincosl(struct t *t)
399570af302Sopenharmony_ci{
400570af302Sopenharmony_ci	t->dy = t->dy2 = 0;
401570af302Sopenharmony_ci	setupfenv(t->r);
402570af302Sopenharmony_ci	sincosl(t->x, &t->y, &t->y2);
403570af302Sopenharmony_ci	t->e = getexcept();
404570af302Sopenharmony_ci	return 0;
405570af302Sopenharmony_ci}
406570af302Sopenharmony_ci
407570af302Sopenharmony_ci#define mp_ff_fi(n) \
408570af302Sopenharmony_ciint mp##n(struct t *t) \
409570af302Sopenharmony_ci{ \
410570af302Sopenharmony_ci	int i; \
411570af302Sopenharmony_ci	t->dy = 0; \
412570af302Sopenharmony_ci	setupfenv(t->r); \
413570af302Sopenharmony_ci	t->y = n(t->x, t->x2, &i); \
414570af302Sopenharmony_ci	t->e = getexcept(); \
415570af302Sopenharmony_ci	t->i = i; \
416570af302Sopenharmony_ci	return 0; \
417570af302Sopenharmony_ci}
418570af302Sopenharmony_ci
419570af302Sopenharmony_cimp_ff_fi(remquo)
420570af302Sopenharmony_cimp_ff_fi(remquof)
421570af302Sopenharmony_cimp_ff_fi(remquol)
422570af302Sopenharmony_ci
423570af302Sopenharmony_ci#define mp_fff_f(n) \
424570af302Sopenharmony_ciint mp##n(struct t *t) \
425570af302Sopenharmony_ci{ \
426570af302Sopenharmony_ci	t->dy = 0; \
427570af302Sopenharmony_ci	setupfenv(t->r); \
428570af302Sopenharmony_ci	t->y = n(t->x, t->x2, t->x3); \
429570af302Sopenharmony_ci	t->e = getexcept(); \
430570af302Sopenharmony_ci	return 0; \
431570af302Sopenharmony_ci}
432570af302Sopenharmony_ci
433570af302Sopenharmony_cimp_fff_f(fma)
434570af302Sopenharmony_cimp_fff_f(fmaf)
435570af302Sopenharmony_cimp_fff_f(fmal)
436570af302Sopenharmony_ci
437570af302Sopenharmony_ci#define mp_if_f(n) \
438570af302Sopenharmony_ciint mp##n(struct t *t) \
439570af302Sopenharmony_ci{ \
440570af302Sopenharmony_ci	t->dy = 0; \
441570af302Sopenharmony_ci	setupfenv(t->r); \
442570af302Sopenharmony_ci	t->y = n(t->i, t->x); \
443570af302Sopenharmony_ci	t->e = getexcept(); \
444570af302Sopenharmony_ci	return 0; \
445570af302Sopenharmony_ci}
446570af302Sopenharmony_ci
447570af302Sopenharmony_cimp_if_f(jn)
448570af302Sopenharmony_cimp_if_f(jnf)
449570af302Sopenharmony_ci//mp_if_f(jnl)
450570af302Sopenharmony_cimp_if_f(yn)
451570af302Sopenharmony_cimp_if_f(ynf)
452570af302Sopenharmony_ci//mp_if_f(ynl)
453570af302Sopenharmony_ci
454