mini-gmp mpz_{get,set}_d not fully compatible with GMP

Niels Möller nisse at lysator.liu.se
Wed Mar 14 18:10:41 UTC 2018


"Marco Bodrato" <bodrato at mail.dm.unipi.it> writes:

> #if defined(USE_FLOAT_H)
>  #include <float.h>
> #endif

This won't work well for mini-gmp.

> #if defined(DBL_MANT_DIG) && FLT_RADIX == 2
>  #define GMP_BITS_PER_DOUBLE DBL_MANT_DIG
> #endif
>
> #if !defined(GMP_BITS_PER_DOUBLE)
>  #define GMP_BITS_PER_DOUBLE (53)
> #endif

Sounds like a reasonable work-around.

>> I'd also say that <float.h> can be assumed to be available.
>
> mini-gmp is used to bootstrap GMP... should we assume something for mini-
> if we do nota assume it for GMP?

Not really. But for float.h, I think we could use it unconditionally
also in gmp.

Patch below.

Regards,
/Niels

diff -Nprc2 gmp.384bf781a7ee/ChangeLog gmp/ChangeLog
*** gmp.384bf781a7ee/ChangeLog	2018-03-14 19:06:44.139928842 +0100
--- gmp/ChangeLog	2018-03-14 19:06:44.159928787 +0100
***************
*** 1,2 ****
--- 1,8 ----
+ 2018-03-11  Niels Möller  <nisse at lysator.liu.se>
+ 
+ 	* configure.ac: Delete configure check for float.h (introduced in
+ 	2002, for compatibility with SunOS cc). Also delete all use of
+ 	HAVE_FLOAT_H.
+ 
  2018-02-28 Marco Bodrato <bodrato at mail.dm.unipi.it>
  
diff -Nprc2 gmp.384bf781a7ee/configure.ac gmp/configure.ac
*** gmp.384bf781a7ee/configure.ac	2018-03-14 19:06:44.143928831 +0100
--- gmp/configure.ac	2018-03-14 19:06:44.163928775 +0100
*************** AC_HEADER_TIME
*** 2713,2717 ****
  
  # Reasons for testing:
- #   float.h - not in SunOS bundled cc
  #   invent.h - IRIX specific
  #   langinfo.h - X/Open standard only, not in djgpp for instance
--- 2713,2716 ----
*************** AC_HEADER_TIME
*** 2737,2741 ****
  # default tests
  #
! AC_CHECK_HEADERS(fcntl.h float.h invent.h langinfo.h locale.h nl_types.h sys/attributes.h sys/iograph.h sys/mman.h sys/param.h sys/processor.h sys/pstat.h sys/sysinfo.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h)
  
  # On SunOS, sys/resource.h needs sys/time.h (for struct timeval)
--- 2736,2740 ----
  # default tests
  #
! AC_CHECK_HEADERS(fcntl.h invent.h langinfo.h locale.h nl_types.h sys/attributes.h sys/iograph.h sys/mman.h sys/param.h sys/processor.h sys/pstat.h sys/sysinfo.h sys/syssgi.h sys/systemcfg.h sys/time.h sys/times.h)
  
  # On SunOS, sys/resource.h needs sys/time.h (for struct timeval)
diff -Nprc2 gmp.384bf781a7ee/mpf/cmp_d.c gmp/mpf/cmp_d.c
*** gmp.384bf781a7ee/mpf/cmp_d.c	2018-03-14 19:06:44.143928831 +0100
--- gmp/mpf/cmp_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/mpf/set_d.c gmp/mpf/set_d.c
*** gmp.384bf781a7ee/mpf/set_d.c	2018-03-14 19:06:44.143928831 +0100
--- gmp/mpf/set_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/mpq/set_d.c gmp/mpq/set_d.c
*** gmp.384bf781a7ee/mpq/set_d.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/mpq/set_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/mpz/cmpabs_d.c gmp/mpz/cmpabs_d.c
*** gmp.384bf781a7ee/mpz/cmpabs_d.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/mpz/cmpabs_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/mpz/cmp_d.c gmp/mpz/cmp_d.c
*** gmp.384bf781a7ee/mpz/cmp_d.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/mpz/cmp_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/mpz/set_d.c gmp/mpz/set_d.c
*** gmp.384bf781a7ee/mpz/set_d.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/mpz/set_d.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 31,37 ****
  #include "config.h"
  
- #if HAVE_FLOAT_H
  #include <float.h>  /* for DBL_MAX */
- #endif
  
  #include "gmp-impl.h"
--- 31,35 ----
diff -Nprc2 gmp.384bf781a7ee/printf/repl-vsnprintf.c gmp/printf/repl-vsnprintf.c
*** gmp.384bf781a7ee/printf/repl-vsnprintf.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/printf/repl-vsnprintf.c	2018-03-14 19:06:44.163928775 +0100
*************** see https://www.gnu.org/licenses/.  */
*** 45,51 ****
  #include <stdlib.h>
  
- #if HAVE_FLOAT_H
  #include <float.h>     /* for DBL_MAX_10_EXP etc */
- #endif
  
  #if HAVE_INTTYPES_H
--- 45,49 ----
diff -Nprc2 gmp.384bf781a7ee/tests/misc.c gmp/tests/misc.c
*** gmp.384bf781a7ee/tests/misc.c	2018-03-14 19:06:44.147928820 +0100
--- gmp/tests/misc.c	2018-03-14 19:06:44.163928775 +0100
*************** the GNU MP Library test suite.  If not,
*** 26,32 ****
  #include <string.h>
  
- #if HAVE_FLOAT_H
  #include <float.h>      /* for DBL_MANT_DIG */
- #endif
  
  #if TIME_WITH_SYS_TIME
--- 26,30 ----

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list