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
252}252}
253 253
254__CRT_INLINE double __cdecl scalbln(double x, long n) {254__CRT_INLINE double __cdecl scalbln(double x, long n) {
255 int m = n > INT_MAX ? INT_MAX : (n < INT_MIN ? INT_MIN : n);255 return scalbn(x, n);
256 return scalbn(x, m);
257}256}
258__CRT_INLINE float __cdecl scalblnf(float x, long n) {257__CRT_INLINE float __cdecl scalblnf(float x, long n) {
259 int m = n > INT_MAX ? INT_MAX : (n < INT_MIN ? INT_MIN : n);258 return scalbn(x, n);
260 return scalbn(x, m);259}
260__CRT_INLINE long double __cdecl scalblnl(long double x, long n) {
261 return scalbn(x, n);
261}262}
262 263
263 264
@@ -293,6 +294,9 @@ __CRT_INLINE float __cdecl rintf(float x) { · 29 unmodified lines
293 "fstps %0\n" : "=m" (retval) : "m" (x));294 "fstps %0\n" : "=m" (retval) : "m" (x));
294 return retval;295 return retval;
295}296}
297__CRT_INLINE long double __cdecl rintl (long double x) {
298 return rint(x);
299}
296 300
297 301
298/* 7.12.9.5 */302/* 7.12.9.5 */
@@ -312,6 +316,11 @@ __CRT_INLINE long __cdecl lrintf(float x) { · 13 unmodified lines
312 return retval;316 return retval;
313}317}
314 318
319__CRT_INLINE long __cdecl lrintl (long double x) {
320 return lrint(x);
321}
322
323
315__CRT_INLINE long long __cdecl llrint(double x) {324__CRT_INLINE long long __cdecl llrint(double x) {
316long long retval;325long long retval;
317 __asm__ __volatile__326 __asm__ __volatile__
@@ -328,48 +337,12 @@ __CRT_INLINE long long __cdecl llrintf(float x) { · 10 unmodified lines
328 return retval;337 return retval;
329}338}
330 339
331/*340__CRT_INLINE long long __cdecl llrintl (long double x) {
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) {
368 return llrint(x);341 return llrint(x);
369}342}
370 343
371 344
372__CRT_INLINE double trunc(double _x) {345__CRT_INLINE double __cdecl trunc(double _x) {
373 double retval;346 double retval;
374 unsigned short saved_cw;347 unsigned short saved_cw;
375 unsigned short tmp_cw;348 unsigned short tmp_cw;
@@ -385,7 +358,7 @@ __CRT_INLINE double trunc(double _x) { · 9 unmodified lines
385}358}
386 359
387__CRT_INLINE float __cdecl truncf(float x) {360__CRT_INLINE float __cdecl truncf(float x) {
388 return (float) ((int) x);361 return (float) ((intptr_t) x);
389}362}
390__CRT_INLINE long double __cdecl truncl(long double x) {363__CRT_INLINE long double __cdecl truncl(long double x) {
391 return trunc(x);364 return trunc(x);
@@ -498,13 +471,13 @@ __CRT_INLINE long double __cdecl expm1l(long double x) { · 106 unmodified lines
498 471
499 472
500__CRT_INLINE double __cdecl cbrt(double x) {473__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);
502}475}
503__CRT_INLINE float __cdecl cbrtf(float x) {476__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);
505}478}
506__CRT_INLINE long double __cdecl cbrtl(long double x) {479__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);
508}481}
509 482
510 483
@@ -512,7 +485,7 @@ __CRT_INLINE double __cdecl log2(double x) { · 1 unmodified line
512 return log(x) * 1.4426950408889634073599246810019;485 return log(x) * 1.4426950408889634073599246810019;
513}486}
514__CRT_INLINE float __cdecl log2f(float x) {487__CRT_INLINE float __cdecl log2f(float x) {
515 return logf(x) * 1.4426950408889634073599246810019f;488 return log(x) * 1.4426950408889634073599246810019;
516}489}
517__CRT_INLINE long double __cdecl log2l(long double x) {490__CRT_INLINE long double __cdecl log2l(long double x) {
518 return log(x) * 1.4426950408889634073599246810019;491 return log(x) * 1.4426950408889634073599246810019;
@@ -523,7 +496,7 @@ __CRT_INLINE double __cdecl exp2(double x) { · 4 unmodified lines
523 return exp(x * 0.69314718055994530941723212145818);496 return exp(x * 0.69314718055994530941723212145818);
524}497}
525__CRT_INLINE float __cdecl exp2f(float x) {498__CRT_INLINE float __cdecl exp2f(float x) {
526 return expf(x * 0.69314718055994530941723212145818f);499 return exp(x * 0.69314718055994530941723212145818);
527}500}
528__CRT_INLINE long double __cdecl exp2l(long double x) {501__CRT_INLINE long double __cdecl exp2l(long double x) {
529 return exp(x * 0.69314718055994530941723212145818);502 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