mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-23 15:25:19 -04:00
add FLT_MAX, FLT_EPSILON, NAN, and HUGE_VALF to MSL_C headers (#316)
This commit is contained in:
@@ -21,6 +21,11 @@
|
||||
// TODO: OK?
|
||||
#define __signbitd(x) ((*(unsigned char*)&(x)) & 0x80)
|
||||
|
||||
extern unsigned long __float_nan[];
|
||||
extern unsigned long __float_huge[];
|
||||
extern unsigned long __float_max[];
|
||||
extern unsigned long __float_epsilon[];
|
||||
|
||||
inline int __fpclassifyf(float __value) {
|
||||
unsigned long integer = *(unsigned long*)&__value;
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
#ifndef MSL_FLOAT_H_
|
||||
#define MSL_FLOAT_H_
|
||||
|
||||
#include "MSL_C/MSL_Common/Src/float.h"
|
||||
|
||||
#define FLT_MAX (*(float*) __float_max)
|
||||
#define FLT_EPSILON (*(float*) __float_epsilon)
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "MSL_C/MSL_Common/Src/float.h"
|
||||
|
||||
#define NAN (*(float*) __float_nan)
|
||||
#define HUGE_VALF (*(float*) __float_huge)
|
||||
|
||||
#define M_PI 3.14159265358979323846f
|
||||
|
||||
#define DEG_TO_RAD(degrees) (degrees * (M_PI / 180.0f))
|
||||
@@ -50,10 +53,6 @@ double sqrt(double);
|
||||
double tan(double);
|
||||
float tanf(float);
|
||||
|
||||
extern float __float_nan[4];
|
||||
extern float __float_epsilon[4];
|
||||
extern float __float_max[4];
|
||||
|
||||
inline double sqrt_step(double tmpd, float mag) {
|
||||
return tmpd * 0.5 * (3.0 - mag * (tmpd * tmpd));
|
||||
}
|
||||
@@ -66,9 +65,9 @@ inline float sqrtf(float mag) {
|
||||
tmpd = sqrt_step(tmpd, mag);
|
||||
return mag * tmpd;
|
||||
} else if (mag < 0.0) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else if (fpclassify(mag) == 1) {
|
||||
return __float_nan[0];
|
||||
return NAN;
|
||||
} else {
|
||||
return mag;
|
||||
}
|
||||
|
||||
@@ -80,10 +80,8 @@
|
||||
#define _HUGE_ENUF 1e+300
|
||||
#define INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
|
||||
#define HUGE_VAL ((double)INFINITY)
|
||||
#define HUGE_VALF ((float)INFINITY)
|
||||
#define HUGE_VALL ((long double)INFINITY)
|
||||
|
||||
#define FLOAT_INF HUGE_VALF
|
||||
#define DOUBLE_INF HUGE_VAL
|
||||
|
||||
#pragma section ".dead"
|
||||
|
||||
Reference in New Issue
Block a user