From f96fa5ee2abf0ff382330d67c317bf37166ce03f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 2 Jul 2012 20:33:11 +0000 Subject: [PATCH] Fixes trac:3146: fix faulty configure tests (that were introduced with the new Fortran revamp a few months ago) that failed when you compiled with "ifort -i8". The secret: "test $foo -eq 0" fails when $foo is sufficiently large. So instead, use "test "$foo" = "0"". expr does work with large integers, though, so one "test -lt" was replaced with expr. This commit was SVN r26715. The following Trac tickets were found above: Ticket 3146 --> https://svn.open-mpi.org/trac/ompi/ticket/3146 --- ompi/config/fortran_get_handle_max.m4 | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/ompi/config/fortran_get_handle_max.m4 b/ompi/config/fortran_get_handle_max.m4 index 9a7beeadce..74915fad02 100644 --- a/ompi/config/fortran_get_handle_max.m4 +++ b/ompi/config/fortran_get_handle_max.m4 @@ -39,7 +39,11 @@ AC_DEFUN([OMPI_FORTRAN_GET_HANDLE_MAX],[ # top nybble is 0x7 to avoid sign issues. ompi_numf=`expr $OMPI_SIZEOF_FORTRAN_INTEGER \* 8 - 1` ompi_fint_max=1 - while test $ompi_numf -gt 0; do + # Use string comparisons when comparing these values to + # 0, because $ompi_numf may be larger than "test -eq + # ..." can handle (e.g., if we compile Fortran with + # "ifort -i8"). + while test "$ompi_numf" != "0"; do ompi_fint_max=`expr $ompi_fint_max \* 2` ompi_numf=`expr $ompi_numf - 1` done @@ -60,23 +64,28 @@ fclose(fp);]])], [ #cross compiling is fun. compute INT_MAX same as INTEGER max ompi_numf=`expr $ac_cv_sizeof_int \* 8 - 1` ompi_cint_max=1 - while test $ompi_numf -gt 0 ; do + # Use string comparisons with "test"; see comment above + # for rationale. + while test "$ompi_numf" != "0" ; do ompi_cint_max=`expr $ompi_cint_max \* 2` ompi_numf=`expr $ompi_numf - 1` done]) - if test $ompi_cint_max -eq 0 ; then + # Use string comparisons with "test"; see comment above for + # rationale. + if test "$ompi_cint_max" = "0" ; then # wow - something went really wrong. Be conservative value=32767 - elif test $ompi_fint_max -eq 0 ; then + elif test "$ompi_fint_max" = "0" ; then # we aren't compiling Fortran - just set it to C INT_MAX value=$ompi_cint_max else - # take the lesser of C INT_MAX and Fortran INTEGER - # max. The resulting value will then be storable in - # either type. + # Take the lesser of C INT_MAX and Fortran INTEGER max. + # The resulting value will then be storable in either + # type. Use expr (instead of "test -lt"), because it can + # handle 8-byte integer values. value=$ompi_fint_max - if test $ompi_cint_max -lt $value; then + if test "`expr $ompi_cint_max \< $value`" = "1"; then value=$ompi_cint_max fi fi