77// TODO: make assembly equivalent for x64 (use intrinsic ?)
88#if defined(_MSC_VER) && defined(_M_IX86)
99 #define ASM_MATH_AVAILABLE (1 )
10- #define ASMVECTORCALL __declspec (naked) __vectorcall
10+ #define ASMNAKED __declspec (naked)
11+ #define ASMVECTORCALL __vectorcall
1112#elif defined(__GNUC__)
1213 #define ASM_MATH_AVAILABLE (1 )
1314 #if defined(__x86_64) || defined(__i386__)
14- #define ASMVECTORCALL inline __attribute__ ((__always_inline__))
15+ #define ASMNAKED inline __attribute__ ((__always_inline__))
1516 #else
16- #define ASMVECTORCALL inline
17+ #define ASMNAKED inline
1718 #endif
19+ #define ASMVECTORCALL
1820#else /* nor MSVC nor GCC/clang */
1921 #define ASM_MATH_AVAILABLE (0 )
2022#endif
2123
2224// XXX: this pow() implementation seems to suck for y > 4, regardless of float/double
2325
2426#if ASM_MATH_AVAILABLE == 1
25- static ASMVECTORCALL double fpuPow (double x, double y)
27+ static ASMNAKED double ASMVECTORCALL fpuPow (double x, double y)
2628{
2729#if defined(_MSC_VER) && defined(_M_IX86)
2830 __asm
@@ -105,7 +107,7 @@ static ASMVECTORCALL double fpuPow(double x, double y)
105107#endif /* MSVC/GNUC */
106108}
107109
108- static ASMVECTORCALL float fpuPowF (float x, float y)
110+ static ASMNAKED float ASMVECTORCALL fpuPowF (float x, float y)
109111{
110112#if defined(_MSC_VER) && defined(_M_IX86)
111113 __asm
@@ -189,7 +191,7 @@ static ASMVECTORCALL float fpuPowF(float x, float y)
189191#endif /* MSVC/GNUC */
190192}
191193
192- static ASMVECTORCALL double fpuCos (double x)
194+ static ASMNAKED double ASMVECTORCALL fpuCos (double x)
193195{
194196#if defined(_MSC_VER) && defined(_M_IX86)
195197 __asm
@@ -210,11 +212,11 @@ static ASMVECTORCALL double fpuCos(double x)
210212 #if defined(__x86_64__) || defined(__i386__)
211213 // not writing the *entire* function body in assembly actually helps
212214 // gcc and clang with inlining and LTO
213- // asm volatile("fcos\n":"+t"(x)::);
214- // return x;
215- return cos (x);
215+ asm volatile (" fcos\n " :" +t" (x)::);
216+ return x;
217+ // return cos(x);
216218 #else /* x86_64 */
217- return cos (x);/ / return __builtin_cos(x);
219+ /* return cos(x);* /return __builtin_cos (x);
218220 #endif /* GNUC, platform */
219221#endif /* MSVC/GNUC */
220222}
0 commit comments