Skip to content

Commit 127ea18

Browse files
committed
Add configure support for determining UINT64_FORMAT, the appropriate
snprintf format for uint64 items.
1 parent feed7cf commit 127ea18

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

configure

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13659,9 +13659,8 @@ fi
1365913659

1366013660
# If we found "long int" is 64 bits, assume snprintf handles it. If
1366113661
# we found we need to use "long long int", better check. We cope with
13662-
# snprintfs that use either %lld, %qd, or %I64d as the format. If
13663-
# neither works, fall back to our own snprintf emulation (which we
13664-
# know uses %lld).
13662+
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
13663+
# work, fall back to our own snprintf emulation (which we know uses %lld).
1366513664

1366613665
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
1366713666
if test $pgac_need_repl_snprintf = no; then
@@ -13744,10 +13743,13 @@ esac
1374413743
# Here if we previously decided we needed to use our own snprintf
1374513744
LONG_LONG_INT_FORMAT='%lld'
1374613745
fi
13746+
LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'`
1374713747
INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
13748+
UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
1374813749
else
1374913750
# Here if we are not using 'long long int' at all
1375013751
INT64_FORMAT='"%ld"'
13752+
UINT64_FORMAT='"%lu"'
1375113753
fi
1375213754

1375313755

@@ -13756,6 +13758,12 @@ cat >>confdefs.h <<_ACEOF
1375613758
_ACEOF
1375713759

1375813760

13761+
13762+
cat >>confdefs.h <<_ACEOF
13763+
#define UINT64_FORMAT $UINT64_FORMAT
13764+
_ACEOF
13765+
13766+
1375913767
if test $pgac_need_repl_snprintf = yes; then
1376013768
LIBOBJS="$LIBOBJS snprintf.$ac_objext"
1376113769
fi

configure.in

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.313 2004/02/02 22:20:32 momjian Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.314 2004/02/10 19:55:45 tgl Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -1063,9 +1063,8 @@ fi
10631063

10641064
# If we found "long int" is 64 bits, assume snprintf handles it. If
10651065
# we found we need to use "long long int", better check. We cope with
1066-
# snprintfs that use either %lld, %qd, or %I64d as the format. If
1067-
# neither works, fall back to our own snprintf emulation (which we
1068-
# know uses %lld).
1066+
# snprintfs that use %lld, %qd, or %I64d as the format. If none of these
1067+
# work, fall back to our own snprintf emulation (which we know uses %lld).
10691068

10701069
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
10711070
if test $pgac_need_repl_snprintf = no; then
@@ -1079,15 +1078,21 @@ if test "$HAVE_LONG_LONG_INT_64" = yes ; then
10791078
# Here if we previously decided we needed to use our own snprintf
10801079
LONG_LONG_INT_FORMAT='%lld'
10811080
fi
1081+
LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'`
10821082
INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
1083+
UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
10831084
else
10841085
# Here if we are not using 'long long int' at all
10851086
INT64_FORMAT='"%ld"'
1087+
UINT64_FORMAT='"%lu"'
10861088
fi
10871089

10881090
AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
10891091
[Define to the appropriate snprintf format for 64-bit ints, if any.])
10901092

1093+
AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
1094+
[Define to the appropriate snprintf format for unsigned 64-bit ints, if any.])
1095+
10911096
if test $pgac_need_repl_snprintf = yes; then
10921097
AC_LIBOBJ(snprintf)
10931098
fi

src/include/pg_config.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@
588588
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
589589
#undef TM_IN_SYS_TIME
590590

591+
/* Define to the appropriate snprintf format for unsigned 64-bit ints, if any.
592+
*/
593+
#undef UINT64_FORMAT
594+
591595
/* Define to 1 to build with assertion checks. (--enable-cassert) */
592596
#undef USE_ASSERT_CHECKING
593597

0 commit comments

Comments
 (0)