diff options
| author | Tom Tromey | 2013-07-06 23:18:58 -0600 |
|---|---|---|
| committer | Tom Tromey | 2013-07-06 23:18:58 -0600 |
| commit | 6dacdad5fcb278e5a16b38bb81786aac9ca27be4 (patch) | |
| tree | f5f331ea361ba0f99e0f9b638d183ad492a7da31 /src/floatfns.c | |
| parent | 0a6f2ff0c8ceb29703e76cddd46ea3f176dd873a (diff) | |
| parent | 219afb88d9d484393418820d1c08dc93299110ec (diff) | |
| download | emacs-6dacdad5fcb278e5a16b38bb81786aac9ca27be4.tar.gz emacs-6dacdad5fcb278e5a16b38bb81786aac9ca27be4.zip | |
merge from trunk
this merges frmo trunk and fixes various build issues.
this needed a few ugly tweaks.
this hangs in "make check" now
Diffstat (limited to 'src/floatfns.c')
| -rw-r--r-- | src/floatfns.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/src/floatfns.c b/src/floatfns.c index 6113758f964..f3d0936f888 100644 --- a/src/floatfns.c +++ b/src/floatfns.c | |||
| @@ -25,7 +25,19 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 25 | /* C89 requires only the following math.h functions, and Emacs omits | 25 | /* C89 requires only the following math.h functions, and Emacs omits |
| 26 | the starred functions since we haven't found a use for them: | 26 | the starred functions since we haven't found a use for them: |
| 27 | acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod, | 27 | acos, asin, atan, atan2, ceil, cos, *cosh, exp, fabs, floor, fmod, |
| 28 | frexp, ldexp, log, log10, *modf, pow, sin, *sinh, sqrt, tan, *tanh. | 28 | frexp, ldexp, log, log10 [via (log X 10)], *modf, pow, sin, *sinh, |
| 29 | sqrt, tan, *tanh. | ||
| 30 | |||
| 31 | C99 and C11 require the following math.h functions in addition to | ||
| 32 | the C89 functions. Of these, Emacs currently exports only the | ||
| 33 | starred ones to Lisp, since we haven't found a use for the others: | ||
| 34 | acosh, atanh, cbrt, *copysign, erf, erfc, exp2, expm1, fdim, fma, | ||
| 35 | fmax, fmin, fpclassify, hypot, ilogb, isfinite, isgreater, | ||
| 36 | isgreaterequal, isinf, isless, islessequal, islessgreater, *isnan, | ||
| 37 | isnormal, isunordered, lgamma, log1p, *log2 [via (log X 2)], *logb | ||
| 38 | (approximately), lrint/llrint, lround/llround, nan, nearbyint, | ||
| 39 | nextafter, nexttoward, remainder, remquo, *rint, round, scalbln, | ||
| 40 | scalbn, signbit, tgamma, trunc. | ||
| 29 | */ | 41 | */ |
| 30 | 42 | ||
| 31 | #include <config.h> | 43 | #include <config.h> |
| @@ -41,6 +53,14 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 41 | # define isnan(x) ((x) != (x)) | 53 | # define isnan(x) ((x) != (x)) |
| 42 | #endif | 54 | #endif |
| 43 | 55 | ||
| 56 | /* Check that X is a floating point number. */ | ||
| 57 | |||
| 58 | static void | ||
| 59 | CHECK_FLOAT (Lisp_Object x) | ||
| 60 | { | ||
| 61 | CHECK_TYPE (FLOATP (x), Qfloatp, x); | ||
| 62 | } | ||
| 63 | |||
| 44 | /* Extract a Lisp number as a `double', or signal an error. */ | 64 | /* Extract a Lisp number as a `double', or signal an error. */ |
| 45 | 65 | ||
| 46 | double | 66 | double |
| @@ -233,21 +253,16 @@ If the optional argument BASE is given, return log ARG using that base. */) | |||
| 233 | 253 | ||
| 234 | if (b == 10.0) | 254 | if (b == 10.0) |
| 235 | d = log10 (d); | 255 | d = log10 (d); |
| 256 | #if HAVE_LOG2 | ||
| 257 | else if (b == 2.0) | ||
| 258 | d = log2 (d); | ||
| 259 | #endif | ||
| 236 | else | 260 | else |
| 237 | d = log (d) / log (b); | 261 | d = log (d) / log (b); |
| 238 | } | 262 | } |
| 239 | return make_float (d); | 263 | return make_float (d); |
| 240 | } | 264 | } |
| 241 | 265 | ||
| 242 | DEFUN ("log10", Flog10, Slog10, 1, 1, 0, | ||
| 243 | doc: /* Return the logarithm base 10 of ARG. */) | ||
| 244 | (Lisp_Object arg) | ||
| 245 | { | ||
| 246 | double d = extract_float (arg); | ||
| 247 | d = log10 (d); | ||
| 248 | return make_float (d); | ||
| 249 | } | ||
| 250 | |||
| 251 | DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, | 266 | DEFUN ("sqrt", Fsqrt, Ssqrt, 1, 1, 0, |
| 252 | doc: /* Return the square root of ARG. */) | 267 | doc: /* Return the square root of ARG. */) |
| 253 | (Lisp_Object arg) | 268 | (Lisp_Object arg) |
| @@ -545,7 +560,6 @@ syms_of_floatfns (void) | |||
| 545 | defsubr (&Sexp); | 560 | defsubr (&Sexp); |
| 546 | defsubr (&Sexpt); | 561 | defsubr (&Sexpt); |
| 547 | defsubr (&Slog); | 562 | defsubr (&Slog); |
| 548 | defsubr (&Slog10); | ||
| 549 | defsubr (&Ssqrt); | 563 | defsubr (&Ssqrt); |
| 550 | 564 | ||
| 551 | defsubr (&Sabs); | 565 | defsubr (&Sabs); |