]> code.delx.au - gnu-emacs/blobdiff - src/floatfns.c
'temacs -nw' should not call missing functions
[gnu-emacs] / src / floatfns.c
index dd6d3dfe582a6352c6ed2985d577eb9828c8f4b4..c68b9bd3a65658cf939024daea6de7ee3f75ce7c 100644 (file)
@@ -1,6 +1,6 @@
 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
 
 /* Primitive operations on floating point for GNU Emacs Lisp interpreter.
 
-Copyright (C) 1988, 1993-1994, 1999, 2001-2013 Free Software Foundation,
+Copyright (C) 1988, 1993-1994, 1999, 2001-2015 Free Software Foundation,
 Inc.
 
 Author: Wolfgang Rupprecht
 Inc.
 
 Author: Wolfgang Rupprecht
@@ -25,7 +25,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* C89 requires only the following math.h functions, and Emacs omits
    the starred functions since we haven't found a use for them:
    acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod,
 /* C89 requires only the following math.h functions, and Emacs omits
    the starred functions since we haven't found a use for them:
    acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod,
-   frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh.
+   frexp, ldexp, log, log10 [via (log X 10)], *modf, pow, sin, *sinh,
+   sqrt, tan, *tanh.
 
    C99 and C11 require the following math.h functions in addition to
    the C89 functions.  Of these, Emacs currently exports only the
 
    C99 and C11 require the following math.h functions in addition to
    the C89 functions.  Of these, Emacs currently exports only the
@@ -33,10 +34,10 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
    acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma,
    fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater,
    isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan,
    acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma,
    fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater,
    isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan,
-   isnormal, isunordered, lgamma, log1p, log2, *logb (approximately),
-   lrint/llrint, lround/llround, nan, nearbyint, nextafter,
-   nexttoward, remainder, remquo, *rint, round, scalbln, scalbn,
-   signbit, tgamma, trunc.
+   isnormal, isunordered, lgamma, log1p, *log2 [via (log X 2)], *logb
+   (approximately), lrint/llrint, lround/llround, nan, nearbyint,
+   nextafter, nexttoward, remainder, remquo, *rint, round, scalbln,
+   scalbn, signbit, tgamma, trunc.
  */
 
 #include <config.h>
  */
 
 #include <config.h>
@@ -45,12 +46,13 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <math.h>
 
 
 #include <math.h>
 
-#ifndef isfinite
-# define isfinite(x) ((x) - (x) == 0)
-#endif
-#ifndef isnan
-# define isnan(x) ((x) != (x))
-#endif
+/* 'isfinite' and 'isnan' cause build failures on Solaris 10 with the
+   bundled GCC in c99 mode.  Work around the bugs with simple
+   implementations that are good enough.  */
+#undef isfinite
+#define isfinite(x) ((x) - (x) == 0)
+#undef isnan
+#define isnan(x) ((x) != (x))
 
 /* Check that X is a floating point number.  */
 
 
 /* Check that X is a floating point number.  */
 
@@ -140,7 +142,7 @@ DEFUN ("tan", Ftan, Stan, 1, 1, 0,
 }
 
 DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
 }
 
 DEFUN ("isnan", Fisnan, Sisnan, 1, 1, 0,
-       doc: /* Return non nil iff argument X is a NaN.  */)
+       doc: /* Return non nil if argument X is a NaN.  */)
   (Lisp_Object x)
 {
   CHECK_FLOAT (x);
   (Lisp_Object x)
 {
   CHECK_FLOAT (x);
@@ -252,21 +254,16 @@ If the optional argument BASE is given, return log ARG using that base.  */)
 
       if (b == 10.0)
        d = log10 (d);
 
       if (b == 10.0)
        d = log10 (d);
+#if HAVE_LOG2
+      else if (b == 2.0)
+       d = log2 (d);
+#endif
       else
        d = log (d) / log (b);
     }
   return make_float (d);
 }
 
       else
        d = log (d) / log (b);
     }
   return make_float (d);
 }
 
-DEFUN ("log10", Flog10, Slog10, 1, 1, 0,
-       doc: /* Return the logarithm base 10 of ARG.  */)
-  (Lisp_Object arg)
-{
-  double d = extract_float (arg);
-  d = log10 (d);
-  return make_float (d);
-}
-
 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
        doc: /* Return the square root of ARG.  */)
   (Lisp_Object arg)
 DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0,
        doc: /* Return the square root of ARG.  */)
   (Lisp_Object arg)
@@ -431,7 +428,9 @@ round2 (EMACS_INT i1, EMACS_INT i2)
 static double
 emacs_rint (double d)
 {
 static double
 emacs_rint (double d)
 {
-  return floor (d + 0.5);
+  double d1 = d + 0.5;
+  double r = floor (d1);
+  return r - (r == d1 && fmod (r, 2) != 0);
 }
 #endif
 
 }
 #endif
 
@@ -564,7 +563,6 @@ syms_of_floatfns (void)
   defsubr (&Sexp);
   defsubr (&Sexpt);
   defsubr (&Slog);
   defsubr (&Sexp);
   defsubr (&Sexpt);
   defsubr (&Slog);
-  defsubr (&Slog10);
   defsubr (&Ssqrt);
 
   defsubr (&Sabs);
   defsubr (&Ssqrt);
 
   defsubr (&Sabs);