History

Cleanup and minor fixes in win32/tcc/tcc_libm.h: truncf(), cbrtf(), exp2f(), log2f(), scalbln*()

Tyge Løvset committed 5 years ago

Commit 3b1a42e1 parent b11144d1 file · +21 −48Browse files

Unified · Split

win32/include/tcc/tcc_libm.h+21−48
@@ -252,12 +252,13 @@ __CRT_INLINE long double __cdecl scalbnl(long double x, int n) { · 251 unmodified lines
252252 }
253253
254254 __CRT_INLINE double __cdecl scalbln(double x, long n) {
255− int m = n > INT_MAX ? INT_MAX : (n < INT_MIN ? INT_MIN : n);
256− return scalbn(x, m);
255+ return scalbn(x, n);
257256 }
258257 __CRT_INLINE float __cdecl scalblnf(float x, long n) {
259− int m = n > INT_MAX ? INT_MAX : (n < INT_MIN ? INT_MIN : n);
260− return scalbn(x, m);
258+ return scalbn(x, n);
259+}
260+__CRT_INLINE long double __cdecl scalblnl(long double x, long n) {
261+ return scalbn(x, n);
261262 }
262263
263264
@@ -293,6 +294,9 @@ __CRT_INLINE float __cdecl rintf(float x) { · 29 unmodified lines
293294 "fstps %0\n" : "=m" (retval) : "m" (x));
294295 return retval;
295296 }
297+__CRT_INLINE long double __cdecl rintl (long double x) {
298+ return rint(x);
299+}
296300
297301
298302 /* 7.12.9.5 */
@@ -312,6 +316,11 @@ __CRT_INLINE long __cdecl lrintf(float x) { · 13 unmodified lines
312316 return retval;
313317 }
314318
319+__CRT_INLINE long __cdecl lrintl (long double x) {
320+ return lrint(x);
321+}
322+
323+
315324 __CRT_INLINE long long __cdecl llrint(double x) {
316325 long long retval;
317326 __asm__ __volatile__
@@ -328,48 +337,12 @@ __CRT_INLINE long long __cdecl llrintf(float x) { · 10 unmodified lines
328337 return retval;
329338 }
330339
331−/*
332− __CRT_INLINE long double __cdecl rintl (long double x) {
333− long double retval;
334− __asm__ (
335− "fldt %1\n"
336− "frndint \n"
337− "fstpt %0\n" : "=m" (retval) : "m" (x));
338− return retval;
339− }
340− __CRT_INLINE long __cdecl lrintl (long double x) {
341− long retval;
342− __asm__ __volatile__
343− ("fldt %1\n"
344− "fistpl %0" : "=m" (retval) : "m" (x));
345− return retval;
346− }
347− __CRT_INLINE long long __cdecl llrintl (long double x) {
348− long long retval;
349− __asm__ __volatile__
350− ("fldt %1\n"
351− "fistpll %0" : "=m" (retval) : "m" (x));
352− return retval;
353− }
354− __CRT_INLINE float __cdecl fabsf (float x) {
355− float res;
356− __asm__ ("fabs;" : "=t" (res) : "0" (x));
357− return res;
358− }
359−*/
360−
361−__CRT_INLINE long double __cdecl rintl(long double x) {
362− return rint(x);
363−}
364−__CRT_INLINE long __cdecl lrintl(long double x) {
365− return lrint(x);
366−}
367−__CRT_INLINE long long __cdecl llrintl(long double x) {
340+__CRT_INLINE long long __cdecl llrintl (long double x) {
368341 return llrint(x);
369342 }
370343
371344
372−__CRT_INLINE double trunc(double _x) {
345+__CRT_INLINE double __cdecl trunc(double _x) {
373346 double retval;
374347 unsigned short saved_cw;
375348 unsigned short tmp_cw;
@@ -385,7 +358,7 @@ __CRT_INLINE double trunc(double _x) { · 9 unmodified lines
385358 }
386359
387360 __CRT_INLINE float __cdecl truncf(float x) {
388− return (float) ((int) x);
361+ return (float) ((intptr_t) x);
389362 }
390363 __CRT_INLINE long double __cdecl truncl(long double x) {
391364 return trunc(x);
@@ -498,13 +471,13 @@ __CRT_INLINE long double __cdecl expm1l(long double x) { · 106 unmodified lines
498471
499472
500473 __CRT_INLINE double __cdecl cbrt(double x) {
501− return (1 - ((x < 0.0) << 1)) * pow(fabs(x), 1/3.0);
474+ return copysign(pow(fabs(x), 1/3.0), x);
502475 }
503476 __CRT_INLINE float __cdecl cbrtf(float x) {
504− return (1 - ((x < 0.0f) << 1)) * powf(fabsf((float) x), 1/3.0f);
477+ return copysignf(pow(fabs(x), 1/3.0), x);
505478 }
506479 __CRT_INLINE long double __cdecl cbrtl(long double x) {
507− return (1 - ((x < 0.0) << 1)) * pow(fabs(x), 1/3.0);
480+ return copysign(pow(fabs(x), 1/3.0), x);
508481 }
509482
510483
@@ -512,7 +485,7 @@ __CRT_INLINE double __cdecl log2(double x) { · 1 unmodified line
512485 return log(x) * 1.4426950408889634073599246810019;
513486 }
514487 __CRT_INLINE float __cdecl log2f(float x) {
515− return logf(x) * 1.4426950408889634073599246810019f;
488+ return log(x) * 1.4426950408889634073599246810019;
516489 }
517490 __CRT_INLINE long double __cdecl log2l(long double x) {
518491 return log(x) * 1.4426950408889634073599246810019;
@@ -523,7 +496,7 @@ __CRT_INLINE double __cdecl exp2(double x) { · 4 unmodified lines
523496 return exp(x * 0.69314718055994530941723212145818);
524497 }
525498 __CRT_INLINE float __cdecl exp2f(float x) {
526− return expf(x * 0.69314718055994530941723212145818f);
499+ return exp(x * 0.69314718055994530941723212145818);
527500 }
528501 __CRT_INLINE long double __cdecl exp2l(long double x) {
529502 return exp(x * 0.69314718055994530941723212145818);

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