mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 09:35:23 -04:00
Make Math_AbsF/Math_SqrtF defines when compiling with gcc/clang. This way they get compiled to an inline intrinsic instruction, instead of a slow function call
This commit is contained in:
parent
1e7ee30156
commit
1a5f963ef0
@ -7,8 +7,11 @@
|
|||||||
|
|
||||||
/* TODO: Replace with own functions that don't rely on <math> */
|
/* TODO: Replace with own functions that don't rely on <math> */
|
||||||
|
|
||||||
|
#ifndef __GNUC__
|
||||||
float Math_AbsF(float x) { return fabsf(x); /* MSVC intrinsic */ }
|
float Math_AbsF(float x) { return fabsf(x); /* MSVC intrinsic */ }
|
||||||
float Math_SqrtF(float x) { return sqrtf(x); /* MSVC intrinsic */ }
|
float Math_SqrtF(float x) { return sqrtf(x); /* MSVC intrinsic */ }
|
||||||
|
#endif
|
||||||
|
|
||||||
float Math_Mod1(float x) { return x - (int)x; /* fmodf(x, 1); */ }
|
float Math_Mod1(float x) { return x - (int)x; /* fmodf(x, 1); */ }
|
||||||
int Math_AbsI(int x) { return abs(x); /* MSVC intrinsic */ }
|
int Math_AbsI(int x) { return abs(x); /* MSVC intrinsic */ }
|
||||||
|
|
||||||
|
@ -15,8 +15,16 @@
|
|||||||
#define Math_Deg2Packed(x) ((cc_uint8)((x) * 256.0f / 360.0f))
|
#define Math_Deg2Packed(x) ((cc_uint8)((x) * 256.0f / 360.0f))
|
||||||
#define Math_Packed2Deg(x) ((x) * 360.0f / 256.0f)
|
#define Math_Packed2Deg(x) ((x) * 360.0f / 256.0f)
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
/* fabsf/sqrtf are single intrinsic instructions in gcc/clang */
|
||||||
|
/* (sqrtf is only when -fno-math-errno though) */
|
||||||
|
#define Math_AbsF(x) __builtin_fabsf(x)
|
||||||
|
#define Math_SqrtF(x) __builtin_sqrtf(x)
|
||||||
|
#else
|
||||||
float Math_AbsF(float x);
|
float Math_AbsF(float x);
|
||||||
float Math_SqrtF(float x);
|
float Math_SqrtF(float x);
|
||||||
|
#endif
|
||||||
|
|
||||||
float Math_Mod1(float x);
|
float Math_Mod1(float x);
|
||||||
int Math_AbsI(int x);
|
int Math_AbsI(int x);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user