[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#12381: Assume C89 or later for math functions.
From: |
Eli Zaretskii |
Subject: |
bug#12381: Assume C89 or later for math functions. |
Date: |
Sat, 08 Sep 2012 10:07:55 +0300 |
> Date: Fri, 07 Sep 2012 13:22:38 -0700
> From: Paul Eggert <eggert@cs.ucla.edu>
> CC: Eli Zaretskii <eliz@gnu.org>
>
> In doing signal-handling cleanup I ran afoul of a lot of crufty old
> floating-point code that hasn't been needed in Emacs for many years.
> Since it's getting in the way of improving Emacs I plan to install
> the following patch to clean out the cruft. I don't think this
> affects the Windows port but am CC'ing to Eli just in case.
You missed msdos/*.inp scripts. sed2v2.inp does define
FLOAT_CHECK_DOMAIN for the MSDOS port (although I'm not sure the DOS
port needs this nowadays, see below).
> +2012-09-07 Paul Eggert <eggert@cs.ucla.edu>
> +
> + Assume C89 or later for math functions.
> + This simplifies the code, and makes it a bit smaller and faster,
> + and (most important) makes it easier to clean up signal handling
> + since we can stop worring about floating-point exceptions in
> + library code. That was a problem before C89, but the problem
> + went away many years ago on all practical Emacs targets.
> + * data.c, image.c, lread.c, print.c:
> + Don't include <math.h>; no longer needed.
> + * data.c, floatfns.c (IEEE_FLOATING_POINT): Don't worry that it
> + might be autoconfigured, as that never happens.
> + * data.c (fmod):
> + * doprnt.c (DBL_MAX_10_EXP):
> + * print.c (DBL_DIG):
> + Remove. C89 or later always defines these.
> + * floatfns.c (HAVE_MATHERR, FLOAT_CHECK_ERRNO, FLOAT_CHECK_DOMAIN)
> + (in_float, float_error_arg, float_error_arg2, float_error_fn_name)
> + (arith_error, domain_error, domain_error2):
> + Remove all this pre-C89 cruft. Do not include <errno.h> as that's
> + no longer needed -- we simply return what C returns. All uses removed.
> + (IN_FLOAT, IN_FLOAT2): Remove. All uses replaced with
> + the wrapped code.
> + (FLOAT_TO_INT, FLOAT_TO_INT2, range_error, range_error2):
> + Remove. All uses expanded, as these macros are no longer used
> + more than once and are now more trouble than they're worth.
> + (Ftan): Use tan, not sin / cos.
> + (Flogb): Assume C89 frexp.
> + (fmod_float): Assume C89 fmod.
> + (matherr) [HAVE_MATHERR]: Remove; no longer needed.
> + (init_floatfns): Remove. All uses removed.
I think we should discuss this first. Issues that I consider
non-trivial are:
. Are we sure all supported systems implement the math functions as
assumed by this patch? I'd suggest reviewing the results of
running the configure script on *BSD systems, on AIX, and on old
Solaris, before making the decision.
. Do we really want to remove a possibility of signaling an error on
EDOM and ERANGE? Right now, this is a configure-time option, but
the proposed patch removes it forever. (For that matter, is it TRT
for Emacs to silently continue with HUGE_VAL etc., disregarding
errors in math functions?)
. The pieces related to 'matherr' might still be needed on platforms
which provide that function. I don't remember the details, but
AFAIR the default version of that function may print an error
message, which I think we need to prevent.
. Last, but not least: what exactly does the patch assume about the
math library functions? Those assumptions are not spelled out in
the log entries; without them, it's hard to reason about the
possible implications of the change. E.g., the log entry says "we
can stop worrying about floating-point exceptions in library code",
but AFAIK you _can_ build a C89 program that will generate SIGFPE
in library functions. Maybe I don't understand what exactly is
meant by "floating-point exceptions".
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/07
- bug#12381: Assume C89 or later for math functions.,
Eli Zaretskii <=
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/08
- bug#12381: Assume C89 or later for math functions., Eli Zaretskii, 2012/09/08
- bug#12381: Assume C89 or later for math functions., Ken Brown, 2012/09/08
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/08
- bug#12381: Assume C89 or later for math functions., Ken Brown, 2012/09/08
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/09
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/10
- bug#12381: Assume C89 or later for math functions., Paul Eggert, 2012/09/08