#include "lib9.h"#include "interp.h"#include "isa.h"#include "runt.h"#include "raise.h"#include "mathi.h"#include "mathmod.h" static union{ double x; uvlong u;} bits64; static union{ float x; unsigned int u;} bits32; voidmathmodinit(void){ builtinmod("$Math", Mathmodtab, Mathmodlen); fmtinstall('g', gfltconv); fmtinstall('G', gfltconv); fmtinstall('e', gfltconv); /* fmtinstall('E', gfltconv); */ /* avoid clash with ether address */ fmtinstall(0x00c9, gfltconv); /* L'É' */ fmtinstall('f', gfltconv);} voidMath_import_int(void *fp){ F_Math_import_int *f; int i, n; unsigned int u; unsigned char *bp; int *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (int*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; x[i] = u; }} voidMath_import_real32(void *fp){ F_Math_import_int *f; int i, n; unsigned int u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; bits32.u = u; x[i] = bits32.x; }} voidMath_import_real(void *fp){ F_Math_import_int *f; int i, n; uvlong u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=8*n) error(exMathia); bp = f->b->data; x = (double*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; bits64.u = u; x[i] = bits64.x; }} voidMath_export_int(void *fp){ F_Math_export_int *f; int i, n; unsigned int u; unsigned char *bp; int *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (int*)(f->x->data); for(i=0; i<n; i++){ u = x[i]; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; }} voidMath_export_real32(void *fp){ F_Math_export_int *f; int i, n; unsigned int u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ bits32.x = x[i]; u = bits32.u; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; }} voidMath_export_real(void *fp){ F_Math_export_int *f; int i, n; uvlong u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=8*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ bits64.x = x[i]; u = bits64.u; *bp++ = u>>56; *bp++ = u>>48; *bp++ = u>>40; *bp++ = u>>32; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; }} voidMath_bits32real(void *fp){ F_Math_bits32real *f; f = fp; bits32.u = f->b; *f->ret = bits32.x;} voidMath_bits64real(void *fp){ F_Math_bits64real *f; f = fp; bits64.u = f->b; *f->ret = bits64.x;} voidMath_realbits32(void *fp){ F_Math_realbits32 *f; f = fp; bits32.x = f->x; *f->ret = bits32.u;} voidMath_realbits64(void *fp){ F_Math_realbits64 *f; f = fp; bits64.x = f->x; *f->ret = bits64.u;} voidMath_getFPcontrol(void *fp){ F_Math_getFPcontrol *f; f = fp; *f->ret = getFPcontrol();} voidMath_getFPstatus(void *fp){ F_Math_getFPstatus *f; f = fp; *f->ret = getFPstatus();} voidMath_finite(void *fp){ F_Math_finite *f; f = fp; *f->ret = finite(f->x);} voidMath_ilogb(void *fp){ F_Math_ilogb *f; f = fp; *f->ret = ilogb(f->x);} voidMath_isnan(void *fp){ F_Math_isnan *f; f = fp; *f->ret = isnan(f->x);} voidMath_acos(void *fp){ F_Math_acos *f; f = fp; *f->ret = __ieee754_acos(f->x);} voidMath_acosh(void *fp){ F_Math_acosh *f; f = fp; *f->ret = __ieee754_acosh(f->x);} voidMath_asin(void *fp){ F_Math_asin *f; f = fp; *f->ret = __ieee754_asin(f->x);} voidMath_asinh(void *fp){ F_Math_asinh *f; f = fp; *f->ret = asinh(f->x);} voidMath_atan(void *fp){ F_Math_atan *f; f = fp; *f->ret = atan(f->x);} voidMath_atanh(void *fp){ F_Math_atanh *f; f = fp; *f->ret = __ieee754_atanh(f->x);} voidMath_cbrt(void *fp){ F_Math_cbrt *f; f = fp; *f->ret = cbrt(f->x);} voidMath_ceil(void *fp){ F_Math_ceil *f; f = fp; *f->ret = ceil(f->x);} voidMath_cos(void *fp){ F_Math_cos *f; f = fp; *f->ret = cos(f->x);} voidMath_cosh(void *fp){ F_Math_cosh *f; f = fp; *f->ret = __ieee754_cosh(f->x);} voidMath_erf(void *fp){ F_Math_erf *f; f = fp; *f->ret = erf(f->x);} voidMath_erfc(void *fp){ F_Math_erfc *f; f = fp; *f->ret = erfc(f->x);} voidMath_exp(void *fp){ F_Math_exp *f; f = fp; *f->ret = __ieee754_exp(f->x);} voidMath_expm1(void *fp){ F_Math_expm1 *f; f = fp; *f->ret = expm1(f->x);} voidMath_fabs(void *fp){ F_Math_fabs *f; f = fp; *f->ret = fabs(f->x);} voidMath_floor(void *fp){ F_Math_floor *f; f = fp; *f->ret = floor(f->x);} voidMath_j0(void *fp){ F_Math_j0 *f; f = fp; *f->ret = __ieee754_j0(f->x);} voidMath_j1(void *fp){ F_Math_j1 *f; f = fp; *f->ret = __ieee754_j1(f->x);} voidMath_log(void *fp){ F_Math_log *f; f = fp; *f->ret = __ieee754_log(f->x);} voidMath_log10(void *fp){ F_Math_log10 *f; f = fp; *f->ret = __ieee754_log10(f->x);} voidMath_log1p(void *fp){ F_Math_log1p *f; f = fp; *f->ret = log1p(f->x);} voidMath_rint(void *fp){ F_Math_rint *f; f = fp; *f->ret = rint(f->x);} voidLines 1–500 of 955. Load more
#include "lib9.h" #include "interp.h" #include "isa.h" #include "runt.h" #include "raise.h" #include "mathi.h" #include "mathmod.h" static union { double x; uvlong u; } bits64; static union{ float x; unsigned int u; } bits32; void mathmodinit(void) { builtinmod("$Math", Mathmodtab, Mathmodlen); fmtinstall('g', gfltconv); fmtinstall('G', gfltconv); fmtinstall('e', gfltconv); /* fmtinstall('E', gfltconv); */ /* avoid clash with ether address */ fmtinstall(0x00c9, gfltconv); /* L'É' */ fmtinstall('f', gfltconv); } void Math_import_int(void *fp) { F_Math_import_int *f; int i, n; unsigned int u; unsigned char *bp; int *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (int*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; x[i] = u; } } void Math_import_real32(void *fp) { F_Math_import_int *f; int i, n; unsigned int u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; bits32.u = u; x[i] = bits32.x; } } void Math_import_real(void *fp) { F_Math_import_int *f; int i, n; uvlong u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=8*n) error(exMathia); bp = f->b->data; x = (double*)(f->x->data); for(i=0; i<n; i++){ u = *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; u = (u<<8) | *bp++; bits64.u = u; x[i] = bits64.x; } } void Math_export_int(void *fp) { F_Math_export_int *f; int i, n; unsigned int u; unsigned char *bp; int *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (int*)(f->x->data); for(i=0; i<n; i++){ u = x[i]; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; } } void Math_export_real32(void *fp) { F_Math_export_int *f; int i, n; unsigned int u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=4*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ bits32.x = x[i]; u = bits32.u; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; } } void Math_export_real(void *fp) { F_Math_export_int *f; int i, n; uvlong u; unsigned char *bp; double *x; f = fp; n = f->x->len; if(f->b->len!=8*n) error(exMathia); bp = (unsigned char *)(f->b->data); x = (double*)(f->x->data); for(i=0; i<n; i++){ bits64.x = x[i]; u = bits64.u; *bp++ = u>>56; *bp++ = u>>48; *bp++ = u>>40; *bp++ = u>>32; *bp++ = u>>24; *bp++ = u>>16; *bp++ = u>>8; *bp++ = u; } } void Math_bits32real(void *fp) { F_Math_bits32real *f; f = fp; bits32.u = f->b; *f->ret = bits32.x; } void Math_bits64real(void *fp) { F_Math_bits64real *f; f = fp; bits64.u = f->b; *f->ret = bits64.x; } void Math_realbits32(void *fp) { F_Math_realbits32 *f; f = fp; bits32.x = f->x; *f->ret = bits32.u; } void Math_realbits64(void *fp) { F_Math_realbits64 *f; f = fp; bits64.x = f->x; *f->ret = bits64.u; } void Math_getFPcontrol(void *fp) { F_Math_getFPcontrol *f; f = fp; *f->ret = getFPcontrol(); } void Math_getFPstatus(void *fp) { F_Math_getFPstatus *f; f = fp; *f->ret = getFPstatus(); } void Math_finite(void *fp) { F_Math_finite *f; f = fp; *f->ret = finite(f->x); } void Math_ilogb(void *fp) { F_Math_ilogb *f; f = fp; *f->ret = ilogb(f->x); } void Math_isnan(void *fp) { F_Math_isnan *f; f = fp; *f->ret = isnan(f->x); } void Math_acos(void *fp) { F_Math_acos *f; f = fp; *f->ret = __ieee754_acos(f->x); } void Math_acosh(void *fp) { F_Math_acosh *f; f = fp; *f->ret = __ieee754_acosh(f->x); } void Math_asin(void *fp) { F_Math_asin *f; f = fp; *f->ret = __ieee754_asin(f->x); } void Math_asinh(void *fp) { F_Math_asinh *f; f = fp; *f->ret = asinh(f->x); } void Math_atan(void *fp) { F_Math_atan *f; f = fp; *f->ret = atan(f->x); } void Math_atanh(void *fp) { F_Math_atanh *f; f = fp; *f->ret = __ieee754_atanh(f->x); } void Math_cbrt(void *fp) { F_Math_cbrt *f; f = fp; *f->ret = cbrt(f->x); } void Math_ceil(void *fp) { F_Math_ceil *f; f = fp; *f->ret = ceil(f->x); } void Math_cos(void *fp) { F_Math_cos *f; f = fp; *f->ret = cos(f->x); } void Math_cosh(void *fp) { F_Math_cosh *f; f = fp; *f->ret = __ieee754_cosh(f->x); } void Math_erf(void *fp) { F_Math_erf *f; f = fp; *f->ret = erf(f->x); } void Math_erfc(void *fp) { F_Math_erfc *f; f = fp; *f->ret = erfc(f->x); } void Math_exp(void *fp) { F_Math_exp *f; f = fp; *f->ret = __ieee754_exp(f->x); } void Math_expm1(void *fp) { F_Math_expm1 *f; f = fp; *f->ret = expm1(f->x); } void Math_fabs(void *fp) { F_Math_fabs *f; f = fp; *f->ret = fabs(f->x); } void Math_floor(void *fp) { F_Math_floor *f; f = fp; *f->ret = floor(f->x); } void Math_j0(void *fp) { F_Math_j0 *f; f = fp; *f->ret = __ieee754_j0(f->x); } void Math_j1(void *fp) { F_Math_j1 *f; f = fp; *f->ret = __ieee754_j1(f->x); } void Math_log(void *fp) { F_Math_log *f; f = fp; *f->ret = __ieee754_log(f->x); } void Math_log10(void *fp) { F_Math_log10 *f; f = fp; *f->ret = __ieee754_log10(f->x); } void Math_log1p(void *fp) { F_Math_log1p *f; f = fp; *f->ret = log1p(f->x); } void Math_rint(void *fp) { F_Math_rint *f; f = fp; *f->ret = rint(f->x); } void