+ Handle errors which may result in signals or may set errno.
+
+ Note that float_error may be declared to return void, so you can't
+ just cast the zero after the colon to (SIGTYPE) to make the types
+ check properly. */
+
+#ifdef FLOAT_CHECK_ERRNO
+#define IN_FLOAT(d, name, num) \
+ do { \
+ float_error_arg = num; \
+ float_error_fn_name = name; \
+ in_float = 1; errno = 0; (d); in_float = 0; \
+ switch (errno) { \
+ case 0: break; \
+ case EDOM: domain_error (float_error_fn_name, float_error_arg); \
+ case ERANGE: range_error (float_error_fn_name, float_error_arg); \
+ default: arith_error (float_error_fn_name, float_error_arg); \
+ } \
+ } while (0)
+#define IN_FLOAT2(d, name, num, num2) \
+ do { \
+ float_error_arg = num; \
+ float_error_arg2 = num2; \
+ float_error_fn_name = name; \
+ in_float = 1; errno = 0; (d); in_float = 0; \
+ switch (errno) { \
+ case 0: break; \
+ case EDOM: domain_error (float_error_fn_name, float_error_arg); \
+ case ERANGE: range_error (float_error_fn_name, float_error_arg); \
+ default: arith_error (float_error_fn_name, float_error_arg); \
+ } \
+ } while (0)
+#else
+#define IN_FLOAT(d, name, num) (in_float = 1, (d), in_float = 0)
+#define IN_FLOAT2(d, name, num, num2) (in_float = 1, (d), in_float = 0)
+#endif
+
+/* Convert float to Lisp_Int if it fits, else signal a range error
+ using the given arguments. */
+#define FLOAT_TO_INT(x, i, name, num) \
+ do \
+ { \
+ if (FIXNUM_OVERFLOW_P (x)) \
+ range_error (name, num); \
+ XSETINT (i, (EMACS_INT)(x)); \
+ } \
+ while (0)
+#define FLOAT_TO_INT2(x, i, name, num1, num2) \
+ do \
+ { \
+ if (FIXNUM_OVERFLOW_P (x)) \
+ range_error2 (name, num1, num2); \
+ XSETINT (i, (EMACS_INT)(x)); \
+ } \
+ while (0)
+
+#define arith_error(op,arg) \
+ Fsignal (Qarith_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
+#define range_error(op,arg) \
+ Fsignal (Qrange_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
+#define range_error2(op,a1,a2) \
+ Fsignal (Qrange_error, Fcons (build_string ((op)), \
+ Fcons ((a1), Fcons ((a2), Qnil))))
+#define domain_error(op,arg) \
+ Fsignal (Qdomain_error, Fcons (build_string ((op)), Fcons ((arg), Qnil)))
+#define domain_error2(op,a1,a2) \
+ Fsignal (Qdomain_error, Fcons (build_string ((op)), \
+ Fcons ((a1), Fcons ((a2), Qnil))))