From cc33b4a1ca7e0fec87eee48745c62dac21a7ff4b Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Sun, 21 Aug 2005 01:30:46 +0000 Subject: [PATCH] This adds the required functions to libroot.so and fixes DEBUG build. Unfortunately, they are pretty broken, so I added them into floatmath.c git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14019 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/math/floatmath.c | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/system/libroot/posix/math/floatmath.c b/src/system/libroot/posix/math/floatmath.c index 60e5f9a255..14d303ccae 100644 --- a/src/system/libroot/posix/math/floatmath.c +++ b/src/system/libroot/posix/math/floatmath.c @@ -46,6 +46,8 @@ float scalbf(float x, float n) {return (float)scalb((double)x, (double)n);}; double modf(double x, double *y) { + // TODO: this truncates to int precision and is broken! + // this should be implemented arch dependent! int integer = (int)x; *y = (double)integer; return x - integer; @@ -54,8 +56,39 @@ modf(double x, double *y) float modff(float x, float *y) { + // TODO: this truncates to int precision and is broken! + // this should be implemented arch dependent! double intpart = 0; float result = (float)modf((double)x, &intpart); *y = (float)intpart; return result; } + + +int +__signbitf(float value) +{ + // TODO: this is broken on most non x86 machines + // this should be implemented arch dependent! + union { float v; int i; } u = { v: value }; + return u.i < 0; +} + +int +__signbit(double value) +{ + // TODO: this is broken on most non x86 machines + // this should be implemented arch dependent! + union { double v; int i[2]; } u = { v: value }; + return u.i[1] < 0; +} + + +int +__signbitl(long double value) +{ + // TODO: this is broken on most non x86 machines + // this should be implemented arch dependent! + union { long double v; int i[2]; } u = { v: value }; + return (u.i[2] & 0x8000) != 0; +}