| 1 |
/** |
| 2 |
* This file has no copyright assigned and is placed in the Public Domain. |
| 3 |
* This file is part of the mingw-w64 runtime package. |
| 4 |
* No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 |
*/ |
| 6 |
/* |
| 7 |
* Written by J.T. Conklin <[email protected]>. |
| 8 |
* Changes for long double by Ulrich Drepper <[email protected]> |
| 9 |
* Public domain. |
| 10 |
*/ |
| 11 |
|
| 12 |
#include <math.h> |
| 13 |
|
| 14 |
float |
| 15 |
logbf (float x) |
| 16 |
{ |
| 17 |
#ifdef __x86_64__ |
| 18 |
int v; |
| 19 |
__mingw_flt_type_t hlp; |
| 20 |
|
| 21 |
hlp.x = x; |
| 22 |
v = hlp.val & 0x7fffffff; /* high |x| */ |
| 23 |
if (!v) |
| 24 |
return (float)-1.0 / fabsf (x); |
| 25 |
if (v >= 0x7f800000) |
| 26 |
return x * x; |
| 27 |
if ((v >>= 23) == 0) |
| 28 |
return -127.0 - (__builtin_clzl(hlp.val & 0x7fffff) - 9); |
| 29 |
return (float) (v - 127); |
| 30 |
#else |
| 31 |
float res = 0.0F; |
| 32 |
asm volatile ( |
| 33 |
"fxtract\n\t" |
| 34 |
"fstp %%st" : "=t" (res) : "0" (x)); |
| 35 |
return res; |
| 36 |
#endif |
| 37 |
} |