X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fgen%2Fmplibm.c;h=141fa8570598cc763b9a3b7d2ea3300f0ba34109;hb=d2ba8e6653b825dff20e989f4cf8fdcc33f3f6be;hp=93225a99a41f398b32ce52c7b09eb9dc38f5c356;hpb=b5bbc6ebaeaf4381ea2436a3b410dcf4980c8efd;p=libc-test diff --git a/src/math/gen/mplibm.c b/src/math/gen/mplibm.c index 93225a9..141fa85 100644 --- a/src/math/gen/mplibm.c +++ b/src/math/gen/mplibm.c @@ -54,6 +54,29 @@ static int mpl2(struct t *s, long double (*f)(long double, long double)) return 0; } +static double sinpi(double x) { return sin(3.141592653589793238*x); } +int mpsinpi(struct t *t) { return mpd1(t, sinpi); } + + +#define OP(n,op,t) static t n(t x, t y) { t z = x op y; return z; } +OP(add,+,double) +OP(addf,+,float) +OP(addl,+,long double) +OP(mul,*,double) +OP(mulf,*,float) +OP(mull,*,long double) +OP(div,/,double) +OP(divf,/,float) +OP(divl,/,long double) +int mpadd(struct t *t) { return mpd2(t, add); } +int mpaddf(struct t *t) { return mpf2(t, addf); } +int mpaddl(struct t *t) { return mpl2(t, addl); } +int mpmul(struct t *t) { return mpd2(t, mul); } +int mpmulf(struct t *t) { return mpf2(t, mulf); } +int mpmull(struct t *t) { return mpl2(t, mull); } +int mpdiv(struct t *t) { return mpd2(t, div); } +int mpdivf(struct t *t) { return mpf2(t, divf); } +int mpdivl(struct t *t) { return mpl2(t, divl); } int mpacos(struct t *t) { return mpd1(t, acos); } int mpacosf(struct t *t) { return mpf1(t, acosf); } @@ -219,7 +242,7 @@ int mppow10(struct t *t) { return mpd1(t, pow10); } int mppow10f(struct t *t) { return mpf1(t, pow10f); } int mppow10l(struct t *t) { return mpl1(t, pow10l); } -#define mp_f_fi(n) \ +#define mp_fi_f(n) \ int mp##n(struct t *t) \ { \ t->dy = 0; \ @@ -229,17 +252,17 @@ int mp##n(struct t *t) \ return 0; \ } -mp_f_fi(ldexp) -mp_f_fi(ldexpf) -mp_f_fi(ldexpl) -mp_f_fi(scalbn) -mp_f_fi(scalbnf) -mp_f_fi(scalbnl) -mp_f_fi(scalbln) -mp_f_fi(scalblnf) -mp_f_fi(scalblnl) +mp_fi_f(ldexp) +mp_fi_f(ldexpf) +mp_fi_f(ldexpl) +mp_fi_f(scalbn) +mp_fi_f(scalbnf) +mp_fi_f(scalbnl) +mp_fi_f(scalbln) +mp_fi_f(scalblnf) +mp_fi_f(scalblnl) -#define mp_fi_f(n) \ +#define mp_f_fi(n) \ int mp##n(struct t *t) \ { \ int i; \ @@ -251,12 +274,12 @@ int mp##n(struct t *t) \ return 0; \ } -mp_fi_f(frexp) -mp_fi_f(frexpf) -mp_fi_f(frexpl) -mp_fi_f(lgamma_r) -mp_fi_f(lgammaf_r) -mp_fi_f(lgammal_r) +mp_f_fi(frexp) +mp_f_fi(frexpf) +mp_f_fi(frexpl) +mp_f_fi(lgamma_r) +mp_f_fi(lgammaf_r) +mp_f_fi(lgammal_r) int mplgamma(struct t *t) { @@ -313,3 +336,118 @@ mp_f_i(lround) mp_f_i(lroundf) mp_f_i(lroundl) +int mpmodf(struct t *t) +{ + double y2; + + t->dy = t->dy2 = 0; + setupfenv(t->r); + t->y = modf(t->x, &y2); + t->y2 = y2; + t->e = getexcept(); + return 0; +} + +int mpmodff(struct t *t) +{ + float y2; + + t->dy = t->dy2 = 0; + setupfenv(t->r); + t->y = modff(t->x, &y2); + t->y2 = y2; + t->e = getexcept(); + return 0; +} + +int mpmodfl(struct t *t) +{ + t->dy = t->dy2 = 0; + setupfenv(t->r); + t->y = modfl(t->x, &t->y2); + t->e = getexcept(); + return 0; +} + +int mpsincos(struct t *t) +{ + double y, y2; + + t->dy = t->dy2 = 0; + setupfenv(t->r); + sincos(t->x, &y, &y2); + t->y = y; + t->y2 = y2; + t->e = getexcept(); + return 0; +} + +int mpsincosf(struct t *t) +{ + float y, y2; + + t->dy = t->dy2 = 0; + setupfenv(t->r); + sincosf(t->x, &y, &y2); + t->y = y; + t->y2 = y2; + t->e = getexcept(); + return 0; +} + +int mpsincosl(struct t *t) +{ + t->dy = t->dy2 = 0; + setupfenv(t->r); + sincosl(t->x, &t->y, &t->y2); + t->e = getexcept(); + return 0; +} + +#define mp_ff_fi(n) \ +int mp##n(struct t *t) \ +{ \ + int i; \ + t->dy = 0; \ + setupfenv(t->r); \ + t->y = n(t->x, t->x2, &i); \ + t->e = getexcept(); \ + t->i = i; \ + return 0; \ +} + +mp_ff_fi(remquo) +mp_ff_fi(remquof) +mp_ff_fi(remquol) + +#define mp_fff_f(n) \ +int mp##n(struct t *t) \ +{ \ + t->dy = 0; \ + setupfenv(t->r); \ + t->y = n(t->x, t->x2, t->x3); \ + t->e = getexcept(); \ + return 0; \ +} + +mp_fff_f(fma) +mp_fff_f(fmaf) +mp_fff_f(fmal) + +#define mp_if_f(n) \ +int mp##n(struct t *t) \ +{ \ + t->dy = 0; \ + setupfenv(t->r); \ + t->y = n(t->i, t->x); \ + t->e = getexcept(); \ + return 0; \ +} + +mp_if_f(jn) +mp_if_f(jnf) +//mp_if_f(jnl) +mp_if_f(yn) +mp_if_f(ynf) +//mp_if_f(ynl) +