*/
#define DEF3OP(name, p, f1, f2, f3) \
-static ieee754##p fpemu_##p##_##name(ieee754##p r, ieee754##p s, \
- ieee754##p t) \
+static union ieee754##p fpemu_##p##_##name(union ieee754##p r, union ieee754##p s, \
+ union ieee754##p t) \
{ \
struct _ieee754_csr ieee754_csr_save; \
s = f1(s, t); \
return s; \
}
-static ieee754dp fpemu_dp_recip(ieee754dp d)
+static union ieee754dp fpemu_dp_recip(union ieee754dp d)
{
return ieee754dp_div(ieee754dp_one(0), d);
}
-static ieee754dp fpemu_dp_rsqrt(ieee754dp d)
+static union ieee754dp fpemu_dp_rsqrt(union ieee754dp d)
{
return ieee754dp_div(ieee754dp_one(0), ieee754dp_sqrt(d));
}
-static ieee754sp fpemu_sp_recip(ieee754sp s)
+static union ieee754sp fpemu_sp_recip(union ieee754sp s)
{
return ieee754sp_div(ieee754sp_one(0), s);
}
-static ieee754sp fpemu_sp_rsqrt(ieee754sp s)
+static union ieee754sp fpemu_sp_rsqrt(union ieee754sp s)
{
return ieee754sp_div(ieee754sp_one(0), ieee754sp_sqrt(s));
}
switch (MIPSInst_FMA_FFMT(ir)) {
case s_fmt:{ /* 0 */
- ieee754sp(*handler) (ieee754sp, ieee754sp, ieee754sp);
- ieee754sp fd, fr, fs, ft;
+ union ieee754sp(*handler) (union ieee754sp, union ieee754sp, union ieee754sp);
+ union ieee754sp fd, fr, fs, ft;
u32 __user *va;
u32 val;
}
case d_fmt:{ /* 1 */
- ieee754dp(*handler) (ieee754dp, ieee754dp, ieee754dp);
- ieee754dp fd, fr, fs, ft;
+ union ieee754dp(*handler) (union ieee754dp, union ieee754dp, union ieee754dp);
+ union ieee754dp fd, fr, fs, ft;
u64 __user *va;
u64 val;
unsigned rcsr = 0; /* resulting csr */
unsigned cond;
union {
- ieee754dp d;
- ieee754sp s;
+ union ieee754dp d;
+ union ieee754sp s;
int w;
#ifdef __mips64
s64 l;
switch (rfmt = (MIPSInst_FFMT(ir) & 0xf)) {
case s_fmt:{ /* 0 */
union {
- ieee754sp(*b) (ieee754sp, ieee754sp);
- ieee754sp(*u) (ieee754sp);
+ union ieee754sp(*b) (union ieee754sp, union ieee754sp);
+ union ieee754sp(*u) (union ieee754sp);
} handler;
switch (MIPSInst_FUNC(ir)) {
/* binary op on handler */
scopbop:
{
- ieee754sp fs, ft;
+ union ieee754sp fs, ft;
SPFROMREG(fs, MIPSInst_FS(ir));
SPFROMREG(ft, MIPSInst_FT(ir));
}
scopuop:
{
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
rv.s = (*handler.u) (fs);
case fcvts_op:
return SIGILL; /* not defined */
case fcvtd_op:{
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
rv.d = ieee754dp_fsp(fs);
goto copcsr;
}
case fcvtw_op:{
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
rv.w = ieee754sp_tint(fs);
case fceil_op:
case ffloor_op:{
unsigned int oldrm = ieee754_csr.rm;
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
ieee754_csr.rm = ieee_rm[modeindex(MIPSInst_FUNC(ir))];
#if defined(__mips64)
case fcvtl_op:{
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
rv.l = ieee754sp_tlong(fs);
case fceill_op:
case ffloorl_op:{
unsigned int oldrm = ieee754_csr.rm;
- ieee754sp fs;
+ union ieee754sp fs;
SPFROMREG(fs, MIPSInst_FS(ir));
ieee754_csr.rm = ieee_rm[modeindex(MIPSInst_FUNC(ir))];
default:
if (MIPSInst_FUNC(ir) >= fcmp_op) {
unsigned cmpop = MIPSInst_FUNC(ir) - fcmp_op;
- ieee754sp fs, ft;
+ union ieee754sp fs, ft;
SPFROMREG(fs, MIPSInst_FS(ir));
SPFROMREG(ft, MIPSInst_FT(ir));
case d_fmt:{
union {
- ieee754dp(*b) (ieee754dp, ieee754dp);
- ieee754dp(*u) (ieee754dp);
+ union ieee754dp(*b) (union ieee754dp, union ieee754dp);
+ union ieee754dp(*u) (union ieee754dp);
} handler;
switch (MIPSInst_FUNC(ir)) {
/* binary op on handler */
dcopbop:{
- ieee754dp fs, ft;
+ union ieee754dp fs, ft;
DPFROMREG(fs, MIPSInst_FS(ir));
DPFROMREG(ft, MIPSInst_FT(ir));
goto copcsr;
}
dcopuop:{
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
rv.d = (*handler.u) (fs);
/* unary conv ops */
case fcvts_op:{
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
rv.s = ieee754sp_fdp(fs);
return SIGILL; /* not defined */
case fcvtw_op:{
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
rv.w = ieee754dp_tint(fs); /* wrong */
case fceil_op:
case ffloor_op:{
unsigned int oldrm = ieee754_csr.rm;
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
ieee754_csr.rm = ieee_rm[modeindex(MIPSInst_FUNC(ir))];
#if defined(__mips64)
case fcvtl_op:{
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
rv.l = ieee754dp_tlong(fs);
case fceill_op:
case ffloorl_op:{
unsigned int oldrm = ieee754_csr.rm;
- ieee754dp fs;
+ union ieee754dp fs;
DPFROMREG(fs, MIPSInst_FS(ir));
ieee754_csr.rm = ieee_rm[modeindex(MIPSInst_FUNC(ir))];
default:
if (MIPSInst_FUNC(ir) >= fcmp_op) {
unsigned cmpop = MIPSInst_FUNC(ir) - fcmp_op;
- ieee754dp fs, ft;
+ union ieee754dp fs, ft;
DPFROMREG(fs, MIPSInst_FS(ir));
DPFROMREG(ft, MIPSInst_FT(ir));
}
case w_fmt:{
- ieee754sp fs;
+ union ieee754sp fs;
switch (MIPSInst_FUNC(ir)) {
case fcvts_op:
#include "ieee754dp.h"
-ieee754dp ieee754dp_add(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y)
{
COMPXDP;
COMPYDP;
#include "ieee754dp.h"
-int ieee754dp_cmp(ieee754dp x, ieee754dp y, int cmp, int sig)
+int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cmp, int sig)
{
COMPXDP;
COMPYDP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_div(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y)
{
COMPXDP;
COMPYDP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_fint(int x)
+union ieee754dp ieee754dp_fint(int x)
{
u64 xm;
int xe;
#endif
}
-ieee754dp ieee754dp_funs(unsigned int u)
+union ieee754dp ieee754dp_funs(unsigned int u)
{
if ((int) u < 0)
return ieee754dp_add(ieee754dp_1e31(),
#include "ieee754dp.h"
-ieee754dp ieee754dp_flong(s64 x)
+union ieee754dp ieee754dp_flong(s64 x)
{
u64 xm;
int xe;
DPNORMRET1(xs, xe, xm, "dp_flong", x);
}
-ieee754dp ieee754dp_fulong(u64 u)
+union ieee754dp ieee754dp_fulong(u64 u)
{
if ((s64) u < 0)
return ieee754dp_add(ieee754dp_1e63(),
/* close to ieeep754dp_logb
*/
-ieee754dp ieee754dp_frexp(ieee754dp x, int *eptr)
+union ieee754dp ieee754dp_frexp(union ieee754dp x, int *eptr)
{
COMPXDP;
CLEARCX;
#include "ieee754dp.h"
-ieee754dp ieee754dp_fsp(ieee754sp x)
+union ieee754dp ieee754dp_fsp(union ieee754sp x)
{
COMPXSP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_logb(ieee754dp x)
+union ieee754dp ieee754dp_logb(union ieee754dp x)
{
COMPXDP;
/* modf function is always exact for a finite number
*/
-ieee754dp ieee754dp_modf(ieee754dp x, ieee754dp *ip)
+union ieee754dp ieee754dp_modf(union ieee754dp x, union ieee754dp *ip)
{
COMPXDP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_mul(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y)
{
COMPXDP;
COMPYDP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_scalb(ieee754dp x, int n)
+union ieee754dp ieee754dp_scalb(union ieee754dp x, int n)
{
COMPXDP;
}
-ieee754dp ieee754dp_ldexp(ieee754dp x, int n)
+union ieee754dp ieee754dp_ldexp(union ieee754dp x, int n)
{
return ieee754dp_scalb(x, n);
}
#include "ieee754dp.h"
-int ieee754dp_finite(ieee754dp x)
+int ieee754dp_finite(union ieee754dp x)
{
return DPBEXP(x) != DP_EMAX + 1 + DP_EBIAS;
}
-ieee754dp ieee754dp_copysign(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_copysign(union ieee754dp x, union ieee754dp y)
{
CLEARCX;
DPSIGN(x) = DPSIGN(y);
}
-ieee754dp ieee754dp_neg(ieee754dp x)
+union ieee754dp ieee754dp_neg(union ieee754dp x)
{
COMPXDP;
DPSIGN(x) ^= 1;
if (xc == IEEE754_CLASS_SNAN) {
- ieee754dp y = ieee754dp_indef();
+ union ieee754dp y = ieee754dp_indef();
SETCX(IEEE754_INVALID_OPERATION);
DPSIGN(y) = DPSIGN(x);
return ieee754dp_nanxcpt(y, "neg");
}
-ieee754dp ieee754dp_abs(ieee754dp x)
+union ieee754dp ieee754dp_abs(union ieee754dp x)
{
COMPXDP;
1742, 661, 130
};
-ieee754dp ieee754dp_sqrt(ieee754dp x)
+union ieee754dp ieee754dp_sqrt(union ieee754dp x)
{
struct _ieee754_csr oldcsr;
- ieee754dp y, z, t;
+ union ieee754dp y, z, t;
unsigned scalx, yh;
COMPXDP;
#include "ieee754dp.h"
-ieee754dp ieee754dp_sub(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y)
{
COMPXDP;
COMPYDP;
#include <linux/kernel.h>
#include "ieee754dp.h"
-int ieee754dp_tint(ieee754dp x)
+int ieee754dp_tint(union ieee754dp x)
{
COMPXDP;
}
-unsigned int ieee754dp_tuns(ieee754dp x)
+unsigned int ieee754dp_tuns(union ieee754dp x)
{
- ieee754dp hb = ieee754dp_1e31();
+ union ieee754dp hb = ieee754dp_1e31();
/* what if x < 0 ?? */
if (ieee754dp_lt(x, hb))
#include "ieee754dp.h"
-s64 ieee754dp_tlong(ieee754dp x)
+s64 ieee754dp_tlong(union ieee754dp x)
{
COMPXDP;
}
-u64 ieee754dp_tulong(ieee754dp x)
+u64 ieee754dp_tulong(union ieee754dp x)
{
- ieee754dp hb = ieee754dp_1e63();
+ union ieee754dp hb = ieee754dp_1e63();
/* what if x < 0 ?? */
if (ieee754dp_lt(x, hb))
;))))
};
-typedef union _ieee754dp {
+union ieee754dp {
struct ieee754dp_const oparts;
struct {
__BITFIELD_FIELD(unsigned int sign:1,
} parts;
double d;
u64 bits;
-} ieee754dp;
+};
struct ieee754sp_const {
__BITFIELD_FIELD(unsigned sign:1,
;)))
};
-typedef union _ieee754sp {
+union ieee754sp {
struct ieee754sp_const parts;
float f;
u32 bits;
-} ieee754sp;
+};
/*
* single precision (often aka float)
*/
-int ieee754sp_finite(ieee754sp x);
-int ieee754sp_class(ieee754sp x);
+int ieee754sp_finite(union ieee754sp x);
+int ieee754sp_class(union ieee754sp x);
-ieee754sp ieee754sp_abs(ieee754sp x);
-ieee754sp ieee754sp_neg(ieee754sp x);
-ieee754sp ieee754sp_scalb(ieee754sp x, int);
-ieee754sp ieee754sp_logb(ieee754sp x);
+union ieee754sp ieee754sp_abs(union ieee754sp x);
+union ieee754sp ieee754sp_neg(union ieee754sp x);
+union ieee754sp ieee754sp_scalb(union ieee754sp x, int);
+union ieee754sp ieee754sp_logb(union ieee754sp x);
/* x with sign of y */
-ieee754sp ieee754sp_copysign(ieee754sp x, ieee754sp y);
+union ieee754sp ieee754sp_copysign(union ieee754sp x, union ieee754sp y);
-ieee754sp ieee754sp_add(ieee754sp x, ieee754sp y);
-ieee754sp ieee754sp_sub(ieee754sp x, ieee754sp y);
-ieee754sp ieee754sp_mul(ieee754sp x, ieee754sp y);
-ieee754sp ieee754sp_div(ieee754sp x, ieee754sp y);
+union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y);
+union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y);
+union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y);
+union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y);
-ieee754sp ieee754sp_fint(int x);
-ieee754sp ieee754sp_funs(unsigned x);
-ieee754sp ieee754sp_flong(s64 x);
-ieee754sp ieee754sp_fulong(u64 x);
-ieee754sp ieee754sp_fdp(ieee754dp x);
+union ieee754sp ieee754sp_fint(int x);
+union ieee754sp ieee754sp_funs(unsigned x);
+union ieee754sp ieee754sp_flong(s64 x);
+union ieee754sp ieee754sp_fulong(u64 x);
+union ieee754sp ieee754sp_fdp(union ieee754dp x);
-int ieee754sp_tint(ieee754sp x);
-unsigned int ieee754sp_tuns(ieee754sp x);
-s64 ieee754sp_tlong(ieee754sp x);
-u64 ieee754sp_tulong(ieee754sp x);
+int ieee754sp_tint(union ieee754sp x);
+unsigned int ieee754sp_tuns(union ieee754sp x);
+s64 ieee754sp_tlong(union ieee754sp x);
+u64 ieee754sp_tulong(union ieee754sp x);
-int ieee754sp_cmp(ieee754sp x, ieee754sp y, int cop, int sig);
+int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cop, int sig);
/*
* basic sp math
*/
-ieee754sp ieee754sp_modf(ieee754sp x, ieee754sp * ip);
-ieee754sp ieee754sp_frexp(ieee754sp x, int *exp);
-ieee754sp ieee754sp_ldexp(ieee754sp x, int exp);
+union ieee754sp ieee754sp_modf(union ieee754sp x, union ieee754sp * ip);
+union ieee754sp ieee754sp_frexp(union ieee754sp x, int *exp);
+union ieee754sp ieee754sp_ldexp(union ieee754sp x, int exp);
-ieee754sp ieee754sp_ceil(ieee754sp x);
-ieee754sp ieee754sp_floor(ieee754sp x);
-ieee754sp ieee754sp_trunc(ieee754sp x);
+union ieee754sp ieee754sp_ceil(union ieee754sp x);
+union ieee754sp ieee754sp_floor(union ieee754sp x);
+union ieee754sp ieee754sp_trunc(union ieee754sp x);
-ieee754sp ieee754sp_sqrt(ieee754sp x);
+union ieee754sp ieee754sp_sqrt(union ieee754sp x);
/*
* double precision (often aka double)
*/
-int ieee754dp_finite(ieee754dp x);
-int ieee754dp_class(ieee754dp x);
+int ieee754dp_finite(union ieee754dp x);
+int ieee754dp_class(union ieee754dp x);
/* x with sign of y */
-ieee754dp ieee754dp_copysign(ieee754dp x, ieee754dp y);
+union ieee754dp ieee754dp_copysign(union ieee754dp x, union ieee754dp y);
-ieee754dp ieee754dp_add(ieee754dp x, ieee754dp y);
-ieee754dp ieee754dp_sub(ieee754dp x, ieee754dp y);
-ieee754dp ieee754dp_mul(ieee754dp x, ieee754dp y);
-ieee754dp ieee754dp_div(ieee754dp x, ieee754dp y);
+union ieee754dp ieee754dp_add(union ieee754dp x, union ieee754dp y);
+union ieee754dp ieee754dp_sub(union ieee754dp x, union ieee754dp y);
+union ieee754dp ieee754dp_mul(union ieee754dp x, union ieee754dp y);
+union ieee754dp ieee754dp_div(union ieee754dp x, union ieee754dp y);
-ieee754dp ieee754dp_abs(ieee754dp x);
-ieee754dp ieee754dp_neg(ieee754dp x);
-ieee754dp ieee754dp_scalb(ieee754dp x, int);
+union ieee754dp ieee754dp_abs(union ieee754dp x);
+union ieee754dp ieee754dp_neg(union ieee754dp x);
+union ieee754dp ieee754dp_scalb(union ieee754dp x, int);
/* return exponent as integer in floating point format
*/
-ieee754dp ieee754dp_logb(ieee754dp x);
+union ieee754dp ieee754dp_logb(union ieee754dp x);
-ieee754dp ieee754dp_fint(int x);
-ieee754dp ieee754dp_funs(unsigned x);
-ieee754dp ieee754dp_flong(s64 x);
-ieee754dp ieee754dp_fulong(u64 x);
-ieee754dp ieee754dp_fsp(ieee754sp x);
+union ieee754dp ieee754dp_fint(int x);
+union ieee754dp ieee754dp_funs(unsigned x);
+union ieee754dp ieee754dp_flong(s64 x);
+union ieee754dp ieee754dp_fulong(u64 x);
+union ieee754dp ieee754dp_fsp(union ieee754sp x);
-ieee754dp ieee754dp_ceil(ieee754dp x);
-ieee754dp ieee754dp_floor(ieee754dp x);
-ieee754dp ieee754dp_trunc(ieee754dp x);
+union ieee754dp ieee754dp_ceil(union ieee754dp x);
+union ieee754dp ieee754dp_floor(union ieee754dp x);
+union ieee754dp ieee754dp_trunc(union ieee754dp x);
-int ieee754dp_tint(ieee754dp x);
-unsigned int ieee754dp_tuns(ieee754dp x);
-s64 ieee754dp_tlong(ieee754dp x);
-u64 ieee754dp_tulong(ieee754dp x);
+int ieee754dp_tint(union ieee754dp x);
+unsigned int ieee754dp_tuns(union ieee754dp x);
+s64 ieee754dp_tlong(union ieee754dp x);
+u64 ieee754dp_tulong(union ieee754dp x);
-int ieee754dp_cmp(ieee754dp x, ieee754dp y, int cop, int sig);
+int ieee754dp_cmp(union ieee754dp x, union ieee754dp y, int cop, int sig);
/*
* basic sp math
*/
-ieee754dp ieee754dp_modf(ieee754dp x, ieee754dp * ip);
-ieee754dp ieee754dp_frexp(ieee754dp x, int *exp);
-ieee754dp ieee754dp_ldexp(ieee754dp x, int exp);
+union ieee754dp ieee754dp_modf(union ieee754dp x, union ieee754dp * ip);
+union ieee754dp ieee754dp_frexp(union ieee754dp x, int *exp);
+union ieee754dp ieee754dp_ldexp(union ieee754dp x, int exp);
-ieee754dp ieee754dp_ceil(ieee754dp x);
-ieee754dp ieee754dp_floor(ieee754dp x);
-ieee754dp ieee754dp_trunc(ieee754dp x);
+union ieee754dp ieee754dp_ceil(union ieee754dp x);
+union ieee754dp ieee754dp_floor(union ieee754dp x);
+union ieee754dp ieee754dp_trunc(union ieee754dp x);
-ieee754dp ieee754dp_sqrt(ieee754dp x);
+union ieee754dp ieee754dp_sqrt(union ieee754dp x);
/* "normal" comparisons
*/
-static inline int ieee754sp_eq(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_eq(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y, IEEE754_CEQ, 0);
}
-static inline int ieee754sp_ne(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_ne(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y,
IEEE754_CLT | IEEE754_CGT | IEEE754_CUN, 0);
}
-static inline int ieee754sp_lt(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_lt(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y, IEEE754_CLT, 0);
}
-static inline int ieee754sp_le(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_le(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y, IEEE754_CLT | IEEE754_CEQ, 0);
}
-static inline int ieee754sp_gt(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_gt(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y, IEEE754_CGT, 0);
}
-static inline int ieee754sp_ge(ieee754sp x, ieee754sp y)
+static inline int ieee754sp_ge(union ieee754sp x, union ieee754sp y)
{
return ieee754sp_cmp(x, y, IEEE754_CGT | IEEE754_CEQ, 0);
}
-static inline int ieee754dp_eq(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_eq(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y, IEEE754_CEQ, 0);
}
-static inline int ieee754dp_ne(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_ne(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y,
IEEE754_CLT | IEEE754_CGT | IEEE754_CUN, 0);
}
-static inline int ieee754dp_lt(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_lt(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y, IEEE754_CLT, 0);
}
-static inline int ieee754dp_le(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_le(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y, IEEE754_CLT | IEEE754_CEQ, 0);
}
-static inline int ieee754dp_gt(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_gt(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y, IEEE754_CGT, 0);
}
-static inline int ieee754dp_ge(ieee754dp x, ieee754dp y)
+static inline int ieee754dp_ge(union ieee754dp x, union ieee754dp y)
{
return ieee754dp_cmp(x, y, IEEE754_CGT | IEEE754_CEQ, 0);
}
/*
* Like strtod
*/
-ieee754dp ieee754dp_fstr(const char *s, char **endp);
-char *ieee754dp_tstr(ieee754dp x, int prec, int fmt, int af);
+union ieee754dp ieee754dp_fstr(const char *s, char **endp);
+char *ieee754dp_tstr(union ieee754dp x, int prec, int fmt, int af);
/*
}
/* debugging */
-ieee754sp ieee754sp_dump(char *s, ieee754sp x);
-ieee754dp ieee754dp_dump(char *s, ieee754dp x);
+union ieee754sp ieee754sp_dump(char *s, union ieee754sp x);
+union ieee754dp ieee754dp_dump(char *s, union ieee754dp x);
#define IEEE754_SPCVAL_PZERO 0
#define IEEE754_SPCVAL_NZERO 1
extern const struct ieee754dp_const __ieee754dp_spcvals[];
extern const struct ieee754sp_const __ieee754sp_spcvals[];
-#define ieee754dp_spcvals ((const ieee754dp *)__ieee754dp_spcvals)
-#define ieee754sp_spcvals ((const ieee754sp *)__ieee754sp_spcvals)
+#define ieee754dp_spcvals ((const union ieee754dp *)__ieee754dp_spcvals)
+#define ieee754sp_spcvals ((const union ieee754sp *)__ieee754sp_spcvals)
/*
* Return infinity with given sign
const char *op; /* operation name */
int rt; /* result type */
union {
- ieee754sp sp; /* single precision */
- ieee754dp dp; /* double precision */
+ union ieee754sp sp; /* single precision */
+ union ieee754dp dp; /* double precision */
#ifdef IEEE854_XP
ieee754xp xp; /* extended precision */
#endif
#define DPBEXP(dp) (dp.parts.bexp)
#define DPMANT(dp) (dp.parts.mant)
-ieee754dp ieee754dp_dump(char *m, ieee754dp x)
+union ieee754dp ieee754dp_dump(char *m, union ieee754dp x)
{
int i;
return x;
}
-ieee754sp ieee754sp_dump(char *m, ieee754sp x)
+union ieee754sp ieee754sp_dump(char *m, union ieee754sp x)
{
int i;
#include "ieee754dp.h"
-int ieee754dp_class(ieee754dp x)
+int ieee754dp_class(union ieee754dp x)
{
COMPXDP;
EXPLODEXDP;
return xc;
}
-int ieee754dp_isnan(ieee754dp x)
+int ieee754dp_isnan(union ieee754dp x)
{
return ieee754dp_class(x) >= IEEE754_CLASS_SNAN;
}
-int ieee754dp_issnan(ieee754dp x)
+int ieee754dp_issnan(union ieee754dp x)
{
assert(ieee754dp_isnan(x));
return ((DPMANT(x) & DP_MBIT(DP_MBITS-1)) == DP_MBIT(DP_MBITS-1));
}
-ieee754dp __cold ieee754dp_xcpt(ieee754dp r, const char *op, ...)
+union ieee754dp __cold ieee754dp_xcpt(union ieee754dp r, const char *op, ...)
{
struct ieee754xctx ax;
if (!TSTX())
return ax.rv.dp;
}
-ieee754dp __cold ieee754dp_nanxcpt(ieee754dp r, const char *op, ...)
+union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp r, const char *op, ...)
{
struct ieee754xctx ax;
return ax.rv.dp;
}
-ieee754dp ieee754dp_bestnan(ieee754dp x, ieee754dp y)
+union ieee754dp ieee754dp_bestnan(union ieee754dp x, union ieee754dp y)
{
assert(ieee754dp_isnan(x));
assert(ieee754dp_isnan(y));
* xe is an unbiased exponent
* xm is 3bit extended precision value.
*/
-ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
+union ieee754dp ieee754dp_format(int sn, int xe, u64 xm)
{
assert(xm); /* we don't gen exact zeros (probably should) */
#define DPDNORMX DPDNORMx(xm, xe)
#define DPDNORMY DPDNORMx(ym, ye)
-static inline ieee754dp builddp(int s, int bx, u64 m)
+static inline union ieee754dp builddp(int s, int bx, u64 m)
{
- ieee754dp r;
+ union ieee754dp r;
assert((s) == 0 || (s) == 1);
assert((bx) >= DP_EMIN - 1 + DP_EBIAS
return r;
}
-extern int ieee754dp_isnan(ieee754dp);
-extern int ieee754dp_issnan(ieee754dp);
+extern int ieee754dp_isnan(union ieee754dp);
+extern int ieee754dp_issnan(union ieee754dp);
extern int __cold ieee754si_xcpt(int, const char *, ...);
extern s64 __cold ieee754di_xcpt(s64, const char *, ...);
-extern ieee754dp __cold ieee754dp_xcpt(ieee754dp, const char *, ...);
-extern ieee754dp __cold ieee754dp_nanxcpt(ieee754dp, const char *, ...);
-extern ieee754dp ieee754dp_bestnan(ieee754dp, ieee754dp);
-extern ieee754dp ieee754dp_format(int, int, u64);
+extern union ieee754dp __cold ieee754dp_xcpt(union ieee754dp, const char *, ...);
+extern union ieee754dp __cold ieee754dp_nanxcpt(union ieee754dp, const char *, ...);
+extern union ieee754dp ieee754dp_bestnan(union ieee754dp, union ieee754dp);
+extern union ieee754dp ieee754dp_format(int, int, u64);
#define DPNORMRET2(s, e, m, name, a0, a1) \
{ \
- ieee754dp V = ieee754dp_format(s, e, m); \
+ union ieee754dp V = ieee754dp_format(s, e, m); \
if(TSTX()) \
return ieee754dp_xcpt(V, name, a0, a1); \
else \
#include "ieee754.h"
-ieee754dp ieee754dp_floor(ieee754dp x)
+union ieee754dp ieee754dp_floor(union ieee754dp x)
{
- ieee754dp i;
+ union ieee754dp i;
if (ieee754dp_lt(ieee754dp_modf(x, &i), ieee754dp_zero(0)))
return ieee754dp_sub(i, ieee754dp_one(0));
return i;
}
-ieee754dp ieee754dp_ceil(ieee754dp x)
+union ieee754dp ieee754dp_ceil(union ieee754dp x)
{
- ieee754dp i;
+ union ieee754dp i;
if (ieee754dp_gt(ieee754dp_modf(x, &i), ieee754dp_zero(0)))
return ieee754dp_add(i, ieee754dp_one(0));
return i;
}
-ieee754dp ieee754dp_trunc(ieee754dp x)
+union ieee754dp ieee754dp_trunc(union ieee754dp x)
{
- ieee754dp i;
+ union ieee754dp i;
(void) ieee754dp_modf(x, &i);
return i;
#include "ieee754sp.h"
-int ieee754sp_class(ieee754sp x)
+int ieee754sp_class(union ieee754sp x)
{
COMPXSP;
EXPLODEXSP;
return xc;
}
-int ieee754sp_isnan(ieee754sp x)
+int ieee754sp_isnan(union ieee754sp x)
{
return ieee754sp_class(x) >= IEEE754_CLASS_SNAN;
}
-int ieee754sp_issnan(ieee754sp x)
+int ieee754sp_issnan(union ieee754sp x)
{
assert(ieee754sp_isnan(x));
return (SPMANT(x) & SP_MBIT(SP_MBITS-1));
}
-ieee754sp __cold ieee754sp_xcpt(ieee754sp r, const char *op, ...)
+union ieee754sp __cold ieee754sp_xcpt(union ieee754sp r, const char *op, ...)
{
struct ieee754xctx ax;
return ax.rv.sp;
}
-ieee754sp __cold ieee754sp_nanxcpt(ieee754sp r, const char *op, ...)
+union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp r, const char *op, ...)
{
struct ieee754xctx ax;
return ax.rv.sp;
}
-ieee754sp ieee754sp_bestnan(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_bestnan(union ieee754sp x, union ieee754sp y)
{
assert(ieee754sp_isnan(x));
assert(ieee754sp_isnan(y));
* xe is an unbiased exponent
* xm is 3bit extended precision value.
*/
-ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
+union ieee754sp ieee754sp_format(int sn, int xe, unsigned xm)
{
assert(xm); /* we don't gen exact zeros (probably should) */
#define SPDNORMX SPDNORMx(xm, xe)
#define SPDNORMY SPDNORMx(ym, ye)
-static inline ieee754sp buildsp(int s, int bx, unsigned m)
+static inline union ieee754sp buildsp(int s, int bx, unsigned m)
{
- ieee754sp r;
+ union ieee754sp r;
assert((s) == 0 || (s) == 1);
assert((bx) >= SP_EMIN - 1 + SP_EBIAS
return r;
}
-extern int ieee754sp_isnan(ieee754sp);
-extern int ieee754sp_issnan(ieee754sp);
+extern int ieee754sp_isnan(union ieee754sp);
+extern int ieee754sp_issnan(union ieee754sp);
extern int __cold ieee754si_xcpt(int, const char *, ...);
extern s64 __cold ieee754di_xcpt(s64, const char *, ...);
-extern ieee754sp __cold ieee754sp_xcpt(ieee754sp, const char *, ...);
-extern ieee754sp __cold ieee754sp_nanxcpt(ieee754sp, const char *, ...);
-extern ieee754sp ieee754sp_bestnan(ieee754sp, ieee754sp);
-extern ieee754sp ieee754sp_format(int, int, unsigned);
+extern union ieee754sp __cold ieee754sp_xcpt(union ieee754sp, const char *, ...);
+extern union ieee754sp __cold ieee754sp_nanxcpt(union ieee754sp, const char *, ...);
+extern union ieee754sp ieee754sp_bestnan(union ieee754sp, union ieee754sp);
+extern union ieee754sp ieee754sp_format(int, int, unsigned);
#define SPNORMRET2(s, e, m, name, a0, a1) \
{ \
- ieee754sp V = ieee754sp_format(s, e, m); \
+ union ieee754sp V = ieee754sp_format(s, e, m); \
if(TSTX()) \
return ieee754sp_xcpt(V, name, a0, a1); \
else \
#include "ieee754sp.h"
-ieee754sp ieee754sp_add(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_add(union ieee754sp x, union ieee754sp y)
{
COMPXSP;
COMPYSP;
#include "ieee754sp.h"
-int ieee754sp_cmp(ieee754sp x, ieee754sp y, int cmp, int sig)
+int ieee754sp_cmp(union ieee754sp x, union ieee754sp y, int cmp, int sig)
{
COMPXSP;
COMPYSP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_div(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_div(union ieee754sp x, union ieee754sp y)
{
COMPXSP;
COMPYSP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_fdp(ieee754dp x)
+union ieee754sp ieee754sp_fdp(union ieee754dp x)
{
COMPXDP;
- ieee754sp nan;
+ union ieee754sp nan;
EXPLODEXDP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_fint(int x)
+union ieee754sp ieee754sp_fint(int x)
{
unsigned xm;
int xe;
}
-ieee754sp ieee754sp_funs(unsigned int u)
+union ieee754sp ieee754sp_funs(unsigned int u)
{
if ((int) u < 0)
return ieee754sp_add(ieee754sp_1e31(),
#include "ieee754sp.h"
-ieee754sp ieee754sp_flong(s64 x)
+union ieee754sp ieee754sp_flong(s64 x)
{
u64 xm; /* <--- need 64-bit mantissa temp */
int xe;
}
-ieee754sp ieee754sp_fulong(u64 u)
+union ieee754sp ieee754sp_fulong(u64 u)
{
if ((s64) u < 0)
return ieee754sp_add(ieee754sp_1e63(),
/* close to ieeep754sp_logb
*/
-ieee754sp ieee754sp_frexp(ieee754sp x, int *eptr)
+union ieee754sp ieee754sp_frexp(union ieee754sp x, int *eptr)
{
COMPXSP;
CLEARCX;
#include "ieee754sp.h"
-ieee754sp ieee754sp_logb(ieee754sp x)
+union ieee754sp ieee754sp_logb(union ieee754sp x)
{
COMPXSP;
/* modf function is always exact for a finite number
*/
-ieee754sp ieee754sp_modf(ieee754sp x, ieee754sp *ip)
+union ieee754sp ieee754sp_modf(union ieee754sp x, union ieee754sp *ip)
{
COMPXSP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_mul(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_mul(union ieee754sp x, union ieee754sp y)
{
COMPXSP;
COMPYSP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_scalb(ieee754sp x, int n)
+union ieee754sp ieee754sp_scalb(union ieee754sp x, int n)
{
COMPXSP;
}
-ieee754sp ieee754sp_ldexp(ieee754sp x, int n)
+union ieee754sp ieee754sp_ldexp(union ieee754sp x, int n)
{
return ieee754sp_scalb(x, n);
}
#include "ieee754sp.h"
-int ieee754sp_finite(ieee754sp x)
+int ieee754sp_finite(union ieee754sp x)
{
return SPBEXP(x) != SP_EMAX + 1 + SP_EBIAS;
}
-ieee754sp ieee754sp_copysign(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_copysign(union ieee754sp x, union ieee754sp y)
{
CLEARCX;
SPSIGN(x) = SPSIGN(y);
}
-ieee754sp ieee754sp_neg(ieee754sp x)
+union ieee754sp ieee754sp_neg(union ieee754sp x)
{
COMPXSP;
SPSIGN(x) ^= 1;
if (xc == IEEE754_CLASS_SNAN) {
- ieee754sp y = ieee754sp_indef();
+ union ieee754sp y = ieee754sp_indef();
SETCX(IEEE754_INVALID_OPERATION);
SPSIGN(y) = SPSIGN(x);
return ieee754sp_nanxcpt(y, "neg");
}
-ieee754sp ieee754sp_abs(ieee754sp x)
+union ieee754sp ieee754sp_abs(union ieee754sp x)
{
COMPXSP;
#include "ieee754sp.h"
-ieee754sp ieee754sp_sqrt(ieee754sp x)
+union ieee754sp ieee754sp_sqrt(union ieee754sp x)
{
int ix, s, q, m, t, i;
unsigned int r;
#include "ieee754sp.h"
-ieee754sp ieee754sp_sub(ieee754sp x, ieee754sp y)
+union ieee754sp ieee754sp_sub(union ieee754sp x, union ieee754sp y)
{
COMPXSP;
COMPYSP;
#include <linux/kernel.h>
#include "ieee754sp.h"
-int ieee754sp_tint(ieee754sp x)
+int ieee754sp_tint(union ieee754sp x)
{
COMPXSP;
}
-unsigned int ieee754sp_tuns(ieee754sp x)
+unsigned int ieee754sp_tuns(union ieee754sp x)
{
- ieee754sp hb = ieee754sp_1e31();
+ union ieee754sp hb = ieee754sp_1e31();
/* what if x < 0 ?? */
if (ieee754sp_lt(x, hb))
#include "ieee754sp.h"
-s64 ieee754sp_tlong(ieee754sp x)
+s64 ieee754sp_tlong(union ieee754sp x)
{
COMPXDP; /* <-- need 64-bit mantissa tmp */
}
-u64 ieee754sp_tulong(ieee754sp x)
+u64 ieee754sp_tulong(union ieee754sp x)
{
- ieee754sp hb = ieee754sp_1e63();
+ union ieee754sp hb = ieee754sp_1e63();
/* what if x < 0 ?? */
if (ieee754sp_lt(x, hb))