From 50fa859819790a938b9bf7ba1df627d8ddc8811d Mon Sep 17 00:00:00 2001 From: Ben Gras Date: Fri, 14 Dec 2007 11:59:54 +0000 Subject: [PATCH] A rint() implementation. --- include/math.h | 1 + lib/math/Makefile.in | 1 + lib/math/math_private.h | 18 +++++++++++------- lib/math/s_rint.c | 11 +++-------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/math.h b/include/math.h index b039cec39..96d6e61c1 100755 --- a/include/math.h +++ b/include/math.h @@ -30,6 +30,7 @@ _PROTOTYPE( double log, (double _x) ); _PROTOTYPE( double log10, (double _x) ); _PROTOTYPE( double modf, (double _x, double *_iptr) ); _PROTOTYPE( double pow, (double _x, double _y) ); +_PROTOTYPE( double rint, (double _x) ); _PROTOTYPE( double sin, (double _x) ); _PROTOTYPE( double sinh, (double _x) ); _PROTOTYPE( double sqrt, (double _x) ); diff --git a/lib/math/Makefile.in b/lib/math/Makefile.in index 5c09a9d6c..61f3f999e 100644 --- a/lib/math/Makefile.in +++ b/lib/math/Makefile.in @@ -17,6 +17,7 @@ libc_FILES=" \ log.c \ log10.c \ pow.c \ + s_rint.c \ sin.c \ sinh.c \ sqrt.c \ diff --git a/lib/math/math_private.h b/lib/math/math_private.h index d865d1fb2..d367f2afd 100644 --- a/lib/math/math_private.h +++ b/lib/math/math_private.h @@ -18,7 +18,7 @@ #define _MATH_PRIVATE_H_ #include -#include +#include /* * The original fdlibm code used statements like: @@ -38,29 +38,29 @@ * ints. */ -#if BYTE_ORDER == BIG_ENDIAN +#if BIG_ENDIAN typedef union { double value; struct { - u_int32_t msw; - u_int32_t lsw; + u32_t msw; + u32_t lsw; } parts; } ieee_double_shape_type; #endif -#if BYTE_ORDER == LITTLE_ENDIAN +#if LITTLE_ENDIAN typedef union { double value; struct { - u_int32_t lsw; - u_int32_t msw; + u32_t lsw; + u32_t msw; } parts; } ieee_double_shape_type; @@ -154,6 +154,8 @@ do { \ (d) = sf_u.value; \ } while (0) +#if 0 + #ifdef _COMPLEX_H /* * Inline functions that can be used to construct complex values. @@ -269,4 +271,6 @@ float __kernel_cosdf(double); float __kernel_tandf(double,int); int __kernel_rem_pio2f(float*,float*,int,int,int,const int*); +#endif + #endif /* !_MATH_PRIVATE_H_ */ diff --git a/lib/math/s_rint.c b/lib/math/s_rint.c index 3454f5fab..fd21fd0dd 100644 --- a/lib/math/s_rint.c +++ b/lib/math/s_rint.c @@ -10,10 +10,6 @@ * ==================================================== */ -#ifndef lint -static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_rint.c,v 1.11.2.1 2007/06/14 05:16:44 bde Exp $"; -#endif - /* * rint(x) * Return x rounded to integral value according to the prevailing @@ -24,7 +20,6 @@ static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_rint.c,v 1.11.2.1 2007/06/14 * Inexact flag raised if x not equal to rint(x). */ -#include "math.h" #include "math_private.h" static const double @@ -36,8 +31,8 @@ TWO52[2]={ double rint(double x) { - int32_t i0,j0,sx; - u_int32_t i,i1; + i32_t i0,j0,sx; + u32_t i,i1; double w,t; EXTRACT_WORDS(i0,i1,x); sx = (i0>>31)&1; @@ -76,7 +71,7 @@ rint(double x) if(j0==0x400) return x+x; /* inf or NaN */ else return x; /* x is integral */ } else { - i = ((u_int32_t)(0xffffffff))>>(j0-20); + i = ((u32_t)(0xffffffff))>>(j0-20); if((i1&i)==0) return x; /* x is integral */ i>>=1; if((i1&i)!=0) i1 = (i1&(~i))|((0x40000000)>>(j0-20)); -- 2.44.0