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...
This commit is contained in:
Marc G. Fournier 1999-03-08 04:17:33 +00:00
parent a431aaec44
commit 75007a72d6
4 changed files with 679 additions and 435 deletions

1054
src/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -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. 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 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> AC_TRY_RUN([#include <stdio.h>
typedef long long int int64; typedef long long int int64;
#define INT64_FORMAT "%lld" #define INT64_FORMAT "%lld"
@ -813,11 +813,45 @@ int does_int64_snprintf_work()
main() { main() {
exit(! does_int64_snprintf_work()); exit(! does_int64_snprintf_work());
}], }],
AC_MSG_RESULT(yes), [ AC_MSG_RESULT(yes)
[SNPRINTF='snprintf.o' AC_DEFINE(HAVE_INT64_AS_LLD) ],
AC_MSG_RESULT(no)], [ AC_MSG_RESULT(no)
[SNPRINTF='snprintf.o' AC_MSG_CHECKING(whether snprintf handles 'long long int' as %qd)
AC_MSG_RESULT(assuming not on target machine)]) 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 fi

View File

@ -281,6 +281,12 @@ extern void srandom(unsigned int seed);
/* Set to 1 if your DBL_MIN is problematic */ /* Set to 1 if your DBL_MIN is problematic */
#undef HAVE_DBL_MIN_PROBLEM #undef HAVE_DBL_MIN_PROBLEM
/* Set to 1 if your snprintf has %lld for 'long long int' */
#undef HAVE_INT64_AS_LLD
/* Set to 1 if your snprintf has %qd for 'long long int' */
#undef HAVE_INT64_AS_QD
/* Set to 1 if type "long int" works and is 64 bits */ /* Set to 1 if type "long int" works and is 64 bits */
#undef HAVE_LONG_INT_64 #undef HAVE_LONG_INT_64

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: int8.h,v 1.10 1999/02/13 23:22:23 momjian Exp $ * $Id: int8.h,v 1.11 1999/03/08 04:17:33 scrappy Exp $
* *
* NOTES * NOTES
* These data types are supported on all 64-bit architectures, and may * These data types are supported on all 64-bit architectures, and may
@ -33,7 +33,11 @@ typedef long int int64;
/* We have working support for "long long int", use that */ /* We have working support for "long long int", use that */
typedef long long int int64; typedef long long int int64;
#define INT64_FORMAT "%lld" #ifdef HAVE_INT64_AS_LLD
# define INT64_FORMAT "%lld"
#elif HAVE_INT64_AS_QD
# define INT64_FORMAT "%qd"
#endif
#else #else
/* Won't actually work, but fall back to long int so that int8.c compiles */ /* Won't actually work, but fall back to long int so that int8.c compiles */
typedef long int int64; typedef long int int64;