Commit: 24cbead998946bc0f165937fee56ab3a5cad73ad
Parent: 7731cc2627da2f49545f4a8b32a02cc2cf6540db
Author: Randy Palamar
Date: Sat, 28 Dec 2024 22:41:55 -0700
stb_truetype: replace math operations with compiler builtins
Diffstat:
1 file changed, 7 insertions(+), 23 deletions(-)
diff --git a/extern/stb_truetype.h b/extern/stb_truetype.h
@@ -270,29 +270,13 @@
typedef u32 stbtt_uint32;
typedef i32 stbtt_int32;
- // e.g. #define your own STBTT_ifloor/STBTT_iceil() to avoid math.h
- #ifndef STBTT_ifloor
- #include <math.h>
- #define STBTT_ifloor(x) ((int) floor(x))
- #define STBTT_iceil(x) ((int) ceil(x))
- #endif
-
- #ifndef STBTT_sqrt
- #include <math.h>
- #define STBTT_sqrt(x) sqrt(x)
- #define STBTT_pow(x,y) pow(x,y)
- #endif
-
- #ifndef STBTT_fmod
- #include <math.h>
- #define STBTT_fmod(x,y) fmod(x,y)
- #endif
-
- #ifndef STBTT_cos
- #include <math.h>
- #define STBTT_cos(x) cos(x)
- #define STBTT_acos(x) acos(x)
- #endif
+ #define STBTT_ifloor(x) ((int)__builtin_floorf(x))
+ #define STBTT_iceil(x) ((int)__builtin_ceilf(x))
+ #define STBTT_sqrt(x) __builtin_sqrtf(x)
+ #define STBTT_pow(x,y) __builtin_powf(x,y)
+ #define STBTT_fmod(x,y) __builtin_fmodf(x,y)
+ #define STBTT_cos(x) __builtin_cosf(x)
+ #define STBTT_acos(x) __builtin_acosf(x)
#define STBTT_fabs(x) ABS(x)
#define STBTT_assert(x) ASSERT(x)