From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: Using the GNU GMP Library for Bignums in Emacs Date: Wed, 1 Aug 2018 19:06:49 -0700 Organization: UCLA Computer Science Department Message-ID: <287f0b32-00c0-5941-67ac-60971232cb6d@cs.ucla.edu> References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> <87tvpdnzgy.fsf@tromey.com> <4c2a814f-c254-29e5-39cf-11b5f2e5c9c8@cs.ucla.edu> <49d8ba62-c9a5-9203-d882-8e900b441ff3@cs.ucla.edu> <8e0320d9-e0d0-2b57-57cc-2df4399f133c@cs.ucla.edu> <87lgaio7xd.fsf@tromey.com> <877em1cb0i.fsf@tromey.com> <765767b2-d2e5-a9a6-f724-d58ecf4847bb@cs.ucla.edu> <1452F858-C7FD-4AEB-BB85-D874692F918F@raeburn.org> <5b3be3f4-d438-166a-863a-587c880584c8@cs.ucla.edu> <94d69bf6-d186-3607-5b1d-9dee4a08ace1@cs.ucla.edu> <83wotamh65.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------316224F31D6878F9D6E2632A" X-Trace: blaine.gmane.org 1533175550 11483 195.159.176.226 (2 Aug 2018 02:05:50 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 2 Aug 2018 02:05:50 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cc: emacs-devel@gnu.org, raeburn@raeburn.org, tom@tromey.com, monnier@IRO.UMontreal.CA, rms@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 02 04:05:45 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fl2zo-0002sl-Kx for ged-emacs-devel@m.gmane.org; Thu, 02 Aug 2018 04:05:44 +0200 Original-Received: from localhost ([::1]:43566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fl31v-0002qf-2q for ged-emacs-devel@m.gmane.org; Wed, 01 Aug 2018 22:07:55 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54099) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fl315-0002qN-Lo for emacs-devel@gnu.org; Wed, 01 Aug 2018 22:07:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fl313-0004Go-4w for emacs-devel@gnu.org; Wed, 01 Aug 2018 22:07:03 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:41374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fl30y-00049p-Rr; Wed, 01 Aug 2018 22:06:57 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 19F00160825; Wed, 1 Aug 2018 19:06:55 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id sdiSWqIbGKjR; Wed, 1 Aug 2018 19:06:50 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B166C160E71; Wed, 1 Aug 2018 19:06:50 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id iDzCmsL9ASt7; Wed, 1 Aug 2018 19:06:50 -0700 (PDT) Original-Received: from [192.168.1.9] (unknown [47.154.30.119]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 2182D160825; Wed, 1 Aug 2018 19:06:50 -0700 (PDT) Openpgp: preference=signencrypt Autocrypt: addr=eggert@cs.ucla.edu; prefer-encrypt=mutual; keydata= xsFNBEyAcmQBEADAAyH2xoTu7ppG5D3a8FMZEon74dCvc4+q1XA2J2tBy2pwaTqfhpxxdGA9 Jj50UJ3PD4bSUEgN8tLZ0san47l5XTAFLi2456ciSl5m8sKaHlGdt9XmAAtmXqeZVIYX/UFS 96fDzf4xhEmm/y7LbYEPQdUdxu47xA5KhTYp5bltF3WYDz1Ygd7gx07Auwp7iw7eNvnoDTAl KAl8KYDZzbDNCQGEbpY3efZIvPdeI+FWQN4W+kghy+P6au6PrIIhYraeua7XDdb2LS1en3Ss mE3QjqfRqI/A2ue8JMwsvXe/WK38Ezs6x74iTaqI3AFH6ilAhDqpMnd/msSESNFt76DiO1ZK QMr9amVPknjfPmJISqdhgB1DlEdw34sROf6V8mZw0xfqT6PKE46LcFefzs0kbg4GORf8vjG2 Sf1tk5eU8MBiyN/bZ03bKNjNYMpODDQQwuP84kYLkX2wBxxMAhBxwbDVZudzxDZJ1C2VXujC OJVxq2kljBM9ETYuUGqd75AW2LXrLw6+MuIsHFAYAgRr7+KcwDgBAfwhPBYX34nSSiHlmLC+ KaHLeCLF5ZI2vKm3HEeCTtlOg7xZEONgwzL+fdKo+D6SoC8RRxJKs8a3sVfI4t6CnrQzvJbB n6gxdgCu5i29J1QCYrCYvql2UyFPAK+do99/1jOXT4m2836j1wARAQABzSBQYXVsIEVnZ2Vy dCA8ZWdnZXJ0QGNzLnVjbGEuZWR1PsLBfgQTAQIAKAUCTIByZAIbAwUJEswDAAYLCQgHAwIG FQgCCQoLBBYCAwECH In-Reply-To: <83wotamh65.fsf@gnu.org> Content-Language: en-US X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 131.179.128.68 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:228099 Archived-At: This is a multi-part message in MIME format. --------------316224F31D6878F9D6E2632A Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Eli Zaretskii wrote: > isn't there a way to test whether a platform supports IEEE > FP representation except by looking for ieee754.h? AFAICS, that > header just defines a few data structures that any IEEE-compliant > platform should be able to work with. We can try using ieee754.h on non-GNU platforms and see what happens. In = theory,=20 there could be weird platforms where it doesn't work (as no standard spec= ifies=20 IEEE 754 layout); in practice, we'll probably be OK. So I created a Gnuli= b=20 module for ieee754.h, merged it in, and installed the attached into maste= r. --------------316224F31D6878F9D6E2632A Content-Type: text/x-patch; name="0001-Substitute-a-ieee754.h-on-hosts-lacking-it.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-Substitute-a-ieee754.h-on-hosts-lacking-it.patch" =46rom d216d7d248199aa6c99cd642116717c5b301ae6d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 1 Aug 2018 18:53:31 -0700 Subject: [PATCH] Substitute a on hosts lacking it * .gitignore: Add lib/ieee754.h. * admin/merge-gnulib (GNULIB_MODULES): Add ieee754-h. * configure.ac: Remove ieee754.h check, as Gnulib now does that. * etc/NEWS: Mention this. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/ieee754.in.h, m4/ieee754-h.m4: New files, from Gnulib. * src/lisp.h (IEEE_FLOATING_POINT): Now a macro so that it can be used in #if. * src/lread.c, src/print.c: Include if IEEE_FLOATING_POINT, not if HAVE_IEEE754_H. * src/lread.c (string_to_number): * src/print.c (float_to_string): Process NaNs only on IEEE hosts, and assume in that case. --- .gitignore | 1 + admin/merge-gnulib | 2 +- configure.ac | 1 - etc/NEWS | 6 +- lib/gnulib.mk.in | 29 +++++++ lib/ieee754.in.h | 222 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++ m4/gnulib-comp.m4 | 4 + m4/ieee754-h.m4 | 21 +++++ src/lisp.h | 11 +-- src/lread.c | 9 +-- src/print.c | 25 +----- 11 files changed, 291 insertions(+), 40 deletions(-) create mode 100644 lib/ieee754.in.h create mode 100644 m4/ieee754-h.m4 diff --git a/.gitignore b/.gitignore index d3712b0..26fe4bb 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,7 @@ lib/execinfo.h lib/fcntl.h lib/getopt.h lib/getopt-cdefs.h +lib/ieee754.h lib/inttypes.h lib/libgnu.a lib/limits.h diff --git a/admin/merge-gnulib b/admin/merge-gnulib index 39dfaee..1397ecf 100755 --- a/admin/merge-gnulib +++ b/admin/merge-gnulib @@ -35,7 +35,7 @@ GNULIB_MODULES=3D fcntl fcntl-h fdatasync fdopendir filemode filevercmp flexmember fpieee fstatat fsusage fsync getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog - ignore-value intprops largefile lstat + ieee754-h ignore-value intprops largefile lstat manywarnings memrchr minmax mkostemp mktime nstrftime pipe2 pselect pthread_sigmask putenv qcopy-acl readlink readlinkat sig2str socklen stat-time std-gnu11 stdalign stddef stdio diff --git a/configure.ac b/configure.ac index dbdcce7..b691867 100644 --- a/configure.ac +++ b/configure.ac @@ -1668,7 +1668,6 @@ AC_DEFUN =20 dnl checks for header files AC_CHECK_HEADERS_ONCE( - ieee754.h linux/fs.h malloc.h sys/systeminfo.h diff --git a/etc/NEWS b/etc/NEWS index 9e7a765..6c79a46 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -880,9 +880,9 @@ Formerly, some of these functions ignored signs and s= ignificands of NaNs. Now, all these functions treat NaN signs and significands as significant. For example, (eql 0.0e+NaN -0.0e+NaN) now returns nil because the two NaNs have different signs; formerly it returned t. -Also, on platforms that have Emacs now reads and prints -NaN significands; e.g., if X is a NaN, (format "%s" X) now returns -"0.0e+NaN", "1.0e+NaN", etc., depending on X's significand. +Also, Emacs now reads and prints NaN significands; e.g., if X is a +NaN, (format "%s" X) now returns "0.0e+NaN", "1.0e+NaN", etc., +depending on X's significand. =20 +++ ** The function 'make-string' accepts an additional optional argument. diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in index e623921..7d28dcc 100644 --- a/lib/gnulib.mk.in +++ b/lib/gnulib.mk.in @@ -95,6 +95,7 @@ # gettime \ # gettimeofday \ # gitlog-to-changelog \ +# ieee754-h \ # ignore-value \ # intprops \ # largefile \ @@ -220,6 +221,7 @@ GL_GENERATE_ALLOCA_H =3D @GL_GENERATE_ALLOCA_H@ GL_GENERATE_BYTESWAP_H =3D @GL_GENERATE_BYTESWAP_H@ GL_GENERATE_ERRNO_H =3D @GL_GENERATE_ERRNO_H@ GL_GENERATE_EXECINFO_H =3D @GL_GENERATE_EXECINFO_H@ +GL_GENERATE_IEEE754_H =3D @GL_GENERATE_IEEE754_H@ GL_GENERATE_LIMITS_H =3D @GL_GENERATE_LIMITS_H@ GL_GENERATE_STDALIGN_H =3D @GL_GENERATE_STDALIGN_H@ GL_GENERATE_STDDEF_H =3D @GL_GENERATE_STDDEF_H@ @@ -646,6 +648,7 @@ HAVE_WINSOCK2_H =3D @HAVE_WINSOCK2_H@ HAVE_XSERVER =3D @HAVE_XSERVER@ HAVE__EXIT =3D @HAVE__EXIT@ HYBRID_MALLOC =3D @HYBRID_MALLOC@ +IEEE754_H =3D @IEEE754_H@ IMAGEMAGICK_CFLAGS =3D @IMAGEMAGICK_CFLAGS@ IMAGEMAGICK_LIBS =3D @IMAGEMAGICK_LIBS@ INCLUDE_NEXT =3D @INCLUDE_NEXT@ @@ -1787,6 +1790,32 @@ EXTRA_libgnu_a_SOURCES +=3D group-member.c endif ## end gnulib module group-member =20 +## begin gnulib module ieee754-h +ifeq (,$(OMIT_GNULIB_MODULE_ieee754-h)) + +BUILT_SOURCES +=3D $(IEEE754_H) + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +ifneq (,$(GL_GENERATE_IEEE754_H)) +ieee754.h: ieee754.in.h $(top_builddir)/config.status + $(AM_V_GEN)rm -f $@-t && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's/ifndef _GL_GNULIB_HEADER/if 0/g' \ + $(srcdir)/ieee754.in.h; \ + } > $@-t && \ + mv -f $@-t $@ +else +ieee754.h: $(top_builddir)/config.status + rm -f $@ +endif +MOSTLYCLEANFILES +=3D ieee754.h ieee754.h-t + +EXTRA_DIST +=3D ieee754.in.h + +endif +## end gnulib module ieee754-h + ## begin gnulib module ignore-value ifeq (,$(OMIT_GNULIB_MODULE_ignore-value)) =20 diff --git a/lib/ieee754.in.h b/lib/ieee754.in.h new file mode 100644 index 0000000..316ac03 --- /dev/null +++ b/lib/ieee754.in.h @@ -0,0 +1,222 @@ +/* Copyright (C) 1992-2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 3 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _IEEE754_H + +#define _IEEE754_H 1 + +#ifndef _GL_GNULIB_HEADER +/* Ordinary glibc usage. */ +# include +# include +#else +/* Gnulib usage. */ +# ifndef __BEGIN_DECLS +# ifdef __cplusplus +# define __BEGIN_DECLS extern "C" { +# define __END_DECLS } +# else +# define __BEGIN_DECLS +# define __END_DECLS +# endif +# endif +# ifndef __FLOAT_WORD_ORDER +# define __LITTLE_ENDIAN 1234 +# define __BIG_ENDIAN 4321 +# ifdef WORDS_BIGENDIAN +# define __BYTE_ORDER __BIG_ENDIAN +# else +# define __BYTE_ORDER __LITTLE_ENDIAN +# endif +# define __FLOAT_WORD_ORDER __BYTE_ORDER +# endif +#endif + +__BEGIN_DECLS + +union ieee754_float + { + float f; + + /* This is the IEEE 754 single-precision format. */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int mantissa:23; +#endif /* Big endian. */ +#if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN + unsigned int mantissa:23; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. = */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:8; + unsigned int quiet_nan:1; + unsigned int mantissa:22; +#endif /* Big endian. */ +#if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN + unsigned int mantissa:22; + unsigned int quiet_nan:1; + unsigned int exponent:8; + unsigned int negative:1; +#endif /* Little endian. */ + } ieee_nan; + }; + +#define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent. */ + + +union ieee754_double + { + double d; + + /* This is the IEEE 754 double-precision format. */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:20; + unsigned int mantissa1:32; +#endif /* Big endian. */ +#if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER =3D=3D __BIG_ENDIAN + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:20; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif /* Little endian. */ + } ieee; + + /* This format makes it easier to see if a NaN is a signalling NaN. = */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:11; + unsigned int quiet_nan:1; + /* Together these comprise the mantissa. */ + unsigned int mantissa0:19; + unsigned int mantissa1:32; +#else +# if __FLOAT_WORD_ORDER =3D=3D __BIG_ENDIAN + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; + unsigned int mantissa1:32; +# else + /* Together these comprise the mantissa. */ + unsigned int mantissa1:32; + unsigned int mantissa0:19; + unsigned int quiet_nan:1; + unsigned int exponent:11; + unsigned int negative:1; +# endif +#endif + } ieee_nan; + }; + +#define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent. */ + + +union ieee854_long_double + { + long double d; + + /* This is the IEEE 854 double-extended-precision format. */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + unsigned int empty:16; + unsigned int mantissa0:32; + unsigned int mantissa1:32; +#endif +#if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER =3D=3D __BIG_ENDIAN + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; + unsigned int mantissa0:32; + unsigned int mantissa1:32; +# else + unsigned int mantissa1:32; + unsigned int mantissa0:32; + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; +# endif +#endif + } ieee; + + /* This is for NaNs in the IEEE 854 double-extended-precision format= =2E */ + struct + { +#if __BYTE_ORDER =3D=3D __BIG_ENDIAN + unsigned int negative:1; + unsigned int exponent:15; + unsigned int empty:16; + unsigned int one:1; + unsigned int quiet_nan:1; + unsigned int mantissa0:30; + unsigned int mantissa1:32; +#endif +#if __BYTE_ORDER =3D=3D __LITTLE_ENDIAN +# if __FLOAT_WORD_ORDER =3D=3D __BIG_ENDIAN + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; + unsigned int mantissa0:30; + unsigned int quiet_nan:1; + unsigned int one:1; + unsigned int mantissa1:32; +# else + unsigned int mantissa1:32; + unsigned int mantissa0:30; + unsigned int quiet_nan:1; + unsigned int one:1; + unsigned int exponent:15; + unsigned int negative:1; + unsigned int empty:16; +# endif +#endif + } ieee_nan; + }; + +#define IEEE854_LONG_DOUBLE_BIAS 0x3fff + +__END_DECLS + +#endif /* ieee754.h */ diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4 index a6e3be3..494c77c 100644 --- a/m4/gnulib-comp.m4 +++ b/m4/gnulib-comp.m4 @@ -101,6 +101,7 @@ AC_DEFUN # Code from module gettimeofday: # Code from module gitlog-to-changelog: # Code from module group-member: + # Code from module ieee754-h: # Code from module ignore-value: # Code from module include_next: # Code from module intprops: @@ -295,6 +296,7 @@ AC_DEFUN gl_PREREQ_GETTIMEOFDAY fi gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + gl_IEEE754_H gl_INTTYPES_INCOMPLETE AC_REQUIRE([gl_LARGEFILE]) gl_LIMITS_H @@ -895,6 +897,7 @@ AC_DEFUN lib/gettimeofday.c lib/gl_openssl.h lib/group-member.c + lib/ieee754.in.h lib/ignore-value.h lib/intprops.h lib/inttypes.in.h @@ -1017,6 +1020,7 @@ AC_DEFUN m4/gl-openssl.m4 m4/gnulib-common.m4 m4/group-member.m4 + m4/ieee754-h.m4 m4/include_next.m4 m4/inttypes.m4 m4/largefile.m4 diff --git a/m4/ieee754-h.m4 b/m4/ieee754-h.m4 new file mode 100644 index 0000000..bf7c332 --- /dev/null +++ b/m4/ieee754-h.m4 @@ -0,0 +1,21 @@ +# Configure ieee754-h module + +dnl Copyright 2018 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_IEEE754_H], +[ + AC_REQUIRE([AC_C_BIGENDIAN]) + AC_CHECK_HEADERS_ONCE([ieee754.h]) + if test $ac_cv_header_ieee754_h =3D yes; then + IEEE754_H=3D + else + IEEE754_H=3Dieee754.h + AC_DEFINE([_GL_REPLACE_IEEE754_H], 1, + [Define to 1 if is missing.]) + fi + AC_SUBST([IEEE754_H]) + AM_CONDITIONAL([GL_GENERATE_IEEE754_H], [test -n "$IEEE754_H"]) +]) diff --git a/src/lisp.h b/src/lisp.h index 96de60e..bdece81 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2670,17 +2670,14 @@ XFLOAT_DATA (Lisp_Object f) =20 /* Most hosts nowadays use IEEE floating point, so they use IEC 60559 representations, have infinities and NaNs, and do not trap on - exceptions. Define IEEE_FLOATING_POINT if this host is one of the + exceptions. Define IEEE_FLOATING_POINT to 1 if this host is one of t= he typical ones. The C11 macro __STDC_IEC_559__ is close to what is wanted here, but is not quite right because Emacs does not require all the features of C11 Annex F (and does not require C11 at all, for that matter). */ -enum - { - IEEE_FLOATING_POINT - =3D (FLT_RADIX =3D=3D 2 && FLT_MANT_DIG =3D=3D 24 - && FLT_MIN_EXP =3D=3D -125 && FLT_MAX_EXP =3D=3D 128) - }; + +#define IEEE_FLOATING_POINT (FLT_RADIX =3D=3D 2 && FLT_MANT_DIG =3D=3D 2= 4 \ + && FLT_MIN_EXP =3D=3D -125 && FLT_MAX_EXP =3D=3D 128) =20 /* A character, declared with the following typedef, is a member of some character set associated with the current buffer. */ diff --git a/src/lread.c b/src/lread.c index 290b0f6..9a025d8 100644 --- a/src/lread.c +++ b/src/lread.c @@ -72,7 +72,7 @@ along with GNU Emacs. If not, see . */ #define file_tell ftell #endif =20 -#if HAVE_IEEE754_H +#if IEEE_FLOATING_POINT # include #endif =20 @@ -3756,21 +3756,18 @@ string_to_number (char const *string, int base, i= nt flags) cp +=3D 3; value =3D INFINITY; } +#if IEEE_FLOATING_POINT else if (cp[-1] =3D=3D '+' && cp[0] =3D=3D 'N' && cp[1] =3D=3D 'a' && cp[2] =3D=3D 'N') { state |=3D E_EXP; cp +=3D 3; -#if HAVE_IEEE754_H union ieee754_double u =3D { .ieee_nan =3D { .exponent =3D -1, .quiet_nan =3D 1, .mantissa0 =3D n >> 31 >> 1, .mantissa1 =3D n }}; value =3D u.d; -#else - /* NAN is a "positive" NaN on all known Emacs hosts. */ - value =3D NAN; -#endif } +#endif else cp =3D ecp; } diff --git a/src/print.c b/src/print.c index add2160..34c7fa1 100644 --- a/src/print.c +++ b/src/print.c @@ -40,7 +40,7 @@ along with GNU Emacs. If not, see . */ #include #include =20 -#if HAVE_IEEE754_H +#if IEEE_FLOATING_POINT # include #endif =20 @@ -1013,34 +1013,15 @@ float_to_string (char *buf, double data) strcpy (buf, minus_infinity_string + positive); return sizeof minus_infinity_string - 1 - positive; } +#if IEEE_FLOATING_POINT if (isnan (data)) { -#if HAVE_IEEE754_H union ieee754_double u =3D { .d =3D data }; uprintmax_t hi =3D u.ieee_nan.mantissa0; return sprintf (buf, &"-%"pMu".0e+NaN"[!u.ieee_nan.negative], (hi << 31 << 1) + u.ieee_nan.mantissa1); -#else - /* Prepend "-" if the NaN's sign bit is negative. - The sign bit of a double is the bit that is 1 in -0.0. */ - static char const NaN_string[] =3D "0.0e+NaN"; - int i; - union { double d; char c[sizeof (double)]; } u_data, u_minus_zero;= - bool negative =3D 0; - u_data.d =3D data; - u_minus_zero.d =3D - 0.0; - for (i =3D 0; i < sizeof (double); i++) - if (u_data.c[i] & u_minus_zero.c[i]) - { - *buf =3D '-'; - negative =3D 1; - break; - } - - strcpy (buf + negative, NaN_string); - return negative + sizeof NaN_string - 1; -#endif } +#endif =20 if (NILP (Vfloat_output_format) || !STRINGP (Vfloat_output_format)) --=20 2.7.4 --------------316224F31D6878F9D6E2632A--