From 5412911f7f8ca41340b0f5cb928ed9726322ab44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Wed, 16 Nov 2005 18:33:51 +0000 Subject: [PATCH] added some x86 glibc functions (more to come) we might miss some wrappers for some ieee754 functions (to check) hope nothing is broken git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14968 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/libroot/posix/arch/x86/Jamfile | 1 - .../libroot/posix/glibc/arch/ppc/Jamfile | 16 ++- .../libroot/posix/glibc/arch/ppc/s_ceilf.c | 62 ++++++++ .../libroot/posix/glibc/arch/ppc/s_floorf.c | 71 ++++++++++ .../libroot/posix/glibc/arch/s_fpclassify.c | 43 ++++++ .../libroot/posix/glibc/arch/s_fpclassifyf.c | 43 ++++++ .../libroot/posix/glibc/arch/s_fpclassifyl.c | 45 ++++++ src/system/libroot/posix/glibc/arch/s_modf.c | 85 +++++++++++ src/system/libroot/posix/glibc/arch/s_modff.c | 66 +++++++++ src/system/libroot/posix/glibc/arch/s_modfl.c | 88 ++++++++++++ src/system/libroot/posix/glibc/arch/w_atan2.c | 47 +++++++ .../libroot/posix/glibc/arch/w_atan2f.c | 46 ++++++ .../libroot/posix/glibc/arch/w_atan2l.c | 47 +++++++ src/system/libroot/posix/glibc/arch/w_fmod.c | 48 +++++++ src/system/libroot/posix/glibc/arch/w_fmodf.c | 48 +++++++ src/system/libroot/posix/glibc/arch/w_fmodl.c | 48 +++++++ .../libroot/posix/glibc/arch/x86/Jamfile | 55 +++++++- .../libroot/posix/glibc/arch/x86/e_acos.S | 21 +++ .../libroot/posix/glibc/arch/x86/e_atan2.S | 17 +++ .../libroot/posix/glibc/arch/x86/e_atan2f.S | 15 ++ .../libroot/posix/glibc/arch/x86/e_atan2l.c | 18 +++ .../libroot/posix/glibc/arch/x86/e_fmod.S | 19 +++ .../libroot/posix/glibc/arch/x86/e_fmodf.S | 20 +++ .../libroot/posix/glibc/arch/x86/e_fmodl.c | 22 +++ .../libroot/posix/glibc/arch/x86/s_ceil.S | 32 +++++ .../libroot/posix/glibc/arch/x86/s_ceilf.S | 32 +++++ .../libroot/posix/glibc/arch/x86/s_ceill.S | 33 +++++ .../libroot/posix/glibc/arch/x86/s_copysign.S | 20 +++ .../posix/glibc/arch/x86/s_copysignf.S | 20 +++ .../posix/glibc/arch/x86/s_copysignl.S | 21 +++ .../libroot/posix/glibc/arch/x86/s_fabs.S | 9 ++ .../libroot/posix/glibc/arch/x86/s_fabsf.S | 9 ++ .../libroot/posix/glibc/arch/x86/s_fabsl.S | 9 ++ .../libroot/posix/glibc/arch/x86/s_fdim.S | 52 +++++++ .../libroot/posix/glibc/arch/x86/s_fdimf.S | 52 +++++++ .../libroot/posix/glibc/arch/x86/s_fdiml.S | 52 +++++++ .../libroot/posix/glibc/arch/x86/s_finite.S | 17 +++ .../libroot/posix/glibc/arch/x86/s_finitef.S | 16 +++ .../libroot/posix/glibc/arch/x86/s_finitel.S | 15 ++ .../libroot/posix/glibc/arch/x86/s_floor.S | 32 +++++ .../libroot/posix/glibc/arch/x86/s_floorf.S | 32 +++++ .../libroot/posix/glibc/arch/x86/s_floorl.S | 33 +++++ .../libroot/posix/glibc/arch/x86/s_logb.S | 16 +++ .../libroot/posix/glibc/arch/x86/s_logbf.S | 16 +++ .../libroot/posix/glibc/arch/x86/s_logbl.c | 19 +++ .../libroot/posix/glibc/arch/x86/s_rint.S | 15 ++ .../libroot/posix/glibc/arch/x86/s_rintf.S | 15 ++ .../libroot/posix/glibc/arch/x86/s_rintl.c | 18 +++ .../libroot/posix/glibc/arch/x86/s_scalbn.S | 19 +++ .../libroot/posix/glibc/arch/x86/s_scalbnf.S | 19 +++ .../libroot/posix/glibc/arch/x86/s_scalbnl.S | 20 +++ .../libroot/posix/glibc/include/math_ldbl.h | 90 ++++++++++++ .../libroot/posix/glibc/math/machine/asm.h | 10 ++ .../libroot/posix/glibc/math/math_private.h | 2 +- src/system/libroot/posix/math/Jamfile | 9 +- .../libroot/posix/math/arch/x86/Jamfile | 1 - src/system/libroot/posix/math/arch/x86/fabs.S | 50 ------- src/system/libroot/posix/math/ceilf.c | 55 -------- src/system/libroot/posix/math/floatmath.c | 56 -------- src/system/libroot/posix/math/floor.c | 133 ------------------ src/system/libroot/posix/math/floorf.c | 66 --------- src/system/libroot/posix/math/ieee.c | 3 + 62 files changed, 1731 insertions(+), 378 deletions(-) create mode 100644 src/system/libroot/posix/glibc/arch/ppc/s_ceilf.c create mode 100644 src/system/libroot/posix/glibc/arch/ppc/s_floorf.c create mode 100644 src/system/libroot/posix/glibc/arch/s_fpclassify.c create mode 100644 src/system/libroot/posix/glibc/arch/s_fpclassifyf.c create mode 100644 src/system/libroot/posix/glibc/arch/s_fpclassifyl.c create mode 100644 src/system/libroot/posix/glibc/arch/s_modf.c create mode 100644 src/system/libroot/posix/glibc/arch/s_modff.c create mode 100644 src/system/libroot/posix/glibc/arch/s_modfl.c create mode 100644 src/system/libroot/posix/glibc/arch/w_atan2.c create mode 100644 src/system/libroot/posix/glibc/arch/w_atan2f.c create mode 100644 src/system/libroot/posix/glibc/arch/w_atan2l.c create mode 100644 src/system/libroot/posix/glibc/arch/w_fmod.c create mode 100644 src/system/libroot/posix/glibc/arch/w_fmodf.c create mode 100644 src/system/libroot/posix/glibc/arch/w_fmodl.c create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_acos.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_atan2.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_atan2f.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_atan2l.c create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_fmod.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_fmodf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/e_fmodl.c create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_ceil.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_ceilf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_ceill.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_copysign.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_copysignf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_copysignl.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fabs.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fabsf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fabsl.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fdim.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fdimf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_fdiml.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_finite.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_finitef.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_finitel.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_floor.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_floorf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_floorl.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_logb.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_logbf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_logbl.c create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_rint.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_rintf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_rintl.c create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_scalbn.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_scalbnf.S create mode 100644 src/system/libroot/posix/glibc/arch/x86/s_scalbnl.S create mode 100644 src/system/libroot/posix/glibc/include/math_ldbl.h create mode 100644 src/system/libroot/posix/glibc/math/machine/asm.h delete mode 100644 src/system/libroot/posix/math/arch/x86/fabs.S delete mode 100644 src/system/libroot/posix/math/ceilf.c delete mode 100644 src/system/libroot/posix/math/floor.c delete mode 100644 src/system/libroot/posix/math/floorf.c diff --git a/src/system/libroot/posix/arch/x86/Jamfile b/src/system/libroot/posix/arch/x86/Jamfile index a2e1d411e9..059ca59bdd 100644 --- a/src/system/libroot/posix/arch/x86/Jamfile +++ b/src/system/libroot/posix/arch/x86/Jamfile @@ -5,6 +5,5 @@ KernelMergeObject posix_arch_$(TARGET_ARCH).o : setjmp_save_sigs.c sigsetjmp.S siglongjmp.S - : -fPIC -DPIC ; diff --git a/src/system/libroot/posix/glibc/arch/ppc/Jamfile b/src/system/libroot/posix/glibc/arch/ppc/Jamfile index 921a3e0676..48ca27b0b8 100644 --- a/src/system/libroot/posix/glibc/arch/ppc/Jamfile +++ b/src/system/libroot/posix/glibc/arch/ppc/Jamfile @@ -1,10 +1,14 @@ -SubDir HAIKU_TOP src system libroot posix arch x86 ; +SubDir HAIKU_TOP src system libroot posix arch ppc ; KernelMergeObject posix_arch_$(TARGET_ARCH).o : - setjmp.c - setjmp_save_sigs.c - sigsetjmp.S - siglongjmp.S - + s_ceilf.c + s_floorf.c + s_fpclassify.c + s_fpclassifyf.c + s_fpclassifyl.c : -fPIC -DPIC ; + +SEARCH on [ FGristFiles + s_fpclassify.c s_fpclassifyf.c s_fpclassifyl.c + ] = [ FDirName $(SUBDIR) $(DOTDOT) ] ; diff --git a/src/system/libroot/posix/glibc/arch/ppc/s_ceilf.c b/src/system/libroot/posix/glibc/arch/ppc/s_ceilf.c new file mode 100644 index 0000000000..29ccadb049 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/ppc/s_ceilf.c @@ -0,0 +1,62 @@ +/* s_ceilf.c -- float version of s_ceil.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_ceilf.c,v 1.4 1995/05/10 20:46:55 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float huge = 1.0e30; +#else +static float huge = 1.0e30; +#endif + +#ifdef __STDC__ + float __ceilf(float x) +#else + float __ceilf(x) + float x; +#endif +{ + int32_t i0,j0; + u_int32_t i; + + GET_FLOAT_WORD(i0,x); + j0 = ((i0>>23)&0xff)-0x7f; + if(j0<23) { + if(j0<0) { /* raise inexact if x != 0 */ + if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ + if(i0<0) {i0=0x80000000;} + else if(i0!=0) { i0=0x3f800000;} + } + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) return x; /* x is integral */ + if(huge+x>(float)0.0) { /* raise inexact flag */ + if(i0>0) i0 += (0x00800000)>>j0; + i0 &= (~i); + } + } + } else { + if(j0==0x80) return x+x; /* inf or NaN */ + else return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + return x; +} +weak_alias (__ceilf, ceilf) diff --git a/src/system/libroot/posix/glibc/arch/ppc/s_floorf.c b/src/system/libroot/posix/glibc/arch/ppc/s_floorf.c new file mode 100644 index 0000000000..e8822b0884 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/ppc/s_floorf.c @@ -0,0 +1,71 @@ +/* s_floorf.c -- float version of s_floor.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_floorf.c,v 1.4 1995/05/10 20:47:22 jtc Exp $"; +#endif + +/* + * floorf(x) + * Return x rounded toward -inf to integral value + * Method: + * Bit twiddling. + * Exception: + * Inexact flag raised if x not equal to floorf(x). + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float huge = 1.0e30; +#else +static float huge = 1.0e30; +#endif + +#ifdef __STDC__ + float __floorf(float x) +#else + float __floorf(x) + float x; +#endif +{ + int32_t i0,j0; + u_int32_t i; + GET_FLOAT_WORD(i0,x); + j0 = ((i0>>23)&0xff)-0x7f; + if(j0<23) { + if(j0<0) { /* raise inexact if x != 0 */ + if(huge+x>(float)0.0) {/* return 0*sign(x) if |x|<1 */ + if(i0>=0) {i0=0;} + else if((i0&0x7fffffff)!=0) + { i0=0xbf800000;} + } + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) return x; /* x is integral */ + if(huge+x>(float)0.0) { /* raise inexact flag */ + if(i0<0) i0 += (0x00800000)>>j0; + i0 &= (~i); + } + } + } else { + if(j0==0x80) return x+x; /* inf or NaN */ + else return x; /* x is integral */ + } + SET_FLOAT_WORD(x,i0); + return x; +} +weak_alias (__floorf, floorf) diff --git a/src/system/libroot/posix/glibc/arch/s_fpclassify.c b/src/system/libroot/posix/glibc/arch/s_fpclassify.c new file mode 100644 index 0000000000..8368ba4d23 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_fpclassify.c @@ -0,0 +1,43 @@ +/* Return classification value corresponding to argument. + Copyright (C) 1997 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + + +int +__fpclassify (double x) +{ + u_int32_t hx, lx; + int retval = FP_NORMAL; + + EXTRACT_WORDS (hx, lx, x); + lx |= hx & 0xfffff; + hx &= 0x7ff00000; + if ((hx | lx) == 0) + retval = FP_ZERO; + else if (hx == 0) + retval = FP_SUBNORMAL; + else if (hx == 0x7ff00000) + retval = lx != 0 ? FP_NAN : FP_INFINITE; + + return retval; +} diff --git a/src/system/libroot/posix/glibc/arch/s_fpclassifyf.c b/src/system/libroot/posix/glibc/arch/s_fpclassifyf.c new file mode 100644 index 0000000000..709bc2b01f --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_fpclassifyf.c @@ -0,0 +1,43 @@ +/* Return classification value corresponding to argument. + Copyright (C) 1997, 2000, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + + +int +__fpclassifyf (float x) +{ + u_int32_t wx; + int retval = FP_NORMAL; + + GET_FLOAT_WORD (wx, x); + wx &= 0x7fffffff; + if (wx == 0) + retval = FP_ZERO; + else if (wx < 0x800000) + retval = FP_SUBNORMAL; + else if (wx >= 0x7f800000) + retval = wx > 0x7f800000 ? FP_NAN : FP_INFINITE; + + return retval; +} +libm_hidden_def (__fpclassifyf) diff --git a/src/system/libroot/posix/glibc/arch/s_fpclassifyl.c b/src/system/libroot/posix/glibc/arch/s_fpclassifyl.c new file mode 100644 index 0000000000..c66a2cb02b --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_fpclassifyl.c @@ -0,0 +1,45 @@ +/* Return classification value corresponding to argument. + Copyright (C) 1997, 1999, 2002 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997 and + Jakub Jelinek , 1999. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + +#include "math_private.h" + + +int +__fpclassifyl (long double x) +{ + u_int64_t hx, lx; + int retval = FP_NORMAL; + + GET_LDOUBLE_WORDS64 (hx, lx, x); + lx |= (hx & 0x0000ffffffffffffLL); + hx &= 0x7fff000000000000LL; + if ((hx | lx) == 0) + retval = FP_ZERO; + else if (hx == 0) + retval = FP_SUBNORMAL; + else if (hx == 0x7fff000000000000LL) + retval = lx != 0 ? FP_NAN : FP_INFINITE; + + return retval; +} +libm_hidden_def (__fpclassifyl) diff --git a/src/system/libroot/posix/glibc/arch/s_modf.c b/src/system/libroot/posix/glibc/arch/s_modf.c new file mode 100644 index 0000000000..7851f675a4 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_modf.c @@ -0,0 +1,85 @@ +/* @(#)s_modf.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_modf.c,v 1.8 1995/05/10 20:47:55 jtc Exp $"; +#endif + +/* + * modf(double x, double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const double one = 1.0; +#else +static double one = 1.0; +#endif + +#ifdef __STDC__ + double __modf(double x, double *iptr) +#else + double __modf(x, iptr) + double x,*iptr; +#endif +{ + int32_t i0,i1,j0; + u_int32_t i; + EXTRACT_WORDS(i0,i1,x); + j0 = ((i0>>20)&0x7ff)-0x3ff; /* exponent of x */ + if(j0<20) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + INSERT_WORDS(*iptr,i0&0x80000000,0); /* *iptr = +-0 */ + return x; + } else { + i = (0x000fffff)>>j0; + if(((i0&i)|i1)==0) { /* x is integral */ + *iptr = x; + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0&(~i),0); + return x - *iptr; + } + } + } else if (j0>51) { /* no fraction part */ + *iptr = x*one; + /* We must handle NaNs separately. */ + if (j0 == 0x400 && ((i0 & 0xfffff) | i1)) + return x*one; + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ + return x; + } else { /* fraction part in low x */ + i = ((u_int32_t)(0xffffffff))>>(j0-20); + if((i1&i)==0) { /* x is integral */ + *iptr = x; + INSERT_WORDS(x,i0&0x80000000,0); /* return +-0 */ + return x; + } else { + INSERT_WORDS(*iptr,i0,i1&(~i)); + return x - *iptr; + } + } +} +weak_alias (__modf, modf) +#ifdef NO_LONG_DOUBLE +strong_alias (__modf, __modfl) +weak_alias (__modf, modfl) +#endif diff --git a/src/system/libroot/posix/glibc/arch/s_modff.c b/src/system/libroot/posix/glibc/arch/s_modff.c new file mode 100644 index 0000000000..e6c22b2add --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_modff.c @@ -0,0 +1,66 @@ +/* s_modff.c -- float version of s_modf.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: s_modff.c,v 1.4 1995/05/10 20:47:56 jtc Exp $"; +#endif + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const float one = 1.0; +#else +static float one = 1.0; +#endif + +#ifdef __STDC__ + float __modff(float x, float *iptr) +#else + float __modff(x, iptr) + float x,*iptr; +#endif +{ + int32_t i0,j0; + u_int32_t i; + GET_FLOAT_WORD(i0,x); + j0 = ((i0>>23)&0xff)-0x7f; /* exponent of x */ + if(j0<23) { /* integer part in x */ + if(j0<0) { /* |x|<1 */ + SET_FLOAT_WORD(*iptr,i0&0x80000000); /* *iptr = +-0 */ + return x; + } else { + i = (0x007fffff)>>j0; + if((i0&i)==0) { /* x is integral */ + u_int32_t ix; + *iptr = x; + GET_FLOAT_WORD(ix,x); + SET_FLOAT_WORD(x,ix&0x80000000); /* return +-0 */ + return x; + } else { + SET_FLOAT_WORD(*iptr,i0&(~i)); + return x - *iptr; + } + } + } else { /* no fraction part */ + *iptr = x*one; + /* We must handle NaNs separately. */ + if (j0 == 0x80 && (i0 & 0x7fffff)) + return x*one; + SET_FLOAT_WORD(x,i0&0x80000000); /* return +-0 */ + return x; + } +} +weak_alias (__modff, modff) diff --git a/src/system/libroot/posix/glibc/arch/s_modfl.c b/src/system/libroot/posix/glibc/arch/s_modfl.c new file mode 100644 index 0000000000..63d66e7114 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/s_modfl.c @@ -0,0 +1,88 @@ +/* s_modfl.c -- long double version of s_modf.c. + * Conversion to IEEE quad long double by Jakub Jelinek, jj@ultra.linux.cz. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * modfl(long double x, long double *iptr) + * return fraction part of x, and return x's integral part in *iptr. + * Method: + * Bit twiddling. + * + * Exception: + * No exception. + */ + +#include "math.h" +#include "math_private.h" + +#ifdef __STDC__ +static const long double one = 1.0; +#else +static long double one = 1.0; +#endif + +#ifdef __STDC__ + long double __modfl(long double x, long double *iptr) +#else + long double __modfl(x, iptr) + long double x,*iptr; +#endif +{ + int64_t i0,i1,j0; + u_int64_t i; + GET_LDOUBLE_WORDS64(i0,i1,x); + j0 = ((i0>>48)&0x7fff)-0x3fff; /* exponent of x */ + if(j0<48) { /* integer part in high x */ + if(j0<0) { /* |x|<1 */ + /* *iptr = +-0 */ + SET_LDOUBLE_WORDS64(*iptr,i0&0x8000000000000000ULL,0); + return x; + } else { + i = (0x0000ffffffffffffLL)>>j0; + if(((i0&i)|i1)==0) { /* x is integral */ + *iptr = x; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { + SET_LDOUBLE_WORDS64(*iptr,i0&(~i),0); + return x - *iptr; + } + } + } else if (j0>111) { /* no fraction part */ + *iptr = x*one; + /* We must handle NaNs separately. */ + if (j0 == 0x4000 && ((i0 & 0x0000ffffffffffffLL) | i1)) + return x*one; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { /* fraction part in low x */ + i = -1ULL>>(j0-48); + if((i1&i)==0) { /* x is integral */ + *iptr = x; + /* return +-0 */ + SET_LDOUBLE_WORDS64(x,i0&0x8000000000000000ULL,0); + return x; + } else { + SET_LDOUBLE_WORDS64(*iptr,i0,i1&(~i)); + return x - *iptr; + } + } +} +weak_alias (__modfl, modfl) diff --git a/src/system/libroot/posix/glibc/arch/w_atan2.c b/src/system/libroot/posix/glibc/arch/w_atan2.c new file mode 100644 index 0000000000..801baa2347 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_atan2.c @@ -0,0 +1,47 @@ +/* @(#)w_atan2.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: w_atan2.c,v 1.6 1995/05/10 20:48:39 jtc Exp $"; +#endif + +/* + * wrapper atan2(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double __atan2(double y, double x) /* wrapper atan2 */ +#else + double __atan2(y,x) /* wrapper atan2 */ + double y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2(y,x); +#else + double z; + z = __ieee754_atan2(y,x); + if(_LIB_VERSION != _SVID_||__isnan(x)||__isnan(y)) return z; + if(x==0.0&&y==0.0) + return __kernel_standard(y,x,3); /* atan2(+-0,+-0) */ + return z; +#endif +} +weak_alias (__atan2, atan2) +#ifdef NO_LONG_DOUBLE +strong_alias (__atan2, __atan2l) +weak_alias (__atan2, atan2l) +#endif diff --git a/src/system/libroot/posix/glibc/arch/w_atan2f.c b/src/system/libroot/posix/glibc/arch/w_atan2f.c new file mode 100644 index 0000000000..09caa06f00 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_atan2f.c @@ -0,0 +1,46 @@ +/* w_atan2f.c -- float version of w_atan2.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: w_atan2f.c,v 1.3 1995/05/10 20:48:42 jtc Exp $"; +#endif + +/* + * wrapper atan2f(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float __atan2f(float y, float x) /* wrapper atan2f */ +#else + float __atan2f(y,x) /* wrapper atan2 */ + float y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2f(y,x); +#else + float z; + z = __ieee754_atan2f(y,x); + if(_LIB_VERSION != _SVID_||__isnanf(x)||__isnanf(y)) return z; + if(x==0.0&&y==0.0) + return __kernel_standard(y,x,103); /* atan2(+-0,+-0) */ + return z; +#endif +} +weak_alias (__atan2f, atan2f) diff --git a/src/system/libroot/posix/glibc/arch/w_atan2l.c b/src/system/libroot/posix/glibc/arch/w_atan2l.c new file mode 100644 index 0000000000..2897c8c5f9 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_atan2l.c @@ -0,0 +1,47 @@ +/* w_atan2l.c -- long double version of w_atan2.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper atan2l(y,x) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __atan2l(long double y, long double x) /* wrapper atan2l */ +#else + long double __atan2l(y,x) /* wrapper atan2l */ + long double y,x; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_atan2l(y,x); +#else + long double z; + z = __ieee754_atan2l(y,x); + if(_LIB_VERSION != _SVID_||__isnanl(x)||__isnanl(y)) return z; + if(x==0.0&&y==0.0) + return __kernel_standard(y,x,203); /* atan2(+-0,+-0) */ + return z; +#endif +} +weak_alias (__atan2l, atan2l) diff --git a/src/system/libroot/posix/glibc/arch/w_fmod.c b/src/system/libroot/posix/glibc/arch/w_fmod.c new file mode 100644 index 0000000000..0ceeb98c55 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_fmod.c @@ -0,0 +1,48 @@ +/* @(#)w_fmod.c 5.1 93/09/24 */ +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: w_fmod.c,v 1.6 1995/05/10 20:48:55 jtc Exp $"; +#endif + +/* + * wrapper fmod(x,y) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + double __fmod(double x, double y) /* wrapper fmod */ +#else + double __fmod(x,y) /* wrapper fmod */ + double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_fmod(x,y); +#else + double z; + z = __ieee754_fmod(x,y); + if(_LIB_VERSION == _IEEE_ ||__isnan(y)||__isnan(x)) return z; + if(y==0.0) { + return __kernel_standard(x,y,27); /* fmod(x,0) */ + } else + return z; +#endif +} +weak_alias (__fmod, fmod) +#ifdef NO_LONG_DOUBLE +strong_alias (__fmod, __fmodl) +weak_alias (__fmod, fmodl) +#endif diff --git a/src/system/libroot/posix/glibc/arch/w_fmodf.c b/src/system/libroot/posix/glibc/arch/w_fmodf.c new file mode 100644 index 0000000000..9afe5ddfdd --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_fmodf.c @@ -0,0 +1,48 @@ +/* w_fmodf.c -- float version of w_fmod.c. + * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: w_fmodf.c,v 1.3 1995/05/10 20:48:57 jtc Exp $"; +#endif + +/* + * wrapper fmodf(x,y) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + float __fmodf(float x, float y) /* wrapper fmodf */ +#else + float __fmodf(x,y) /* wrapper fmodf */ + float x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_fmodf(x,y); +#else + float z; + z = __ieee754_fmodf(x,y); + if(_LIB_VERSION == _IEEE_ ||__isnanf(y)||__isnanf(x)) return z; + if(y==(float)0.0) { + /* fmodf(x,0) */ + return (float)__kernel_standard((double)x,(double)y,127); + } else + return z; +#endif +} +weak_alias (__fmodf, fmodf) diff --git a/src/system/libroot/posix/glibc/arch/w_fmodl.c b/src/system/libroot/posix/glibc/arch/w_fmodl.c new file mode 100644 index 0000000000..71ed4a94a4 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/w_fmodl.c @@ -0,0 +1,48 @@ +/* w_fmodl.c -- long double version of w_fmod.c. + * Conversion to long double by Ulrich Drepper, + * Cygnus Support, drepper@cygnus.com. + */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +#if defined(LIBM_SCCS) && !defined(lint) +static char rcsid[] = "$NetBSD: $"; +#endif + +/* + * wrapper fmodl(x,y) + */ + +#include "math.h" +#include "math_private.h" + + +#ifdef __STDC__ + long double __fmodl(long double x, long double y)/* wrapper fmodl */ +#else + long double __fmodl(x,y) /* wrapper fmodl */ + long double x,y; +#endif +{ +#ifdef _IEEE_LIBM + return __ieee754_fmodl(x,y); +#else + long double z; + z = __ieee754_fmodl(x,y); + if(_LIB_VERSION == _IEEE_ ||__isnanl(y)||__isnanl(x)) return z; + if(y==0.0) { + return __kernel_standard(x,y,227); /* fmod(x,0) */ + } else + return z; +#endif +} +weak_alias (__fmodl, fmodl) diff --git a/src/system/libroot/posix/glibc/arch/x86/Jamfile b/src/system/libroot/posix/glibc/arch/x86/Jamfile index f3a4cf4c74..5d7c29f23e 100644 --- a/src/system/libroot/posix/glibc/arch/x86/Jamfile +++ b/src/system/libroot/posix/glibc/arch/x86/Jamfile @@ -1,9 +1,9 @@ SubDir HAIKU_TOP src system libroot posix glibc arch x86 ; -SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch - $(TARGET_ARCH) ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include arch $(TARGET_ARCH) ; SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc include ; SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc stdlib ; +SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc math ; SubDirSysHdrs $(HAIKU_TOP) src system libroot posix glibc ; if $(OPTIM) = -O0 { @@ -13,23 +13,72 @@ if $(OPTIM) = -O0 { # don't compile with debugging DEBUG = 0 ; +SubDirCcFlags -D_GNU_SOURCE -D_IEEE_LIBM ; + KernelMergeObject posix_gnu_arch_$(TARGET_ARCH).o : add_n.S addmul_1.S cmp.c dbl2mpn.c divrem.c + e_acos.S + e_atan2.S + e_atan2f.S + e_atan2l.c + e_fmod.S + e_fmodf.S + e_fmodl.c ldbl2mpn.c mul.c mul_1.S mul_n.c lshift.S rshift.S + s_ceil.S + s_ceilf.S + s_ceill.S + s_copysign.S + s_copysignf.S + s_copysignl.S + s_fdim.S + s_fdimf.S + s_fdiml.S + s_fabs.S + s_fabsf.S + s_fabsl.S + s_finite.S + s_finitef.S + s_finitel.S + s_floor.S + s_floorf.S + s_floorl.S + s_fpclassify.c + s_fpclassifyf.c + s_fpclassifyl.c + s_logb.S + s_logbf.S + s_logbl.c + s_modf.c + s_modff.c + s_modfl.c + s_rint.S + s_rintf.S + s_rintl.c + s_scalbn.S + s_scalbnf.S + s_scalbnl.S sub_n.S submul_1.S + w_atan2.c + w_atan2f.c + w_atan2l.c + w_fmod.c + w_fmodf.c + w_fmodl.c : -fPIC -DPIC ; SEARCH on [ FGristFiles - cmp.c divrem.c mul.c mul_n.c dbl2mpn.c + cmp.c divrem.c mul.c mul_n.c dbl2mpn.c s_fpclassify.c s_fpclassifyf.c s_fpclassifyl.c s_modf.c s_modff.c s_modfl.c + w_atan2.c w_atan2f.c w_atan2l.c w_fmod.c w_fmodl.c w_fmodf.c ] = [ FDirName $(HAIKU_TOP) src system libroot posix glibc arch ] ; diff --git a/src/system/libroot/posix/glibc/arch/x86/e_acos.S b/src/system/libroot/posix/glibc/arch/x86/e_acos.S new file mode 100644 index 0000000000..b9d07b1091 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_acos.S @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: e_acos.S,v 1.4 1995/05/08 23:44:37 jtc Exp $") + +/* acos = atan (sqrt(1 - x^2) / x) */ +ENTRY(__ieee754_acos) + fldl 4(%esp) /* x */ + fld %st /* x : x */ + fmul %st(0) /* x^2 : x */ + fld1 /* 1 : x^2 : x */ + fsubp /* 1 - x^2 : x */ + fsqrt /* sqrt (1 - x^2) : x */ + fxch %st(1) /* x : sqrt (1 - x^2) */ + fpatan /* atan (sqrt(1 - x^2) / x) */ + ret +END (__ieee754_acos) diff --git a/src/system/libroot/posix/glibc/arch/x86/e_atan2.S b/src/system/libroot/posix/glibc/arch/x86/e_atan2.S new file mode 100644 index 0000000000..f5d2468eb2 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_atan2.S @@ -0,0 +1,17 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: e_atan2.S,v 1.4 1995/05/08 23:46:28 jtc Exp $") + +ENTRY(__ieee754_atan2) + fldl 4(%esp) + fldl 12(%esp) + fpatan + ret +END (__ieee754_atan2) + +weak_alias (__ieee754_atan2, atan2) diff --git a/src/system/libroot/posix/glibc/arch/x86/e_atan2f.S b/src/system/libroot/posix/glibc/arch/x86/e_atan2f.S new file mode 100644 index 0000000000..fc6621f183 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_atan2f.S @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: e_atan2f.S,v 1.1 1995/05/08 23:35:10 jtc Exp $") + +ENTRY(__ieee754_atan2f) + flds 4(%esp) + flds 8(%esp) + fpatan + ret +END (__ieee754_atan2f) diff --git a/src/system/libroot/posix/glibc/arch/x86/e_atan2l.c b/src/system/libroot/posix/glibc/arch/x86/e_atan2l.c new file mode 100644 index 0000000000..19a2a60621 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_atan2l.c @@ -0,0 +1,18 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper . + */ + +#include + +long double +__ieee754_atan2l (long double y, long double x) +{ + long double res; + + asm ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)"); + + return res; +} diff --git a/src/system/libroot/posix/glibc/arch/x86/e_fmod.S b/src/system/libroot/posix/glibc/arch/x86/e_fmod.S new file mode 100644 index 0000000000..4cf6e92054 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_fmod.S @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: e_fmod.S,v 1.4 1995/05/08 23:47:56 jtc Exp $") + +ENTRY(__ieee754_fmod) + fldl 12(%esp) + fldl 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret +END (__ieee754_fmod) diff --git a/src/system/libroot/posix/glibc/arch/x86/e_fmodf.S b/src/system/libroot/posix/glibc/arch/x86/e_fmodf.S new file mode 100644 index 0000000000..bbce40976d --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_fmodf.S @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * Adapted for float type by Ulrich Drepper . + */ + +#include + +RCSID("$NetBSD: $") + +ENTRY(__ieee754_fmodf) + flds 8(%esp) + flds 4(%esp) +1: fprem + fstsw %ax + sahf + jp 1b + fstp %st(1) + ret +END(__ieee754_fmodf) diff --git a/src/system/libroot/posix/glibc/arch/x86/e_fmodl.c b/src/system/libroot/posix/glibc/arch/x86/e_fmodl.c new file mode 100644 index 0000000000..c7c9a60456 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/e_fmodl.c @@ -0,0 +1,22 @@ +/* + * Written by J.T. Conklin . + * Public domain. + * + * Adapted for `long double' by Ulrich Drepper . + */ + +#include + +long double +__ieee754_fmodl (long double x, long double y) +{ + long double res; + + asm ("1:\tfprem\n" + "fstsw %%ax\n" + "sahf\n" + "jp 1b\n" + "fstp %%st(1)" + : "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)"); + return res; +} diff --git a/src/system/libroot/posix/glibc/arch/x86/s_ceil.S b/src/system/libroot/posix/glibc/arch/x86/s_ceil.S new file mode 100644 index 0000000000..b0159128aa --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_ceil.S @@ -0,0 +1,32 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_ceil.S,v 1.4 1995/05/08 23:52:13 jtc Exp $") + +ENTRY(__ceil) + fldl 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x0800,%edx /* round towards +oo */ + orl 4(%esp),%edx + andl $0xfbff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__ceil) +weak_alias (__ceil, ceil) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_ceilf.S b/src/system/libroot/posix/glibc/arch/x86/s_ceilf.S new file mode 100644 index 0000000000..352d40d7ce --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_ceilf.S @@ -0,0 +1,32 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_ceilf.S,v 1.3 1995/05/08 23:52:44 jtc Exp $") + +ENTRY(__ceilf) + flds 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x0800,%edx /* round towards +oo */ + orl 4(%esp),%edx + andl $0xfbff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__ceilf) +weak_alias (__ceilf, ceilf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_ceill.S b/src/system/libroot/posix/glibc/arch/x86/s_ceill.S new file mode 100644 index 0000000000..0128966ebe --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_ceill.S @@ -0,0 +1,33 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +RCSID("$NetBSD: $") + +ENTRY(__ceill) + fldt 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x0800,%edx /* round towards +oo */ + orl 4(%esp),%edx + andl $0xfbff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__ceill) +weak_alias (__ceill, ceill) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_copysign.S b/src/system/libroot/posix/glibc/arch/x86/s_copysign.S new file mode 100644 index 0000000000..2520a94427 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_copysign.S @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_copysign.S,v 1.4 1995/05/08 23:53:02 jtc Exp $") + +ENTRY(__copysign) + movl 16(%esp),%edx + movl 8(%esp),%eax + andl $0x80000000,%edx + andl $0x7fffffff,%eax + orl %edx,%eax + movl %eax,8(%esp) + fldl 4(%esp) + ret +END (__copysign) +weak_alias (__copysign, copysign) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_copysignf.S b/src/system/libroot/posix/glibc/arch/x86/s_copysignf.S new file mode 100644 index 0000000000..57b1a6f119 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_copysignf.S @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_copysignf.S,v 1.3 1995/05/08 23:53:25 jtc Exp $") + +ENTRY(__copysignf) + movl 8(%esp),%edx + movl 4(%esp),%eax + andl $0x80000000,%edx + andl $0x7fffffff,%eax + orl %edx,%eax + movl %eax,4(%esp) + flds 4(%esp) + ret +END (__copysignf) +weak_alias (__copysignf, copysignf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_copysignl.S b/src/system/libroot/posix/glibc/arch/x86/s_copysignl.S new file mode 100644 index 0000000000..2163e7b014 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_copysignl.S @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +RCSID("$NetBSD: $") + +ENTRY(__copysignl) + movl 24(%esp),%edx + movl 12(%esp),%eax + andl $0x8000,%edx + andl $0x7fff,%eax + orl %edx,%eax + movl %eax,12(%esp) + fldt 4(%esp) + ret +END (__copysignl) +weak_alias (__copysignl, copysignl) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fabs.S b/src/system/libroot/posix/glibc/arch/x86/s_fabs.S new file mode 100644 index 0000000000..23ae9dccb9 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fabs.S @@ -0,0 +1,9 @@ +#include + + .text +ENTRY(__fabs) + fldl 4(%esp) + fabs + ret +END(__fabs) +weak_alias (__fabs, fabs) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fabsf.S b/src/system/libroot/posix/glibc/arch/x86/s_fabsf.S new file mode 100644 index 0000000000..c0407a8839 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fabsf.S @@ -0,0 +1,9 @@ +#include + + .text +ENTRY(__fabsf) + flds 4(%esp) + fabs + ret +END(__fabsf) +weak_alias (__fabsf, fabsf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fabsl.S b/src/system/libroot/posix/glibc/arch/x86/s_fabsl.S new file mode 100644 index 0000000000..a12a3e050b --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fabsl.S @@ -0,0 +1,9 @@ +#include + + .text +ENTRY(__fabsl) + fldt 4(%esp) + fabs + ret +END(__fabsl) +weak_alias (__fabsl, fabsl) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fdim.S b/src/system/libroot/posix/glibc/arch/x86/s_fdim.S new file mode 100644 index 0000000000..92deb15d85 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fdim.S @@ -0,0 +1,52 @@ +/* Compute positive difference. + Copyright (C) 1997, 1999, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .text +ENTRY(__fdim) + fldl 4(%esp) // x + fldl 12(%esp) // x : y + + fucom %st(1) + fnstsw + sahf + jp 1f + + jc 3f + + fstp %st(1) + fldz + jmp 2f + +3: fsubrp %st, %st(1) + ret + +1: fxam + fnstsw + andb $0x45, %ah + cmpb $0x01, %ah + je 2f + + fxch +2: fstp %st(1) + ret +END(__fdim) +weak_alias (__fdim, fdim) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fdimf.S b/src/system/libroot/posix/glibc/arch/x86/s_fdimf.S new file mode 100644 index 0000000000..905cec2fae --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fdimf.S @@ -0,0 +1,52 @@ +/* Compute positive difference. + Copyright (C) 1997, 1999, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .text +ENTRY(__fdimf) + flds 4(%esp) // x + flds 8(%esp) // x : y + + fucom %st(1) + fnstsw + sahf + jp 1f + + jc 3f + + fstp %st(1) + fldz + jmp 2f + +3: fsubrp %st, %st(1) + ret + +1: fxam + fnstsw + andb $0x45, %ah + cmpb $0x01, %ah + je 2f + + fxch +2: fstp %st(1) + ret +END(__fdimf) +weak_alias (__fdimf, fdimf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_fdiml.S b/src/system/libroot/posix/glibc/arch/x86/s_fdiml.S new file mode 100644 index 0000000000..754b221de2 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_fdiml.S @@ -0,0 +1,52 @@ +/* Compute positive difference. + Copyright (C) 1997, 1999, 2004 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1997. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .text +ENTRY(__fdiml) + fldt 4(%esp) // x + fldt 16(%esp) // x : y + + fucom %st(1) + fnstsw + sahf + jp 1f + + jc 3f + + fstp %st(1) + fldz + jmp 2f + +3: fsubrp %st, %st(1) + ret + +1: fxam + fnstsw + andb $0x45, %ah + cmpb $0x01, %ah + je 2f + + fxch +2: fstp %st(1) + ret +END(__fdiml) +weak_alias (__fdiml, fdiml) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_finite.S b/src/system/libroot/posix/glibc/arch/x86/s_finite.S new file mode 100644 index 0000000000..1ae4aed451 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_finite.S @@ -0,0 +1,17 @@ +/* + * Written by Joe Keane . + */ + +#include + +ENTRY(__finite) + movl 8(%esp),%eax + movl $0xFFEFFFFF,%ecx + subl %eax,%ecx + xorl %ecx,%eax + shrl $31, %eax + ret +END (__finite) +weak_alias (__finite, finite) +hidden_def (__finite) + diff --git a/src/system/libroot/posix/glibc/arch/x86/s_finitef.S b/src/system/libroot/posix/glibc/arch/x86/s_finitef.S new file mode 100644 index 0000000000..69e72facff --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_finitef.S @@ -0,0 +1,16 @@ +/* + * Written by Joe Keane . + */ + +#include + +ENTRY(__finitef) + movl 4(%esp),%eax + movl $0xFF7FFFFF,%ecx + subl %eax,%ecx + xorl %ecx,%eax + shrl $31,%eax + ret +END (__finitef) +weak_alias (__finitef, finitef) +hidden_def (__finitef) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_finitel.S b/src/system/libroot/posix/glibc/arch/x86/s_finitel.S new file mode 100644 index 0000000000..cce90e18fc --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_finitel.S @@ -0,0 +1,15 @@ +/* + * Written by Joe Keane . + */ + +#include + +ENTRY(__finitel) + movl 12(%esp),%eax + orl $0xffff8000, %eax + incl %eax + shrl $31, %eax + ret +END (__finitel) +weak_alias (__finitel, finitel) +hidden_def (__finitel) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_floor.S b/src/system/libroot/posix/glibc/arch/x86/s_floor.S new file mode 100644 index 0000000000..20a8660424 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_floor.S @@ -0,0 +1,32 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_floor.S,v 1.4 1995/05/09 00:01:59 jtc Exp $") + +ENTRY(__floor) + fldl 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x400,%edx /* round towards -oo */ + orl 4(%esp),%edx + andl $0xf7ff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__floor) +weak_alias (__floor, floor) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_floorf.S b/src/system/libroot/posix/glibc/arch/x86/s_floorf.S new file mode 100644 index 0000000000..eca93a2aa3 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_floorf.S @@ -0,0 +1,32 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_floorf.S,v 1.3 1995/05/09 00:04:32 jtc Exp $") + +ENTRY(__floorf) + flds 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x400,%edx /* round towards -oo */ + orl 4(%esp),%edx + andl $0xf7ff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__floorf) +weak_alias (__floorf, floorf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_floorl.S b/src/system/libroot/posix/glibc/arch/x86/s_floorl.S new file mode 100644 index 0000000000..c2bf091d73 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_floorl.S @@ -0,0 +1,33 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +RCSID("$NetBSD: $") + +ENTRY(__floorl) + fldt 4(%esp) + subl $8,%esp + + fstcw 4(%esp) /* store fpu control word */ + + /* We use here %edx although only the low 1 bits are defined. + But none of the operations should care and they are faster + than the 16 bit operations. */ + movl $0x400,%edx /* round towards -oo */ + orl 4(%esp),%edx + andl $0xf7ff,%edx + movl %edx,(%esp) + fldcw (%esp) /* load modified control word */ + + frndint /* round */ + + fldcw 4(%esp) /* restore original control word */ + + addl $8,%esp + ret +END (__floorl) +weak_alias (__floorl, floorl) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_logb.S b/src/system/libroot/posix/glibc/arch/x86/s_logb.S new file mode 100644 index 0000000000..f78c091c8a --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_logb.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_logb.S,v 1.4 1995/05/09 00:14:30 jtc Exp $") + +ENTRY(__logb) + fldl 4(%esp) + fxtract + fstp %st + ret +END (__logb) +weak_alias (__logb, logb) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_logbf.S b/src/system/libroot/posix/glibc/arch/x86/s_logbf.S new file mode 100644 index 0000000000..91eb3d2925 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_logbf.S @@ -0,0 +1,16 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_logbf.S,v 1.3 1995/05/09 00:15:12 jtc Exp $") + +ENTRY(__logbf) + flds 4(%esp) + fxtract + fstp %st + ret +END (__logbf) +weak_alias (__logbf, logbf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_logbl.c b/src/system/libroot/posix/glibc/arch/x86/s_logbl.c new file mode 100644 index 0000000000..391e2db489 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_logbl.c @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +long double +__logbl (long double x) +{ + long double res; + + asm ("fxtract\n" + "fstp %%st" : "=t" (res) : "0" (x)); + return res; +} + +weak_alias (__logbl, logbl) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_rint.S b/src/system/libroot/posix/glibc/arch/x86/s_rint.S new file mode 100644 index 0000000000..be36c5f0ca --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_rint.S @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_rint.S,v 1.4 1995/05/09 00:16:08 jtc Exp $") + +ENTRY(__rint) + fldl 4(%esp) + frndint + ret +END (__rint) +weak_alias (__rint, rint) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_rintf.S b/src/system/libroot/posix/glibc/arch/x86/s_rintf.S new file mode 100644 index 0000000000..2b358c1cf1 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_rintf.S @@ -0,0 +1,15 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_rintf.S,v 1.3 1995/05/09 00:17:22 jtc Exp $") + +ENTRY(__rintf) + flds 4(%esp) + frndint + ret +END (__rintf) +weak_alias (__rintf, rintf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_rintl.c b/src/system/libroot/posix/glibc/arch/x86/s_rintl.c new file mode 100644 index 0000000000..66af9cb675 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_rintl.c @@ -0,0 +1,18 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +long double +__rintl (long double x) +{ + long double res; + + asm ("frndint" : "=t" (res) : "0" (x)); + return res; +} + +weak_alias (__rintl, rintl) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_scalbn.S b/src/system/libroot/posix/glibc/arch/x86/s_scalbn.S new file mode 100644 index 0000000000..ea9e25f094 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_scalbn.S @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_scalbn.S,v 1.4 1995/05/09 00:19:06 jtc Exp $") + +ENTRY(__scalbn) + fildl 12(%esp) + fldl 4(%esp) + fscale + fstp %st(1) + ret +END (__scalbn) +weak_alias (__scalbn, scalbn) +strong_alias (__scalbn, __scalbln) +weak_alias (__scalbn, scalbln) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_scalbnf.S b/src/system/libroot/posix/glibc/arch/x86/s_scalbnf.S new file mode 100644 index 0000000000..dc8cfb4296 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_scalbnf.S @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin . + * Public domain. + */ + +#include + +RCSID("$NetBSD: s_scalbnf.S,v 1.3 1995/05/09 00:19:59 jtc Exp $") + +ENTRY(__scalbnf) + fildl 8(%esp) + flds 4(%esp) + fscale + fstp %st(1) + ret +END (__scalbnf) +weak_alias (__scalbnf, scalbnf) +strong_alias (__scalbnf, __scalblnf) +weak_alias (__scalbnf, scalblnf) diff --git a/src/system/libroot/posix/glibc/arch/x86/s_scalbnl.S b/src/system/libroot/posix/glibc/arch/x86/s_scalbnl.S new file mode 100644 index 0000000000..295494b3d2 --- /dev/null +++ b/src/system/libroot/posix/glibc/arch/x86/s_scalbnl.S @@ -0,0 +1,20 @@ +/* + * Written by J.T. Conklin . + * Changes for long double by Ulrich Drepper + * Public domain. + */ + +#include + +RCSID("$NetBSD: $") + +ENTRY(__scalbnl) + fildl 16(%esp) + fldt 4(%esp) + fscale + fstp %st(1) + ret +END (__scalbnl) +weak_alias (__scalbnl, scalbnl) +strong_alias (__scalbnl, __scalblnl) +weak_alias (__scalbnl, scalblnl) diff --git a/src/system/libroot/posix/glibc/include/math_ldbl.h b/src/system/libroot/posix/glibc/include/math_ldbl.h new file mode 100644 index 0000000000..b3faa04846 --- /dev/null +++ b/src/system/libroot/posix/glibc/include/math_ldbl.h @@ -0,0 +1,90 @@ +#ifndef _MATH_PRIVATE_H_ +#error "Never use directly; include instead." +#endif + +/* A union which permits us to convert between a long double and + four 32 bit ints or two 64 bit ints. */ + +#if __FLOAT_WORD_ORDER == BIG_ENDIAN + +typedef union +{ + long double value; + struct + { + u_int64_t msw; + u_int64_t lsw; + } parts64; + struct + { + u_int32_t w0, w1, w2, w3; + } parts32; +} ieee854_long_double_shape_type; + +#endif + +#if __FLOAT_WORD_ORDER == LITTLE_ENDIAN + +typedef union +{ + long double value; + struct + { + u_int64_t lsw; + u_int64_t msw; + } parts64; + struct + { + u_int32_t w3, w2, w1, w0; + } parts32; +} ieee854_long_double_shape_type; + +#endif + +/* Get two 64 bit ints from a long double. */ + +#define GET_LDOUBLE_WORDS64(ix0,ix1,d) \ +do { \ + ieee854_long_double_shape_type qw_u; \ + qw_u.value = (d); \ + (ix0) = qw_u.parts64.msw; \ + (ix1) = qw_u.parts64.lsw; \ +} while (0) + +/* Set a long double from two 64 bit ints. */ + +#define SET_LDOUBLE_WORDS64(d,ix0,ix1) \ +do { \ + ieee854_long_double_shape_type qw_u; \ + qw_u.parts64.msw = (ix0); \ + qw_u.parts64.lsw = (ix1); \ + (d) = qw_u.value; \ +} while (0) + +/* Get the more significant 64 bits of a long double mantissa. */ + +#define GET_LDOUBLE_MSW64(v,d) \ +do { \ + ieee854_long_double_shape_type sh_u; \ + sh_u.value = (d); \ + (v) = sh_u.parts64.msw; \ +} while (0) + +/* Set the more significant 64 bits of a long double mantissa from an int. */ + +#define SET_LDOUBLE_MSW64(d,v) \ +do { \ + ieee854_long_double_shape_type sh_u; \ + sh_u.value = (d); \ + sh_u.parts64.msw = (v); \ + (d) = sh_u.value; \ +} while (0) + +/* Get the least significant 64 bits of a long double mantissa. */ + +#define GET_LDOUBLE_LSW64(v,d) \ +do { \ + ieee854_long_double_shape_type sh_u; \ + sh_u.value = (d); \ + (v) = sh_u.parts64.lsw; \ +} while (0) diff --git a/src/system/libroot/posix/glibc/math/machine/asm.h b/src/system/libroot/posix/glibc/math/machine/asm.h new file mode 100644 index 0000000000..548e248556 --- /dev/null +++ b/src/system/libroot/posix/glibc/math/machine/asm.h @@ -0,0 +1,10 @@ +/* The libm assembly code wants to include to define the + ENTRY macro. We define assembly-related macros in sysdep.h and + asm-syntax.h. */ + +#include +#include + +/* The libm assembly code uses this macro for RCSid strings. + We don't put RCSid strings into object files. */ +#define RCSID(id) /* ignore them */ diff --git a/src/system/libroot/posix/glibc/math/math_private.h b/src/system/libroot/posix/glibc/math/math_private.h index 1cbe797aea..9508a69d0e 100644 --- a/src/system/libroot/posix/glibc/math/math_private.h +++ b/src/system/libroot/posix/glibc/math/math_private.h @@ -149,7 +149,7 @@ do { \ } while (0) /* Get long double macros from a separate header. */ -//#include +#include /* ieee style elementary functions */ extern double __ieee754_sqrt (double); diff --git a/src/system/libroot/posix/math/Jamfile b/src/system/libroot/posix/math/Jamfile index 15bd529867..cb31677aac 100644 --- a/src/system/libroot/posix/math/Jamfile +++ b/src/system/libroot/posix/math/Jamfile @@ -1,6 +1,8 @@ SubDir HAIKU_TOP src system libroot posix math ; -SubDirHdrs [ FDirName $(SUBDIR) $(DOTDOT) glibc ] ; +#SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) glibc ] ; +#SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) glibc include ] ; +#SubDirSysHdrs [ FDirName $(SUBDIR) $(DOTDOT) glibc include arch $(TARGET_ARCH) ] ; SubDirCcFlags -Dnational ; KernelMergeObject posix_math.o : @@ -8,20 +10,15 @@ KernelMergeObject posix_math.o : asincos.c asinh.c atan.c - atan2.c atanh.c cabs.c cbrt.c - ceilf.c cosh.c erf.c exp.c exp__E.c expm1.c floatmath.c - floor.c - floorf.c - fmod.c gamma.c ieee.c j0.c diff --git a/src/system/libroot/posix/math/arch/x86/Jamfile b/src/system/libroot/posix/math/arch/x86/Jamfile index 5eda534b67..b785247f38 100644 --- a/src/system/libroot/posix/math/arch/x86/Jamfile +++ b/src/system/libroot/posix/math/arch/x86/Jamfile @@ -2,7 +2,6 @@ SubDir HAIKU_TOP src system libroot posix math arch x86 ; KernelMergeObject posix_math_arch_$(TARGET_ARCH).o : cos.S - fabs.S frexp.c isinf.c ldexp.c diff --git a/src/system/libroot/posix/math/arch/x86/fabs.S b/src/system/libroot/posix/math/arch/x86/fabs.S deleted file mode 100644 index e95e3f8195..0000000000 --- a/src/system/libroot/posix/math/arch/x86/fabs.S +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/i386/gen/fabs.S,v 1.5 1999/08/27 23:59:20 peter Exp $ - */ - -#if defined(LIBC_RCS) && !defined(lint) - .text - .asciz "$FreeBSD: src/lib/libc/i386/gen/fabs.S,v 1.5 1999/08/27 23:59:20 peter Exp $" -#endif /* LIBC_RCS and not lint */ - - -.global fabs -.type fabs,@function -fabs: - fldl 4(%esp) - fabs - ret diff --git a/src/system/libroot/posix/math/ceilf.c b/src/system/libroot/posix/math/ceilf.c deleted file mode 100644 index bf1b0c9aad..0000000000 --- a/src/system/libroot/posix/math/ceilf.c +++ /dev/null @@ -1,55 +0,0 @@ -/* s_ceilf.c -- float version of s_ceil.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -#include -#include "math/math_private.h" - -static const float sHuge = 1.0e30; - -float -ceilf(float x) -{ - int32_t i0,j0; - u_int32_t i; - - GET_FLOAT_WORD(i0,x); - j0 = ((i0 >> 23) & 0xff) - 0x7f; - if (j0 < 23) { - if (j0 < 0) { /* raise inexact if x != 0 */ - if (sHuge + x > 0.0f) {/* return 0*sign(x) if |x|<1 */ - if (i0 < 0) - i0 = 0x80000000; - else if (i0 != 0) - i0 = 0x3f800000; - } - } else { - i = (0x007fffff) >> j0; - if ((i0 & i) == 0) - return x; /* x is integral */ - if (sHuge + x > 0.0f) { /* raise inexact flag */ - if (i0 > 0) - i0 += (0x00800000) >> j0; - i0 &= (~i); - } - } - } else { - if (j0 == 0x80) - return x + x; /* inf or NaN */ - else - return x; /* x is integral */ - } - SET_FLOAT_WORD(x, i0); - return x; -} diff --git a/src/system/libroot/posix/math/floatmath.c b/src/system/libroot/posix/math/floatmath.c index 29b5028c8f..3e44d12f72 100644 --- a/src/system/libroot/posix/math/floatmath.c +++ b/src/system/libroot/posix/math/floatmath.c @@ -32,38 +32,12 @@ float logbf(float x) {return (float)logb((double)x);}; float powf(float x, float y) {return (float)pow((double)x, (double)y);}; float sqrtf(float x) {return (float)sqrt((double)x);}; float hypotf(float x, float y) {return (float)hypot((double)x, (double)y);}; -float fabsf(float x) {return (float)fabs((double)x);}; -float fmodf(float x, float y) {return (float)fmod((double)x, (double)y);}; -float copysignf(float x, float y) {return (float)copysign((double)x, (double)y);}; float erff(float x) {return (float)erf((double)x);}; float erfcf(float x) {return (float)erfc((double)x);}; float gammaf(float x) {return (float)gamma((double)x);}; float lgammaf(float x) {return (float)lgamma((double)x);}; -float rintf(float x) {return (float)rint((double)x);}; float scalbf(float x, float n) {return (float)scalb((double)x, (double)n);}; -// TODO: use optimized versions of these -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; -} - -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) @@ -93,33 +67,3 @@ __signbitl(long double value) return (u.i[2] & 0x8000) != 0; } - -int -__fpclassifyf(float value) -{ - // TODO: implement me! - return FP_NORMAL; -} - - -int -__fpclassify(double value) -{ - // TODO: implement me! - return FP_NORMAL; -} - - -int -__fpclassifyl(long double value) -{ - // TODO: implement me! - return FP_NORMAL; -} - -int -finitef(float value) -{ - int clazz = __fpclassifyf(value); - return (clazz == FP_ZERO || clazz == FP_SUBNORMAL || clazz == FP_NORMAL); -} diff --git a/src/system/libroot/posix/math/floor.c b/src/system/libroot/posix/math/floor.c deleted file mode 100644 index d0c0e3b574..0000000000 --- a/src/system/libroot/posix/math/floor.c +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include - -vc(L, 4503599627370496.0E0 ,0000,5c00,0000,0000, 55, 1.0) /* 2**55 */ - -ic(L, 4503599627370496.0E0, 52, 1.0) /* 2**52 */ - -#ifdef vccast -#define L vccast(L) -#endif - -/* - * floor(x) := the largest integer no larger than x; - * ceil(x) := -floor(-x), for all real x. - * - * Note: Inexact will be signaled if x is not an integer, as is - * customary for IEEE 754. No other signal can be emitted. - */ -double -floor(x) -double x; -{ - volatile double y; - - if ( -#if !defined(vax)&&!defined(tahoe) - x != x || /* NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - x >= L) /* already an even integer */ - return x; - else if (x < (double)0) - return -ceil(-x); - else { /* now 0 <= x < L */ - y = L+x; /* destructive store must be forced */ - y -= L; /* an integer, and |x-y| < 1 */ - return x < y ? y-(double)1 : y; - } -} - -double -ceil(x) -double x; -{ - volatile double y; - - if ( -#if !defined(vax)&&!defined(tahoe) - x != x || /* NaN */ -#endif /* !defined(vax)&&!defined(tahoe) */ - x >= L) /* already an even integer */ - return x; - else if (x < (double)0) - return -floor(-x); - else { /* now 0 <= x < L */ - y = L+x; /* destructive store must be forced */ - y -= L; /* an integer, and |x-y| < 1 */ - return x > y ? y+(double)1 : y; - } -} - -#ifndef ns32000 /* rint() is in ./NATIONAL/support.s */ -/* - * algorithm for rint(x) in pseudo-pascal form ... - * - * real rint(x): real x; - * ... delivers integer nearest x in direction of prevailing rounding - * ... mode - * const L = (last consecutive integer)/2 - * = 2**55; for VAX D - * = 2**52; for IEEE 754 Double - * real s,t; - * begin - * if x != x then return x; ... NaN - * if |x| >= L then return x; ... already an integer - * s := copysign(L,x); - * t := x + s; ... = (x+s) rounded to integer - * return t - s - * end; - * - * Note: Inexact will be signaled if x is not an integer, as is - * customary for IEEE 754. No other signal can be emitted. - */ -double -rint(x) -double x; -{ - double s; - volatile double t; - const double one = 1.0; - -#if !defined(vax)&&!defined(tahoe) - if (x != x) /* NaN */ - return (x); -#endif /* !defined(vax)&&!defined(tahoe) */ - if (copysign(x,one) >= L) /* already an integer */ - return (x); - s = copysign(L,x); - t = x + s; /* x+s rounded to integer */ - return (t - s); -} -#endif /* not national */ diff --git a/src/system/libroot/posix/math/floorf.c b/src/system/libroot/posix/math/floorf.c deleted file mode 100644 index cf42b04fc9..0000000000 --- a/src/system/libroot/posix/math/floorf.c +++ /dev/null @@ -1,66 +0,0 @@ -/* s_floorf.c -- float version of s_floor.c. - * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - */ - -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * floorf(x) - * Return x rounded toward -inf to integral value - * Method: - * Bit twiddling. - * Exception: - * Inexact flag raised if x not equal to floorf(x). - */ - -#include - -#include -#include "math/math_private.h" - -static const float sHuge = 1.0e30; - -float -floorf(float x) -{ - int32 i0,j0; - uint32 i; - - GET_FLOAT_WORD(i0, x); - j0 = ((i0 >> 23) & 0xff) - 0x7f; - if (j0 < 23) { - if (j0 < 0) { /* raise inexact if x != 0 */ - if (sHuge + x > 0.0f) {/* return 0*sign(x) if |x|<1 */ - if (i0 >= 0) - i0 = 0; - else if ((i0 & 0x7fffffff) != 0) - i0 = 0xbf800000; - } - } else { - i = (0x007fffff) >> j0; - if ((i0 & i) == 0) - return x; /* x is integral */ - if (sHuge + x > 0.0f) { /* raise inexact flag */ - if (i0 < 0) - i0 += (0x00800000) >> j0; - i0 &= (~i); - } - } - } else { - if (j0 == 0x80) - return x + x; /* inf or NaN */ - else - return x; /* x is integral */ - } - SET_FLOAT_WORD(x, i0); - return x; -} diff --git a/src/system/libroot/posix/math/ieee.c b/src/system/libroot/posix/math/ieee.c index 3ff6a69df3..6dfc50a264 100644 --- a/src/system/libroot/posix/math/ieee.c +++ b/src/system/libroot/posix/math/ieee.c @@ -82,6 +82,7 @@ static const double novf=1.7E308, nunf=3.0E-308,zero=0.0; #endif /* defined(vax)||defined(tahoe) */ + double scalb(double x, double N) { @@ -128,6 +129,7 @@ scalb(double x, double N) return(x); } +#if 0 double copysign(double x, double y) @@ -190,6 +192,7 @@ finite(double x) #endif /* national */ #endif /* defined(vax)||defined(tahoe) */ } +#endif double drem(double x, double p)