@@ -11817,9 +11817,47 @@ if test "${pgac_cv_type_long_int_64+set}" = set; then
11817
11817
echo $ECHO_N " (cached) $ECHO_C " >&6
11818
11818
else
11819
11819
if test " $cross_compiling " = yes; then
11820
- pgac_cv_type_long_int_64=no
11821
- { echo " $as_me :$LINENO : WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
11822
- echo " $as_me : WARNING: 64 bit arithmetic disabled when cross-compiling" >&2 ; }
11820
+ # If cross-compiling, check the size reported by the compiler and
11821
+ # trust that the arithmetic works.
11822
+ cat > conftest.$ac_ext << _ACEOF
11823
+ #line $LINENO "configure"
11824
+ #include "confdefs.h"
11825
+
11826
+ #ifdef F77_DUMMY_MAIN
11827
+ # ifdef __cplusplus
11828
+ extern "C"
11829
+ # endif
11830
+ int F77_DUMMY_MAIN() { return 1; }
11831
+ #endif
11832
+ int
11833
+ main ()
11834
+ {
11835
+ static int test_array [1 - 2 * !(sizeof(long int) == 8)];
11836
+ test_array [0] = 0
11837
+
11838
+ ;
11839
+ return 0;
11840
+ }
11841
+ _ACEOF
11842
+ rm -f conftest.$ac_objext
11843
+ if { (eval echo " $as_me :$LINENO : \" $ac_compile \" " ) >&5
11844
+ (eval $ac_compile ) 2>&5
11845
+ ac_status=$?
11846
+ echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
11847
+ (exit $ac_status ); } &&
11848
+ { ac_try=' test -s conftest.$ac_objext'
11849
+ { (eval echo " $as_me :$LINENO : \" $ac_try \" " ) >&5
11850
+ (eval $ac_try ) 2>&5
11851
+ ac_status=$?
11852
+ echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
11853
+ (exit $ac_status ); }; }; then
11854
+ pgac_cv_type_long_int_64=yes
11855
+ else
11856
+ echo " $as_me : failed program was:" >&5
11857
+ cat conftest.$ac_ext >&5
11858
+ pgac_cv_type_long_int_64=no
11859
+ fi
11860
+ rm -f conftest.$ac_objext conftest.$ac_ext
11823
11861
else
11824
11862
cat > conftest.$ac_ext << _ACEOF
11825
11863
#line $LINENO "configure"
@@ -11893,9 +11931,47 @@ if test "${pgac_cv_type_long_long_int_64+set}" = set; then
11893
11931
echo $ECHO_N " (cached) $ECHO_C " >&6
11894
11932
else
11895
11933
if test " $cross_compiling " = yes; then
11896
- pgac_cv_type_long_long_int_64=no
11897
- { echo " $as_me :$LINENO : WARNING: 64 bit arithmetic disabled when cross-compiling" >&5
11898
- echo " $as_me : WARNING: 64 bit arithmetic disabled when cross-compiling" >&2 ; }
11934
+ # If cross-compiling, check the size reported by the compiler and
11935
+ # trust that the arithmetic works.
11936
+ cat > conftest.$ac_ext << _ACEOF
11937
+ #line $LINENO "configure"
11938
+ #include "confdefs.h"
11939
+
11940
+ #ifdef F77_DUMMY_MAIN
11941
+ # ifdef __cplusplus
11942
+ extern "C"
11943
+ # endif
11944
+ int F77_DUMMY_MAIN() { return 1; }
11945
+ #endif
11946
+ int
11947
+ main ()
11948
+ {
11949
+ static int test_array [1 - 2 * !(sizeof(long long int) == 8)];
11950
+ test_array [0] = 0
11951
+
11952
+ ;
11953
+ return 0;
11954
+ }
11955
+ _ACEOF
11956
+ rm -f conftest.$ac_objext
11957
+ if { (eval echo " $as_me :$LINENO : \" $ac_compile \" " ) >&5
11958
+ (eval $ac_compile ) 2>&5
11959
+ ac_status=$?
11960
+ echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
11961
+ (exit $ac_status ); } &&
11962
+ { ac_try=' test -s conftest.$ac_objext'
11963
+ { (eval echo " $as_me :$LINENO : \" $ac_try \" " ) >&5
11964
+ (eval $ac_try ) 2>&5
11965
+ ac_status=$?
11966
+ echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
11967
+ (exit $ac_status ); }; }; then
11968
+ pgac_cv_type_long_long_int_64=yes
11969
+ else
11970
+ echo " $as_me : failed program was:" >&5
11971
+ cat conftest.$ac_ext >&5
11972
+ pgac_cv_type_long_long_int_64=no
11973
+ fi
11974
+ rm -f conftest.$ac_objext conftest.$ac_ext
11899
11975
else
11900
11976
cat > conftest.$ac_ext << _ACEOF
11901
11977
#line $LINENO "configure"
@@ -12012,25 +12088,29 @@ rm -f conftest.$ac_objext conftest.$ac_ext
12012
12088
fi
12013
12089
12014
12090
12091
+ # If we found "long int" is 64 bits, assume snprintf handles it. If
12092
+ # we found we need to use "long long int", better check. We cope with
12093
+ # snprintfs that use either %lld, %qd, or %I64d as the format. If
12094
+ # neither works, fall back to our own snprintf emulation (which we
12095
+ # know uses %lld).
12015
12096
12016
- if test x " $HAVE_LONG_LONG_INT_64 " = xyes ; then
12097
+ if test " $HAVE_LONG_LONG_INT_64 " = yes ; then
12017
12098
if test $pgac_need_repl_snprintf = no; then
12018
- echo " $as_me :$LINENO : checking whether snprintf handles 'long long int' as %lld" >&5
12019
- echo $ECHO_N " checking whether snprintf handles 'long long int' as %lld... $ECHO_C " >&6
12020
- if test " $cross_compiling " = yes; then
12021
- echo " $as_me :$LINENO : result: cannot test (not on host machine)" >&5
12022
- echo " ${ECHO_T} cannot test (not on host machine)" >&6
12023
- # Force usage of our own snprintf, since we cannot test foreign snprintf
12024
- pgac_need_repl_snprintf=yes
12025
- INT64_FORMAT=' "%lld"'
12026
-
12099
+ echo " $as_me :$LINENO : checking snprintf format for long long int" >&5
12100
+ echo $ECHO_N " checking snprintf format for long long int... $ECHO_C " >&6
12101
+ if test " ${pgac_cv_snprintf_long_long_int_format+set} " = set ; then
12102
+ echo $ECHO_N " (cached) $ECHO_C " >&6
12103
+ else
12104
+ for pgac_format in ' %lld' ' %qd' ' %I64d' ; do
12105
+ if test " $cross_compiling " = yes; then
12106
+ pgac_cv_snprintf_long_long_int_format=cross; break
12027
12107
else
12028
12108
cat > conftest.$ac_ext << _ACEOF
12029
12109
#line $LINENO "configure"
12030
12110
#include "confdefs.h"
12031
12111
#include <stdio.h>
12032
12112
typedef long long int int64;
12033
- #define INT64_FORMAT "%lld "
12113
+ #define INT64_FORMAT "$pgac_format "
12034
12114
12035
12115
int64 a = 20000001;
12036
12116
int64 b = 40000005;
@@ -12064,91 +12144,38 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
12064
12144
ac_status=$?
12065
12145
echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
12066
12146
(exit $ac_status ); }; }; then
12067
- echo " $as_me :$LINENO : result: yes" >&5
12068
- echo " ${ECHO_T} yes" >&6
12069
- INT64_FORMAT=' "%lld"'
12070
-
12147
+ pgac_cv_snprintf_long_long_int_format=$pgac_format ; break
12071
12148
else
12072
12149
echo " $as_me : program exited with status $ac_status " >&5
12073
12150
echo " $as_me : failed program was:" >&5
12074
12151
cat conftest.$ac_ext >&5
12075
- ( exit $ac_status )
12076
- echo " $as_me :$LINENO : result: no" >&5
12077
- echo " ${ECHO_T} no" >&6
12078
- echo " $as_me :$LINENO : checking whether snprintf handles 'long long int' as %qd" >&5
12079
- echo $ECHO_N " checking whether snprintf handles 'long long int' as %qd... $ECHO_C " >&6
12080
- if test " $cross_compiling " = yes; then
12081
- echo " $as_me :$LINENO : result: cannot test (not on host machine)" >&5
12082
- echo " ${ECHO_T} cannot test (not on host machine)" >&6
12083
- # Force usage of our own snprintf, since we cannot test foreign snprintf
12084
- pgac_need_repl_snprintf=yes
12085
- INT64_FORMAT=' "%lld"'
12086
-
12087
- else
12088
- cat > conftest.$ac_ext << _ACEOF
12089
- #line $LINENO "configure"
12090
- #include "confdefs.h"
12091
- #include <stdio.h>
12092
- typedef long long int int64;
12093
- #define INT64_FORMAT "%qd"
12094
-
12095
- int64 a = 20000001;
12096
- int64 b = 40000005;
12097
-
12098
- int does_int64_snprintf_work()
12099
- {
12100
- int64 c;
12101
- char buf[100];
12102
-
12103
- if (sizeof(int64) != 8)
12104
- return 0; /* doesn't look like the right size */
12105
-
12106
- c = a * b;
12107
- snprintf(buf, 100, INT64_FORMAT, c);
12108
- if (strcmp(buf, "800000140000005") != 0)
12109
- return 0; /* either multiply or snprintf is busted */
12110
- return 1;
12111
- }
12112
- main() {
12113
- exit(! does_int64_snprintf_work());
12114
- }
12115
- _ACEOF
12116
- rm -f conftest$ac_exeext
12117
- if { (eval echo " $as_me :$LINENO : \" $ac_link \" " ) >&5
12118
- (eval $ac_link ) 2>&5
12119
- ac_status=$?
12120
- echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
12121
- (exit $ac_status ); } && { ac_try=' ./conftest$ac_exeext'
12122
- { (eval echo " $as_me :$LINENO : \" $ac_try \" " ) >&5
12123
- (eval $ac_try ) 2>&5
12124
- ac_status=$?
12125
- echo " $as_me :$LINENO : \$ ? = $ac_status " >&5
12126
- (exit $ac_status ); }; }; then
12127
- echo " $as_me :$LINENO : result: yes" >&5
12128
- echo " ${ECHO_T} yes" >&6
12129
- INT64_FORMAT=' "%qd"'
12130
-
12131
- else
12132
- echo " $as_me : program exited with status $ac_status " >&5
12133
- echo " $as_me : failed program was:" >&5
12134
- cat conftest.$ac_ext >&5
12135
- ( exit $ac_status )
12136
- echo " $as_me :$LINENO : result: no" >&5
12137
- echo " ${ECHO_T} no" >&6
12138
- # Force usage of our own snprintf, since system snprintf is broken
12139
- pgac_need_repl_snprintf=yes
12140
- INT64_FORMAT=' "%lld"'
12141
-
12142
12152
fi
12143
12153
rm -f core core.* * .core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
12144
12154
fi
12155
+ done
12145
12156
fi
12146
- rm -f core core.* * .core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
12147
- fi
12157
+
12158
+ LONG_LONG_INT_FORMAT=' '
12159
+
12160
+ case $pgac_cv_snprintf_long_long_int_format in
12161
+ cross) echo " $as_me :$LINENO : result: cannot test (not on host machine)" >&5
12162
+ echo " ${ECHO_T} cannot test (not on host machine)" >&6 ;;
12163
+ ?* ) echo " $as_me :$LINENO : result: $pgac_cv_snprintf_long_long_int_format " >&5
12164
+ echo " ${ECHO_T} $pgac_cv_snprintf_long_long_int_format " >&6
12165
+ LONG_LONG_INT_FORMAT=$pgac_cv_snprintf_long_long_int_format ;;
12166
+ * ) echo " $as_me :$LINENO : result: none" >&5
12167
+ echo " ${ECHO_T} none" >&6 ;;
12168
+ esac
12169
+ if test " $LONG_LONG_INT_FORMAT " = " " ; then
12170
+ # Force usage of our own snprintf, since system snprintf is broken
12171
+ pgac_need_repl_snprintf=yes
12172
+ LONG_LONG_INT_FORMAT=' %lld'
12173
+ fi
12148
12174
else
12149
- # here if we previously decided we needed to use our own snprintf
12150
- INT64_FORMAT= ' " %lld" '
12175
+ # Here if we previously decided we needed to use our own snprintf
12176
+ LONG_LONG_INT_FORMAT= ' %lld'
12151
12177
fi
12178
+ INT64_FORMAT=" \" $LONG_LONG_INT_FORMAT \" "
12152
12179
else
12153
12180
# Here if we are not using 'long long int' at all
12154
12181
INT64_FORMAT=' "%ld"'
0 commit comments