mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Use ARM's faster math functions on non-tiny builds
This commit is contained in:
parent
3c10fb5580
commit
4814b6bdf8
58 changed files with 3760 additions and 361 deletions
78
libc/tinymath/internal.h
Normal file
78
libc/tinymath/internal.h
Normal file
|
@ -0,0 +1,78 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_TINYMATH_INTERNAL_H_
|
||||
#define COSMOPOLITAN_LIBC_TINYMATH_INTERNAL_H_
|
||||
|
||||
#define WANT_ROUNDING 1
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define issignalingf_inline(x) 0
|
||||
#define issignaling_inline(x) 0
|
||||
|
||||
// clang-format off
|
||||
#define asuint(f) ((union{float _f; uint32_t _i;}){f})._i
|
||||
#define asfloat(i) ((union{uint32_t _i; float _f;}){i})._f
|
||||
#define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i
|
||||
#define asdouble(i) ((union{uint64_t _i; double _f;}){i})._f
|
||||
// clang-format on
|
||||
|
||||
static inline float eval_as_float(float x) {
|
||||
float y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline double eval_as_double(double x) {
|
||||
double y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline void fp_force_evall(long double x) {
|
||||
volatile long double y;
|
||||
y = x;
|
||||
}
|
||||
|
||||
static inline void fp_force_evalf(float x) {
|
||||
volatile float y;
|
||||
y = x;
|
||||
}
|
||||
|
||||
static inline void fp_force_eval(double x) {
|
||||
volatile double y;
|
||||
y = x;
|
||||
}
|
||||
|
||||
static inline double fp_barrier(double x) {
|
||||
volatile double y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
static inline float fp_barrierf(float x) {
|
||||
volatile float y = x;
|
||||
return y;
|
||||
}
|
||||
|
||||
double __math_divzero(uint32_t) hidden;
|
||||
double __math_invalid(double) hidden;
|
||||
double __math_oflow(uint32_t) hidden;
|
||||
double __math_uflow(uint32_t) hidden;
|
||||
double __math_xflow(uint32_t, double) hidden;
|
||||
float __math_divzerof(uint32_t) hidden;
|
||||
float __math_invalidf(float) hidden;
|
||||
float __math_oflowf(uint32_t) hidden;
|
||||
float __math_uflowf(uint32_t) hidden;
|
||||
float __math_xflowf(uint32_t, float) hidden;
|
||||
|
||||
#define FORCE_EVAL(x) \
|
||||
do { \
|
||||
if (sizeof(x) == sizeof(float)) { \
|
||||
fp_force_evalf(x); \
|
||||
} else if (sizeof(x) == sizeof(double)) { \
|
||||
fp_force_eval(x); \
|
||||
} else { \
|
||||
fp_force_evall(x); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_TINYMATH_INTERNAL_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue