Including <limits.h> in gmp-impl.h

Marc Glisse marc.glisse at inria.fr
Fri Dec 27 14:06:49 UTC 2013


On Fri, 27 Dec 2013, Torbjorn Granlund wrote:

> Marc Glisse <marc.glisse at inria.fr> writes:
>
>  I couldn't find anything other than the -mcpu=ultrasparc ABI=32 issue
>  with gcc-2.9x around 1999-2000.
>
> I haven't looked deeply into this issue, but to me it seems strange that
> we define INT_MAX etc ourselves.
>
> I think we might trust limits.h these days.  If a 15 year old system
> then gets desupported, too bad.

Then I am considering pushing the attached patch soon.

-- 
Marc Glisse
-------------- next part --------------
diff -r 709a37323927 ChangeLog
--- a/ChangeLog	Fri Dec 27 07:50:29 2013 +0100
+++ b/ChangeLog	Fri Dec 27 15:02:47 2013 +0100
@@ -1,3 +1,9 @@
+2013-12-27  Marc Glisse  <marc.glisse at inria.fr>
+
+	* configure.ac: Test for <limits.h>.
+	* gmp-impl.h: Include <limits.h> if available.
+	* tests/mpn/t-get_d.c: Remove comment about <limits.h>
+
 2013-12-26 Marco Bodrato <bodrato at mail.dm.unipi.it>
 
 	* Update many file's encoding to UTF-8.
diff -r 709a37323927 configure.ac
--- a/configure.ac	Fri Dec 27 07:50:29 2013 +0100
+++ b/configure.ac	Fri Dec 27 15:02:47 2013 +0100
@@ -2597,7 +2597,7 @@
 # inttypes.h, stdint.h, unistd.h and sys/types.h are already in the autoconf
 # 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)
+AC_CHECK_HEADERS(fcntl.h float.h invent.h langinfo.h limits.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)
 AC_CHECK_HEADERS(sys/resource.h,,,
diff -r 709a37323927 gmp-impl.h
--- a/gmp-impl.h	Fri Dec 27 07:50:29 2013 +0100
+++ b/gmp-impl.h	Fri Dec 27 15:02:47 2013 +0100
@@ -36,9 +36,9 @@
 #include <intrinsics.h>  /* for _popcnt */
 #endif
 
-/* limits.h is not used in general, since it's an ANSI-ism, and since on
-   solaris gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong
-   values (the ABI=64 values).
+/* For INT_MAX, etc. We used to avoid it because of a bug (on solaris,
+   gcc 2.95 under -mcpu=ultrasparc in ABI=32 ends up getting wrong
+   values (the ABI=64 values)), but it should be safe now.
 
    On Cray vector systems, however, we need the system limits.h since sizes
    of signed and unsigned types can differ there, depending on compiler
@@ -46,7 +46,7 @@
    reference, int can be 46 or 64 bits, whereas uint is always 64 bits; and
    short can be 24, 32, 46 or 64 bits, and different for ushort.  */
 
-#if defined _CRAY
+#if HAVE_LIMITS_H
 #include <limits.h>
 #endif
 
diff -r 709a37323927 tests/mpn/t-get_d.c
--- a/tests/mpn/t-get_d.c	Fri Dec 27 07:50:29 2013 +0100
+++ b/tests/mpn/t-get_d.c	Fri Dec 27 15:02:47 2013 +0100
@@ -17,12 +17,6 @@
 You should have received a copy of the GNU General Public License along with
 the GNU MP Library test suite.  If not, see https://www.gnu.org/licenses/.  */
 
-/* Note that we don't use <limits.h> for LONG_MIN, but instead our own
-   definition in gmp-impl.h.  In gcc 2.95.4 (debian 3.0) under
-   -mcpu=ultrasparc, limits.h sees __sparc_v9__ defined and assumes that
-   means long is 64-bit long, but it's only 32-bits, causing fatal compile
-   errors.  */
-
 #include "config.h"
 
 #include <setjmp.h>


More information about the gmp-devel mailing list