]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
(_AC_COMPUTE_INT_COMPILE):
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 30 Sep 2001 15:17:25 +0000 (15:17 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 30 Sep 2001 15:17:25 +0000 (15:17 +0000)
Check for `expr' arithmetic overflow, and for compilation failure,
and invoke a new argument $4 if either is discovered.
This makes _AC_COMPUTE_INT_COMPILE more like _AC_COMPUTE_INT_RUN.
(_AC_COMPUTE_INT): Pass IF-FAILS arg to _AC_COMPUTE_INT_COMPILE.

lib/autoconf/general.m4

index 52b31132735ffbbac65c84f753f314f1aabeb1d8..b7b07375a8a85adbb2c12c7ef253ee56ca97dd8f 100644 (file)
@@ -2503,10 +2503,10 @@ m4_define([AC_LIBOBJ],
 ## ----------------------------------- ##
 
 
-# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, [INCLUDES])
+# _AC_COMPUTE_INT_COMPILE(EXPRESSION, VARIABLE, [INCLUDES], [IF-FAILS])
 # ---------------------------------------------------------
 # Compute the integer EXPRESSION and store the result in the VARIABLE.
-# Works OK if cross compiling.
+# Works OK if cross compiling, but assumes twos-complement arithmetic.
 m4_define([_AC_COMPUTE_INT_COMPILE],
 [# Depending upon the size, compute the lo and hi bounds.
 AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= 0])],
@@ -2514,21 +2514,36 @@ AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= 0])],
   while :; do
     AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])],
                    [ac_hi=$ac_mid; break],
-                   [ac_lo=`expr $ac_mid + 1`; ac_mid=`expr 2 '*' $ac_mid + 1`])
+                   [ac_lo=`expr $ac_mid + 1`
+                    if test $ac_lo -le $ac_mid; then
+                      ac_lo= ac_hi=
+                      break
+                    fi
+                    ac_mid=`expr 2 '*' $ac_mid + 1`])
   done],
+[AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) < 0])],
  [ac_hi=-1 ac_mid=-1
   while :; do
     AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) >= $ac_mid])],
                       [ac_lo=$ac_mid; break],
-                      [ac_hi=`expr '(' $ac_mid ')' - 1`; ac_mid=`expr 2 '*' $ac_mid`])
-  done])
+                      [ac_hi=`expr '(' $ac_mid ')' - 1`
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       ac_mid=`expr 2 '*' $ac_mid`])
+  done],
+ [ac_lo= ac_hi=])])
 # Binary search between lo and hi bounds.
 while test "x$ac_lo" != "x$ac_hi"; do
   ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
   AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([$3], [($1) <= $ac_mid])],
                      [ac_hi=$ac_mid], [ac_lo=`expr '(' $ac_mid ')' + 1`])
 done
-$2=$ac_lo[]dnl
+case $ac_lo in
+?*) $2=$ac_lo;;
+'') $4 ;;
+esac[]dnl
 ])# _AC_COMPUTE_INT_COMPILE
 
 
@@ -2544,7 +2559,7 @@ m4_define([_AC_COMPUTE_INT_RUN],
 # ---------------------------------------------------------
 m4_define([_AC_COMPUTE_INT],
 [if test "$cross_compiling" = yes; then
-  _AC_COMPUTE_INT_COMPILE([$1], [$2], [$3])
+  _AC_COMPUTE_INT_COMPILE([$1], [$2], [$3], [$4])
 else
   _AC_COMPUTE_INT_RUN([$1], [$2], [$3], [$4])
 fi