History

Minimum changes to make all float variants of math.h functions work, by calling the double functions and removing unsupported __asm implementations using "=t". This patch also enables the double version of logb(double).

Tyge committed 6 years ago

Commit df67d861 parent c386ca91 file · +24 −38Browse files

Unified · Split

win32/include/math.h+24−38
@@ -198,12 +198,6 @@ extern "C" { · 197 unmodified lines
198198 #endif
199199
200200 #ifndef __cplusplus
201− __CRT_INLINE long double __cdecl fabsl (long double x)
202− {
203− long double res;
204− __asm__ ("fabs;" : "=t" (res) : "0" (x));
205− return res;
206− }
207201 #define _hypotl(x,y) ((long double)_hypot((double)(x),(double)(y)))
208202 #define _matherrl _matherr
209203 __CRT_INLINE long double _chgsignl(long double _Number) { return _chgsign((double)(_Number)); }
@@ -211,14 +205,31 @@ extern "C" { · 1 unmodified line
211205 __CRT_INLINE float frexpf(float _X,int *_Y) { return ((float)frexp((double)_X,_Y)); }
212206
213207 #if !defined (__ia64__)
214− __CRT_INLINE float __cdecl fabsf (float x)
215− {
216− float res;
217− __asm__ ("fabs;" : "=t" (res) : "0" (x));
218− return res;
208+ __CRT_INLINE float fabsf(float x) { return (float) fabs(x); }
209+ __CRT_INLINE float ldexpf(float x, int expn) { return (float) ldexp(x, expn); }
210+ __CRT_INLINE float acosf(float x) { return (float) acos(x); }
211+ __CRT_INLINE float asinf(float x) { return (float) asin(x); }
212+ __CRT_INLINE float atanf(float x) { return (float) atan(x); }
213+ __CRT_INLINE float atan2f(float x, float y) { return (float) atan2(x, y); }
214+ __CRT_INLINE float ceilf(float x) { return (float) ceil(x); }
215+ __CRT_INLINE float cosf(float x) { return (float) cos(x); }
216+ __CRT_INLINE float coshf(float x) { return (float) cosh(x); }
217+ __CRT_INLINE float expf(float x) { return (float) exp(x); }
218+ __CRT_INLINE float floorf(float x) { return (float) floor(x); }
219+ __CRT_INLINE float fmodf(float x, float y) { return (float) fmod(x, y); }
220+ __CRT_INLINE float logf(float x) { return (float) log(x); }
221+ __CRT_INLINE float logbf(float x) { return (float) logb(x); }
222+ __CRT_INLINE float log10f(float x) { return (float) log10(x); }
223+ __CRT_INLINE float modff(float x, float *y) {
224+ double di, df = modf(x, &di);
225+ *y = (float) di; return (float) df;
219226 }
220−
221− __CRT_INLINE float __cdecl ldexpf (float x, int expn) { return (float) ldexp (x, expn); }
227+ __CRT_INLINE float powf(float x, float y) { return (float) pow(x, y); }
228+ __CRT_INLINE float sinf(float x) { return (float) sin(x); }
229+ __CRT_INLINE float sinhf(float x) { return (float) sinh(x); }
230+ __CRT_INLINE float sqrtf(float x) { return (float) sqrt(x); }
231+ __CRT_INLINE float tanf(float x) { return (float) tan(x); }
232+ __CRT_INLINE float tanhf(float x) { return (float) tanh(x); }
222233 #endif
223234 #else
224235 // cplusplus
@@ -366,31 +377,6 @@ extern "C" { · 141 unmodified lines
366377 extern double __cdecl logb (double);
367378 extern float __cdecl logbf (float);
368379 extern long double __cdecl logbl (long double);
369−
370− __CRT_INLINE double __cdecl logb (double x)
371− {
372− double res;
373− __asm__ ("fxtract\n\t"
374− "fstp %%st" : "=t" (res) : "0" (x));
375− return res;
376− }
377−
378− __CRT_INLINE float __cdecl logbf (float x)
379− {
380− float res;
381− __asm__ ("fxtract\n\t"
382− "fstp %%st" : "=t" (res) : "0" (x));
383− return res;
384− }
385−
386− __CRT_INLINE long double __cdecl logbl (long double x)
387− {
388− long double res;
389− __asm__ ("fxtract\n\t"
390− "fstp %%st" : "=t" (res) : "0" (x));
391− return res;
392− }
393−
394380 extern long double __cdecl modfl (long double, long double*);
395381
396382 /* 7.12.6.13 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t