summaryrefslogtreecommitdiff
path: root/lib/divsc3.c
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2011-11-16 07:33:06 +0000
committerDaniel Dunbar <daniel@zuster.org>2011-11-16 07:33:06 +0000
commitc25c6d10b18efa071f0016f31f6f3dd8a8fa6676 (patch)
treebfbcd9b0cdf523b4f8d8e54750dbf9d6dece3c85 /lib/divsc3.c
parent8603024a01cfa82ab8dce397f40a2d6f246076e3 (diff)
downloadcompiler-rt-c25c6d10b18efa071f0016f31f6f3dd8a8fa6676.tar.gz
lib: Finish int_math.h definitions using compiler builtins and eliminate
implementation use of <math.h>. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@144786 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/divsc3.c')
-rw-r--r--lib/divsc3.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/divsc3.c b/lib/divsc3.c
index 88e2e0943..caa0c4075 100644
--- a/lib/divsc3.c
+++ b/lib/divsc3.c
@@ -14,7 +14,6 @@
#include "int_lib.h"
#include "int_math.h"
-#include <math.h>
/* Returns: the quotient of (a + ib) / (c + id) */
@@ -22,37 +21,37 @@ float _Complex
__divsc3(float __a, float __b, float __c, float __d)
{
int __ilogbw = 0;
- float __logbw = logbf(fmaxf(fabsf(__c), fabsf(__d)));
+ float __logbw = crt_logbf(crt_fmaxf(crt_fabsf(__c), crt_fabsf(__d)));
if (crt_isfinite(__logbw))
{
__ilogbw = (int)__logbw;
- __c = scalbnf(__c, -__ilogbw);
- __d = scalbnf(__d, -__ilogbw);
+ __c = crt_scalbnf(__c, -__ilogbw);
+ __d = crt_scalbnf(__d, -__ilogbw);
}
float __denom = __c * __c + __d * __d;
float _Complex z;
- __real__ z = scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
- __imag__ z = scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
+ __real__ z = crt_scalbnf((__a * __c + __b * __d) / __denom, -__ilogbw);
+ __imag__ z = crt_scalbnf((__b * __c - __a * __d) / __denom, -__ilogbw);
if (crt_isnan(__real__ z) && crt_isnan(__imag__ z))
{
if ((__denom == 0) && (!crt_isnan(__a) || !crt_isnan(__b)))
{
- __real__ z = copysignf(INFINITY, __c) * __a;
- __imag__ z = copysignf(INFINITY, __c) * __b;
+ __real__ z = crt_copysignf(CRT_INFINITY, __c) * __a;
+ __imag__ z = crt_copysignf(CRT_INFINITY, __c) * __b;
}
else if ((crt_isinf(__a) || crt_isinf(__b)) &&
crt_isfinite(__c) && crt_isfinite(__d))
{
- __a = copysignf(crt_isinf(__a) ? 1 : 0, __a);
- __b = copysignf(crt_isinf(__b) ? 1 : 0, __b);
- __real__ z = INFINITY * (__a * __c + __b * __d);
- __imag__ z = INFINITY * (__b * __c - __a * __d);
+ __a = crt_copysignf(crt_isinf(__a) ? 1 : 0, __a);
+ __b = crt_copysignf(crt_isinf(__b) ? 1 : 0, __b);
+ __real__ z = CRT_INFINITY * (__a * __c + __b * __d);
+ __imag__ z = CRT_INFINITY * (__b * __c - __a * __d);
}
else if (crt_isinf(__logbw) && __logbw > 0 &&
crt_isfinite(__a) && crt_isfinite(__b))
{
- __c = copysignf(crt_isinf(__c) ? 1 : 0, __c);
- __d = copysignf(crt_isinf(__d) ? 1 : 0, __d);
+ __c = crt_copysignf(crt_isinf(__c) ? 1 : 0, __c);
+ __d = crt_copysignf(crt_isinf(__d) ? 1 : 0, __d);
__real__ z = 0 * (__a * __c + __b * __d);
__imag__ z = 0 * (__b * __c - __a * __d);
}