forked from pahihu/t4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredmath.h
114 lines (98 loc) · 2.23 KB
/
redmath.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#ifndef _REDMATH_H
#define _REDMATH_H
#include <stdint.h>
#if defined(_MSC_VER) || (defined(__linux__) && !defined(TLOSS))
struct exception {
int type;
char *name;
double arg1;
double arg2;
double retval;
};
#endif
#ifndef HUGE
#include <math.h>
#define HUGE 0x1.fffffep+127f
#endif
#ifndef TLOSS
#define DOMAIN 1
#define SING 2
#define OVERFLOW 3
#define UNDERFLOW 4
#define TLOSS 5
#define PLOSS 6
#endif
double __kernel_standard(double,double,int);
double fdm_ldexp(double,int);
float fdm_ldexpf(float,int);
double fdm_scalbn(double,int);
float fdm_scalbnf(float,int);
double ieee754_remainder(double,double);
double ieee754_fmod(double,double);
double ieee754_sqrt(double);
double fdm_remainder(double,double);
double fdm_sqrt(double);
#define _IEEE_ 0
#define _SVID_ 1
#define _XOPEN_ 2
#define _POSIX_ 3
#ifndef _LIB_VERSION
#define _LIB_VERSION _POSIX_
#endif
#define EXTRACT_WORDS(hi,lo,x) \
{ \
union { \
uint64_t bits; \
double fp; \
} r64; \
r64.fp = (x); \
lo = r64.bits & 0xffffffffULL; \
hi = (r64.bits >> 32) & 0xffffffffULL; \
}
#define GET_HIGH_WORD(hi,x) \
{ \
union { \
uint64_t bits; \
double fp; \
} r64; \
r64.fp = (x); \
hi = (r64.bits >> 32) & 0xffffffffULL; \
}
#define SET_HIGH_WORD(x,hi) \
{ \
union { \
uint64_t bits; \
double fp; \
} r64; \
r64.fp = (x); \
r64.bits = (((uint64_t) ((hi) & 0xffffffffUL)) << 32) | (r64.bits & 0xffffffffULL); \
x = r64.fp; \
}
#define INSERT_WORDS(x,hi,lo) \
{ \
union { \
uint64_t bits; \
double fp; \
} r64; \
r64.bits = (((uint64_t) ((hi) & 0xffffffffUL)) << 32) | ((lo) & 0xffffffffUL); \
x = r64.fp; \
}
#define GET_FLOAT_WORD(ix,x) \
{ \
union { \
int32_t bits; \
float fp; \
} r32; \
r32.fp = (x); \
ix = r32.bits; \
}
#define SET_FLOAT_WORD(x,ix) \
{ \
union { \
int32_t bits; \
float fp; \
} r32; \
r32.bits = (ix); \
x = r32.fp; \
}
#endif