diff options
| author | Marc G. Fournier | 1999-03-08 04:17:33 +0000 |
|---|---|---|
| committer | Marc G. Fournier | 1999-03-08 04:17:33 +0000 |
| commit | 75007a72d6d3387c1e5cd6ba11e06c76513bfd64 (patch) | |
| tree | 8c49812e65bad5bb846adca05b0ec94ed4cb93c9 /src/configure.in | |
| parent | a431aaec44020ea1359a5aa035cdbf189baecd90 (diff) | |
Have configure check for use of %lld for int64, and if that fails, check for
use of %qd...a more generic solution then having #ifdef __<INSERT OS HERE>__
in the code...
Diffstat (limited to 'src/configure.in')
| -rw-r--r-- | src/configure.in | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/src/configure.in b/src/configure.in index 4bb74ca8454..cf1b969812d 100644 --- a/src/configure.in +++ b/src/configure.in @@ -788,7 +788,7 @@ dnl If we found "long int" is 64 bits, assume snprintf handles it. dnl If we found we need to use "long long int", better check. if [[ x$SNPRINTF = x -a $HAVE_LONG_LONG_INT_64 -eq 1 ]] ; then - AC_MSG_CHECKING(whether snprintf handles 'long long int') + AC_MSG_CHECKING(whether snprintf handles 'long long int' as %lld) AC_TRY_RUN([#include <stdio.h> typedef long long int int64; #define INT64_FORMAT "%lld" @@ -813,11 +813,45 @@ int does_int64_snprintf_work() main() { exit(! does_int64_snprintf_work()); }], - AC_MSG_RESULT(yes), - [SNPRINTF='snprintf.o' - AC_MSG_RESULT(no)], - [SNPRINTF='snprintf.o' - AC_MSG_RESULT(assuming not on target machine)]) + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INT64_AS_LLD) ], + [ AC_MSG_RESULT(no) + AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd) + AC_TRY_RUN([#include <stdio.h> +typedef long long int int64; +#define INT64_FORMAT "%qd" + +int64 a = 20000001; +int64 b = 40000005; + +int does_int64_snprintf_work() +{ + int64 c; + char buf[100]; + + if (sizeof(int64) != 8) + return 0; /* doesn't look like the right size */ + + c = a * b; + snprintf(buf, 100, INT64_FORMAT, c); + if (strcmp(buf, "800000140000005") != 0) + return 0; /* either multiply or snprintf is busted */ + return 1; +} +main() { + exit(! does_int64_snprintf_work()); +}], + [ AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_INT64_AS_QD) ], + [ SNPRINTF='snprintf.o' + AC_MSG_RESULT(no)], + [ SNPRINTF='snprintf.o' + AC_MSG_RESULT(assuming not on target machine)]) ], + + [ SNPRINTF='snprintf.o' + AC_MSG_RESULT(no)], + [ SNPRINTF='snprintf.o' + AC_MSG_RESULT(assuming not on target machine)]) fi |
