aboutsummaryrefslogtreecommitdiffstats
path: root/src/floatfns.c
diff options
context:
space:
mode:
authorJim Blandy1992-01-13 21:48:08 +0000
committerJim Blandy1992-01-13 21:48:08 +0000
commit265a9e559da4ac72d154ecd638c51801b3e97847 (patch)
tree633e4dc50761c2cd5201a7874e23eee9e51aecea /src/floatfns.c
parentd427b66a664c0e1ffc818dfa5b87b45b4857d2ae (diff)
downloademacs-265a9e559da4ac72d154ecd638c51801b3e97847.tar.gz
emacs-265a9e559da4ac72d154ecd638c51801b3e97847.zip
*** empty log message ***
Diffstat (limited to 'src/floatfns.c')
-rw-r--r--src/floatfns.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/floatfns.c b/src/floatfns.c
index 1cf132d5f5c..12f14ffef72 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -26,7 +26,23 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26Lisp_Object Qarith_error; 26Lisp_Object Qarith_error;
27 27
28#ifdef LISP_FLOAT_TYPE 28#ifdef LISP_FLOAT_TYPE
29
29#include <math.h> 30#include <math.h>
31#include <errno.h>
32
33extern int errno;
34
35/* Avoid traps on VMS from sinh and cosh.
36 All the other functions set errno instead. */
37
38#ifdef VMS
39#undef cosh
40#undef sinh
41#define cosh(x) ((exp(x)+exp(-x))*0.5)
42#define sinh(x) ((exp(x)-exp(-x))*0.5)
43#endif /* VMS */
44
45static float_error ();
30 46
31/* Nonzero while executing in floating point. 47/* Nonzero while executing in floating point.
32 This tells float_error what to do. */ 48 This tells float_error what to do. */
@@ -34,13 +50,19 @@ Lisp_Object Qarith_error;
34static int in_float; 50static int in_float;
35 51
36/* If an argument is out of range for a mathematical function, 52/* If an argument is out of range for a mathematical function,
37 that is detected with a signal. Here is the actual argument 53 here is the actual argument value to use in the error message. */
38 value to use in the error message. */
39 54
40static Lisp_Object float_error_arg; 55static Lisp_Object float_error_arg;
41 56
42#define IN_FLOAT(d, num) \ 57/* Evaluate the floating point expression D, recording NUM
43(in_float = 1, float_error_arg = num, (d), in_float = 0) 58 as the original argument for error messages.
59 D is normally an assignment expression.
60 Handle errors which may result in signals or may set errno. */
61
62#define IN_FLOAT(D, NUM) \
63(in_float = 1, errno = 0, float_error_arg = NUM, (D), \
64 (errno == ERANGE || errno == EDOM ? float_error () : 0), \
65 in_float = 0)
44 66
45/* Extract a Lisp number as a `double', or signal an error. */ 67/* Extract a Lisp number as a `double', or signal an error. */
46 68
@@ -476,7 +498,6 @@ Rounds the value toward zero.")
476 return num; 498 return num;
477} 499}
478 500
479#ifdef BSD
480static 501static
481float_error (signo) 502float_error (signo)
482 int signo; 503 int signo;
@@ -484,22 +505,22 @@ float_error (signo)
484 if (! in_float) 505 if (! in_float)
485 fatal_error_signal (signo); 506 fatal_error_signal (signo);
486 507
508#ifdef BSD
487#ifdef BSD4_1 509#ifdef BSD4_1
488 sigrelse (SIGILL); 510 sigrelse (SIGILL);
489#else /* not BSD4_1 */ 511#else /* not BSD4_1 */
490 sigsetmask (0); 512 sigsetmask (0);
491#endif /* not BSD4_1 */ 513#endif /* not BSD4_1 */
514#else
515 /* Must reestablish handler each time it is called. */
516 signal (SIGILL, float_error);
517#endif /* BSD */
492 518
493 in_float = 0; 519 in_float = 0;
494 520
495 Fsignal (Qarith_error, Fcons (float_error_arg, Qnil)); 521 Fsignal (Qarith_error, Fcons (float_error_arg, Qnil));
496} 522}
497 523
498/* Another idea was to replace the library function `infnan'
499 where SIGILL is signaled. */
500
501#endif /* BSD */
502
503init_floatfns () 524init_floatfns ()
504{ 525{
505 signal (SIGILL, float_error); 526 signal (SIGILL, float_error);