]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
(AC_LANG_INT_SAVE(C)): Also support negative values, down to LONG_MIN.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 18 Sep 2001 17:54:21 +0000 (17:54 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 18 Sep 2001 17:54:21 +0000 (17:54 +0000)
lib/autoconf/c.m4

index 18703648a3bd0c9bd94a2d34db4bee8b0465dcc2..a26dbba249c599adc64079beee44168e9a588a9b 100644 (file)
@@ -208,22 +208,29 @@ _array_ @<:@0@:>@ = 0
 # But we include them only after the EXPRESSION has been evaluated.
 m4_define([AC_LANG_INT_SAVE(C)],
 [AC_LANG_PROGRAM([$1
-unsigned long conftestval () { return $2; }
+long longval () { return $2; }
+unsigned long ulongval () { return $2; }
 @%:@include <stdio.h>
 @%:@include <stdlib.h>],
 [
   FILE *f = fopen ("conftest.val", "w");
-  if (f)
+  if (! f)
+    exit (1);
+  if (($2) < 0)
     {
-      unsigned long i = conftestval ();
-      if (0 <= ($2) && i == ($2))
-       {
-         fprintf (f, "%lu\n", i);
-         if (! ferror (f) && fclose (f) == 0)
-           exit (0);
-       }
+      long i = longval ();
+      if (i != ($2))
+       exit (1);
+      fprintf (f, "%ld\n", i);
     }
-  exit (1);
+  else
+    {
+      unsigned long i = ulongval ();
+      if (i != ($2))
+       exit (1);
+      fprintf (f, "%lu\n", i);
+    }
+  exit (ferror (f) || fclose (f) != 0);
 ])])