Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce48605

Browse files
committed
Add #define INT64_MODIFIER for the printf length modifier for 64-bit ints.
We have had INT64_FORMAT and UINT64_FORMAT for a long time, but that's notgood enough if you want something more exotic, like "%20lld".Abhijit Menon-Sen, per Andres Freund's suggestion.
1 parentfa06982 commitce48605

File tree

6 files changed

+49
-66
lines changed

6 files changed

+49
-66
lines changed

‎config/c-library.m4

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -221,22 +221,22 @@ HAVE_POSIX_SIGNALS=$pgac_cv_func_posix_signals
221221
AC_SUBST(HAVE_POSIX_SIGNALS)])# PGAC_FUNC_POSIX_SIGNALS
222222

223223

224-
#PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
224+
#PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
225225
# ---------------------------------------
226-
# Determine whichformatsnprintf uses for long long int. We handle
227-
#%lld, %qd, %I64d. The result is in shell variable
228-
#LONG_LONG_INT_FORMAT.
226+
# Determine whichlength modifiersnprintf uses for long long int. We
227+
#handle ll, q, and I64. The result is in shell variable
228+
#LONG_LONG_INT_MODIFIER.
229229
#
230230
# MinGW uses '%I64d', though gcc throws an warning with -Wall,
231231
# while '%lld' doesn't generate a warning, but doesn't work.
232232
#
233-
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT],
234-
[AC_MSG_CHECKING([snprintfformat for long long int])
235-
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_format,
236-
[forpgac_format in '%lld' '%qd' '%I64d'; do
233+
AC_DEFUN([PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER],
234+
[AC_MSG_CHECKING([snprintflength modifier for long long int])
235+
AC_CACHE_VAL(pgac_cv_snprintf_long_long_int_modifier,
236+
[forpgac_modifier in 'll' 'q' 'I64'; do
237237
AC_TRY_RUN([#include <stdio.h>
238238
typedef long long int ac_int64;
239-
#define INT64_FORMAT "$pgac_format"
239+
#define INT64_FORMAT "%${pgac_modifier}d"
240240
241241
ac_int64 a = 20000001;
242242
ac_int64 b = 40000005;
@@ -258,19 +258,19 @@ int does_int64_snprintf_work()
258258
main() {
259259
exit(! does_int64_snprintf_work());
260260
}],
261-
[pgac_cv_snprintf_long_long_int_format=$pgac_format; break],
261+
[pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier; break],
262262
[],
263-
[pgac_cv_snprintf_long_long_int_format=cross; break])
263+
[pgac_cv_snprintf_long_long_int_modifier=cross; break])
264264
done])dnl AC_CACHE_VAL
265265
266-
LONG_LONG_INT_FORMAT=''
266+
LONG_LONG_INT_MODIFIER=''
267267
268-
case $pgac_cv_snprintf_long_long_int_format in
268+
case $pgac_cv_snprintf_long_long_int_modifier in
269269
cross)AC_MSG_RESULT([cannot test (not on host machine)]);;
270-
?*)AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_format])
271-
LONG_LONG_INT_FORMAT=$pgac_cv_snprintf_long_long_int_format;;
270+
?*)AC_MSG_RESULT([$pgac_cv_snprintf_long_long_int_modifier])
271+
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
272272
*)AC_MSG_RESULT(none);;
273-
esac])#PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
273+
esac])#PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
274274

275275

276276
# PGAC_FUNC_SNPRINTF_ARG_CONTROL

‎configure

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13095,20 +13095,20 @@ fi
1309513095

1309613096
iftest"$HAVE_LONG_LONG_INT_64" = yes;then
1309713097
iftest$pgac_need_repl_snprintf = no;then
13098-
{$as_echo"$as_me:${as_lineno-$LINENO}: checking snprintfformat for long long int">&5
13099-
$as_echo_n"checking snprintfformat for long long int...">&6; }
13100-
if${pgac_cv_snprintf_long_long_int_format+:}false;then:
13098+
{$as_echo"$as_me:${as_lineno-$LINENO}: checking snprintflength modifier for long long int">&5
13099+
$as_echo_n"checking snprintflength modifier for long long int...">&6; }
13100+
if${pgac_cv_snprintf_long_long_int_modifier+:}false;then:
1310113101
$as_echo_n"(cached)">&6
1310213102
else
13103-
forpgac_formatin'%lld''%qd''%I64d';do
13103+
forpgac_modifierin'll''q''I64';do
1310413104
iftest"$cross_compiling" = yes;then:
13105-
pgac_cv_snprintf_long_long_int_format=cross;break
13105+
pgac_cv_snprintf_long_long_int_modifier=cross;break
1310613106
else
1310713107
cat confdefs.h -<<_ACEOF >conftest.$ac_ext
1310813108
/* end confdefs.h. */
1310913109
#include <stdio.h>
1311013110
typedef long long int ac_int64;
13111-
#define INT64_FORMAT "$pgac_format"
13111+
#define INT64_FORMAT "%${pgac_modifier}d"
1311213112
1311313113
ac_int64 a = 20000001;
1311413114
ac_int64 b = 40000005;
@@ -13132,7 +13132,7 @@ main() {
1313213132
}
1313313133
_ACEOF
1313413134
if ac_fn_c_try_run"$LINENO";then:
13135-
pgac_cv_snprintf_long_long_int_format=$pgac_format;break
13135+
pgac_cv_snprintf_long_long_int_modifier=$pgac_modifier;break
1313613136
fi
1313713137
rm -f core*.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
1313813138
conftest.$ac_objext conftest.beam conftest.$ac_ext
@@ -13141,44 +13141,36 @@ fi
1314113141
done
1314213142
fi
1314313143

13144-
LONG_LONG_INT_FORMAT=''
13144+
LONG_LONG_INT_MODIFIER=''
1314513145

13146-
case$pgac_cv_snprintf_long_long_int_formatin
13146+
case$pgac_cv_snprintf_long_long_int_modifierin
1314713147
cross) {$as_echo"$as_me:${as_lineno-$LINENO}: result: cannot test (not on host machine)">&5
1314813148
$as_echo"cannot test (not on host machine)">&6; };;
13149-
?*) {$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_snprintf_long_long_int_format">&5
13150-
$as_echo"$pgac_cv_snprintf_long_long_int_format">&6; }
13151-
LONG_LONG_INT_FORMAT=$pgac_cv_snprintf_long_long_int_format;;
13149+
?*) {$as_echo"$as_me:${as_lineno-$LINENO}: result:$pgac_cv_snprintf_long_long_int_modifier">&5
13150+
$as_echo"$pgac_cv_snprintf_long_long_int_modifier">&6; }
13151+
LONG_LONG_INT_MODIFIER=$pgac_cv_snprintf_long_long_int_modifier;;
1315213152
*) {$as_echo"$as_me:${as_lineno-$LINENO}: result: none">&5
1315313153
$as_echo"none">&6; };;
1315413154
esac
13155-
iftest"$LONG_LONG_INT_FORMAT" ="";then
13155+
iftest"$LONG_LONG_INT_MODIFIER" ="";then
1315613156
# Force usage of our own snprintf, since system snprintf is broken
1315713157
pgac_need_repl_snprintf=yes
13158-
LONG_LONG_INT_FORMAT='%lld'
13158+
LONG_LONG_INT_MODIFIER='ll'
1315913159
fi
1316013160
else
1316113161
# Here if we previously decided we needed to use our own snprintf
13162-
LONG_LONG_INT_FORMAT='%lld'
13162+
LONG_LONG_INT_MODIFIER='ll'
1316313163
fi
13164-
LONG_LONG_UINT_FORMAT=`echo"$LONG_LONG_INT_FORMAT"| sed's/d$/u/'`
13165-
INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
13166-
UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
1316713164
else
1316813165
# Here if we are not using 'long long int' at all
13169-
INT64_FORMAT='"%ld"'
13170-
UINT64_FORMAT='"%lu"'
13166+
LONG_LONG_INT_MODIFIER='l'
1317113167
fi
1317213168

13173-
13174-
cat>>confdefs.h<<_ACEOF
13175-
#define INT64_FORMAT$INT64_FORMAT
13176-
_ACEOF
13177-
13169+
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
1317813170

1317913171

1318013172
cat>>confdefs.h<<_ACEOF
13181-
#defineUINT64_FORMAT$UINT64_FORMAT
13173+
#defineINT64_MODIFIER$INT64_MODIFIER
1318213174
_ACEOF
1318313175

1318413176

‎configure.in

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,30 +1642,25 @@ fi
16421642

16431643
if test "$HAVE_LONG_LONG_INT_64" = yes ; then
16441644
if test $pgac_need_repl_snprintf = no; then
1645-
PGAC_FUNC_SNPRINTF_LONG_LONG_INT_FORMAT
1646-
if test "$LONG_LONG_INT_FORMAT" = ""; then
1645+
PGAC_FUNC_SNPRINTF_LONG_LONG_INT_MODIFIER
1646+
if test "$LONG_LONG_INT_MODIFIER" = ""; then
16471647
# Force usage of our own snprintf, since system snprintf is broken
16481648
pgac_need_repl_snprintf=yes
1649-
LONG_LONG_INT_FORMAT='%lld'
1649+
LONG_LONG_INT_MODIFIER='ll'
16501650
fi
16511651
else
16521652
# Here if we previously decided we needed to use our own snprintf
1653-
LONG_LONG_INT_FORMAT='%lld'
1653+
LONG_LONG_INT_MODIFIER='ll'
16541654
fi
1655-
LONG_LONG_UINT_FORMAT=`echo "$LONG_LONG_INT_FORMAT" | sed 's/d$/u/'`
1656-
INT64_FORMAT="\"$LONG_LONG_INT_FORMAT\""
1657-
UINT64_FORMAT="\"$LONG_LONG_UINT_FORMAT\""
16581655
else
16591656
# Here if we are not using 'long long int' at all
1660-
INT64_FORMAT='"%ld"'
1661-
UINT64_FORMAT='"%lu"'
1657+
LONG_LONG_INT_MODIFIER='l'
16621658
fi
16631659

1664-
AC_DEFINE_UNQUOTED(INT64_FORMAT, $INT64_FORMAT,
1665-
[Define to the appropriate snprintf format for 64-bit ints.])
1660+
INT64_MODIFIER="\"$LONG_LONG_INT_MODIFIER\""
16661661

1667-
AC_DEFINE_UNQUOTED(UINT64_FORMAT, $UINT64_FORMAT,
1668-
[Define to the appropriate snprintfformat for unsigned 64-bit ints.])
1662+
AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
1663+
[Define to the appropriate snprintflength modifier for 64-bit ints.])
16691664

16701665
# Also force use of our snprintf if the system's doesn't support the %z flag.
16711666
if test "$pgac_need_repl_snprintf" = no; then

‎src/include/c.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ typedef unsigned long long int uint64;
288288
#defineUINT64CONST(x) ((uint64) x)
289289
#endif
290290

291+
/* snprintf format strings to use for 64-bit integers */
292+
#defineINT64_FORMAT "%" INT64_MODIFIER "d"
293+
#defineUINT64_FORMAT "%" INT64_MODIFIER "u"
291294

292295
/* Select timestamp representation (float8 or int64) */
293296
#ifdefUSE_INTEGER_DATETIMES

‎src/include/pg_config.h.in

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@
653653
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
654654
#undef HAVE__VA_ARGS
655655

656-
/* Define to the appropriate snprintfformat for 64-bit ints. */
657-
#undefINT64_FORMAT
656+
/* Define to the appropriate snprintflength modifier for 64-bit ints. */
657+
#undefINT64_MODIFIER
658658

659659
/* Define to 1 if `locale_t' requires <xlocale.h>. */
660660
#undef LOCALE_T_IN_XLOCALE
@@ -744,9 +744,6 @@
744744
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
745745
#undef TM_IN_SYS_TIME
746746

747-
/* Define to the appropriate snprintf format for unsigned 64-bit ints. */
748-
#undef UINT64_FORMAT
749-
750747
/* Define to 1 to build with assertion checks. (--enable-cassert) */
751748
#undef USE_ASSERT_CHECKING
752749

‎src/include/pg_config.h.win32

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@
532532
/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
533533
#define HAVE__VA_ARGS 1
534534

535-
/* Define to the appropriate snprintfformatfor 64-bit ints, if any. */
536-
#defineINT64_FORMAT "%lld"
535+
/* Define to the appropriate snprintflength modifierfor 64-bit ints. */
536+
#defineINT64_MODIFIER "ll"
537537

538538
/* Define to 1 if `locale_t' requires <xlocale.h>. */
539539
/* #undef LOCALE_T_IN_XLOCALE */
@@ -604,10 +604,6 @@
604604
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
605605
/* #undef TM_IN_SYS_TIME */
606606

607-
/* Define to the appropriate snprintf format for unsigned 64-bit ints, if any.
608-
*/
609-
#define UINT64_FORMAT "%llu"
610-
611607
/* Define to 1 to build with assertion checks. (--enable-cassert) */
612608
/* #undef USE_ASSERT_CHECKING */
613609

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp