]> Zhao Yanbai Git Server - minix.git/commitdiff
A rint() implementation.
authorBen Gras <ben@minix3.org>
Fri, 14 Dec 2007 11:59:54 +0000 (11:59 +0000)
committerBen Gras <ben@minix3.org>
Fri, 14 Dec 2007 11:59:54 +0000 (11:59 +0000)
include/math.h
lib/math/Makefile.in
lib/math/math_private.h
lib/math/s_rint.c

index b039cec3935ccf027d04472eb3aa0e7191b97394..96d6e61c123af98e0b173b80c0d1d7383122e55b 100755 (executable)
@@ -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)                                  );
index 5c09a9d6c322edc7aca1828640c6de5c742e7c21..61f3f999e9e1f1695dbac61fda3d28cdbd2494ed 100644 (file)
@@ -17,6 +17,7 @@ libc_FILES=" \
        log.c \
        log10.c \
        pow.c \
+       s_rint.c \
        sin.c \
        sinh.c \
        sqrt.c \
index d865d1fb2d888903d627c507d31df29bb881c305..d367f2afdcccb49a58c363e7fa77839c72e81ea9 100644 (file)
@@ -18,7 +18,7 @@
 #define        _MATH_PRIVATE_H_
 
 #include <sys/types.h>
-#include <machine/endian.h>
+#include <net/hton.h>
 
 /*
  * The original fdlibm code used statements like:
  * 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_ */
index 3454f5fab4c8441850fd43a281ef5ad85db2d7ac..fd21fd0dda8790e306ca3bb2e32a0b73a744ba45 100644 (file)
  * ====================================================
  */
 
-#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));