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

Commit109de05

Browse files
committed
Fix portability issues in pg_bitutils
We were using uint64 function arguments as "long int" arguments tocompiler builtins, which fails on machines where long ints are 32 bits:the upper half of the uint64 was being ignored. Fix by using the "ll"builtin variants instead, which on those machines take 64 bit arguments.Also, remove configure tests for __builtin_popcountl() (as well as"long" variants for ctz and clz): the theory here is that any compilerversion will provide all widths or none, so one test suffices. Werethis theory to be wrong, we'd have to add tests for__builtin_popcountll() and friends, which would be tedious.Per failures in buildfarm member lapwing and ensuing discussion.
1 parent80c468b commit109de05

File tree

6 files changed

+87
-245
lines changed

6 files changed

+87
-245
lines changed

‎config/c-compiler.m4

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -400,28 +400,6 @@ undefine([Ac_cachevar])dnl
400400

401401

402402

403-
# PGAC_C_BUILTIN_POPCOUNTL
404-
# -------------------------
405-
AC_DEFUN([PGAC_C_BUILTIN_POPCOUNTL],
406-
[define([Ac_cachevar],[AS_TR_SH([pgac_cv_popcountl])])dnl
407-
AC_CACHE_CHECK([for __builtin_popcountl],[Ac_cachevar],
408-
[pgac_save_CFLAGS=$CFLAGS
409-
CFLAGS="$pgac_save_CFLAGS -mpopcnt"
410-
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
411-
[static int x = __builtin_popcountl(255);])],
412-
[Ac_cachevar=yes],
413-
[Ac_cachevar=no])
414-
CFLAGS="$pgac_save_CFLAGS"])
415-
if test x"$Ac_cachevar" = x"yes"; then
416-
CFLAGS_POPCNT="-mpopcnt"
417-
AC_DEFINE(HAVE__BUILTIN_POPCOUNTL,1,
418-
[Define to 1 if your compiler understands __builtin_popcountl.])
419-
fi
420-
undefine([Ac_cachevar])dnl
421-
])# PGAC_C_BUILTIN_POPCOUNTL
422-
423-
424-
425403
# PGAC_C_BUILTIN_CTZ
426404
# -------------------------
427405
# Check if the C compiler understands __builtin_ctz(),
@@ -440,24 +418,6 @@ fi])# PGAC_C_BUILTIN_CTZ
440418

441419

442420

443-
# PGAC_C_BUILTIN_CTZL
444-
# -------------------------
445-
# Check if the C compiler understands __builtin_ctzl(),
446-
# and define HAVE__BUILTIN_CTZL if so.
447-
AC_DEFUN([PGAC_C_BUILTIN_CTZL],
448-
[AC_CACHE_CHECK(for__builtin_ctzl,pgac_cv__builtin_ctzl,
449-
[AC_COMPILE_IFELSE([AC_LANG_SOURCE(
450-
[static int x = __builtin_ctzl(256);]
451-
)],
452-
[pgac_cv__builtin_ctzl=yes],
453-
[pgac_cv__builtin_ctzl=no])])
454-
if test x"$pgac_cv__builtin_ctzl" = xyes ; then
455-
AC_DEFINE(HAVE__BUILTIN_CTZL,1,
456-
[Define to 1 if your compiler understands __builtin_ctzl.])
457-
fi])# PGAC_C_BUILTIN_CTZL
458-
459-
460-
461421
# PGAC_C_BUILTIN_CLZ
462422
# -------------------------
463423
# Check if the C compiler understands __builtin_clz(),
@@ -476,24 +436,6 @@ fi])# PGAC_C_BUILTIN_CLZ
476436

477437

478438

479-
# PGAC_C_BUILTIN_CLZL
480-
# -------------------------
481-
# Check if the C compiler understands __builtin_clzl(),
482-
# and define HAVE__BUILTIN_CLZL if so.
483-
AC_DEFUN([PGAC_C_BUILTIN_CLZL],
484-
[AC_CACHE_CHECK(for__builtin_clzl,pgac_cv__builtin_clzl,
485-
[AC_COMPILE_IFELSE([AC_LANG_SOURCE(
486-
[static int x = __builtin_clzl(256);]
487-
)],
488-
[pgac_cv__builtin_clzl=yes],
489-
[pgac_cv__builtin_clzl=no])])
490-
if test x"$pgac_cv__builtin_clzl" = xyes ; then
491-
AC_DEFINE(HAVE__BUILTIN_CLZL,1,
492-
[Define to 1 if your compiler understands __builtin_clzl.])
493-
fi])# PGAC_C_BUILTIN_CLZL
494-
495-
496-
497439
# PGAC_C_BUILTIN_UNREACHABLE
498440
# --------------------------
499441
# Check if the C compiler understands __builtin_unreachable(),

‎configure

Lines changed: 38 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -14034,89 +14034,57 @@ if test x"$pgac_cv__builtin_bswap64" = xyes ; then
1403414034
$as_echo "#define HAVE__BUILTIN_BSWAP64 1" >>confdefs.h
1403514035

1403614036
fi
14037-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for__builtin_constant_p" >&5
14038-
$as_echo_n "checking for__builtin_constant_p... " >&6; }
14039-
if ${pgac_cv__builtin_constant_p+:} false; then :
14037+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for__builtin_clz" >&5
14038+
$as_echo_n "checking for__builtin_clz... " >&6; }
14039+
if ${pgac_cv__builtin_clz+:} false; then :
1404014040
$as_echo_n "(cached) " >&6
1404114041
else
1404214042
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1404314043
/* end confdefs.h. */
14044-
static int x;
14045-
static int y[__builtin_constant_p(x) ? x : 1];
14046-
static int z[__builtin_constant_p("string literal") ? 1 : x];
14047-
14044+
static int x = __builtin_clz(256);
1404814045

1404914046
_ACEOF
1405014047
if ac_fn_c_try_compile "$LINENO"; then :
14051-
pgac_cv__builtin_constant_p=yes
14048+
pgac_cv__builtin_clz=yes
1405214049
else
14053-
pgac_cv__builtin_constant_p=no
14050+
pgac_cv__builtin_clz=no
1405414051
fi
1405514052
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1405614053
fi
14057-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_constant_p" >&5
14058-
$as_echo "$pgac_cv__builtin_constant_p" >&6; }
14059-
if test x"$pgac_cv__builtin_constant_p" = xyes ; then
14054+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_clz" >&5
14055+
$as_echo "$pgac_cv__builtin_clz" >&6; }
14056+
if test x"$pgac_cv__builtin_clz" = xyes ; then
1406014057

14061-
$as_echo "#defineHAVE__BUILTIN_CONSTANT_P 1" >>confdefs.h
14058+
$as_echo "#defineHAVE__BUILTIN_CLZ 1" >>confdefs.h
1406214059

1406314060
fi
14064-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for__builtin_popcount" >&5
14065-
$as_echo_n "checking for__builtin_popcount... " >&6; }
14066-
if ${pgac_cv_popcount+:} false; then :
14061+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for__builtin_constant_p" >&5
14062+
$as_echo_n "checking for__builtin_constant_p... " >&6; }
14063+
if ${pgac_cv__builtin_constant_p+:} false; then :
1406714064
$as_echo_n "(cached) " >&6
1406814065
else
14069-
pgac_save_CFLAGS=$CFLAGS
14070-
CFLAGS="$pgac_save_CFLAGS -mpopcnt"
14071-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14066+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1407214067
/* end confdefs.h. */
14073-
static int x = __builtin_popcount(255);
14074-
_ACEOF
14075-
if ac_fn_c_try_compile "$LINENO"; then :
14076-
pgac_cv_popcount=yes
14077-
else
14078-
pgac_cv_popcount=no
14079-
fi
14080-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14081-
CFLAGS="$pgac_save_CFLAGS"
14082-
fi
14083-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_popcount" >&5
14084-
$as_echo "$pgac_cv_popcount" >&6; }
14085-
if test x"$pgac_cv_popcount" = x"yes"; then
14086-
CFLAGS_POPCNT="-mpopcnt"
14087-
14088-
$as_echo "#define HAVE__BUILTIN_POPCOUNT 1" >>confdefs.h
14068+
static int x;
14069+
static int y[__builtin_constant_p(x) ? x : 1];
14070+
static int z[__builtin_constant_p("string literal") ? 1 : x];
1408914071

14090-
fi
1409114072

14092-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcountl" >&5
14093-
$as_echo_n "checking for __builtin_popcountl... " >&6; }
14094-
if ${pgac_cv_popcountl+:} false; then :
14095-
$as_echo_n "(cached) " >&6
14096-
else
14097-
pgac_save_CFLAGS=$CFLAGS
14098-
CFLAGS="$pgac_save_CFLAGS -mpopcnt"
14099-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14100-
/* end confdefs.h. */
14101-
static int x = __builtin_popcountl(255);
1410214073
_ACEOF
1410314074
if ac_fn_c_try_compile "$LINENO"; then :
14104-
pgac_cv_popcountl=yes
14075+
pgac_cv__builtin_constant_p=yes
1410514076
else
14106-
pgac_cv_popcountl=no
14077+
pgac_cv__builtin_constant_p=no
1410714078
fi
1410814079
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14109-
CFLAGS="$pgac_save_CFLAGS"
1411014080
fi
14111-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_popcountl" >&5
14112-
$as_echo "$pgac_cv_popcountl" >&6; }
14113-
if test x"$pgac_cv_popcountl" = x"yes"; then
14114-
CFLAGS_POPCNT="-mpopcnt"
14081+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_constant_p" >&5
14082+
$as_echo "$pgac_cv__builtin_constant_p" >&6; }
14083+
if test x"$pgac_cv__builtin_constant_p" = xyes ; then
1411514084

14116-
$as_echo "#defineHAVE__BUILTIN_POPCOUNTL 1" >>confdefs.h
14085+
$as_echo "#defineHAVE__BUILTIN_CONSTANT_P 1" >>confdefs.h
1411714086

1411814087
fi
14119-
1412014088
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ctz" >&5
1412114089
$as_echo_n "checking for __builtin_ctz... " >&6; }
1412214090
if ${pgac_cv__builtin_ctz+:} false; then :
@@ -14141,78 +14109,34 @@ if test x"$pgac_cv__builtin_ctz" = xyes ; then
1414114109
$as_echo "#define HAVE__BUILTIN_CTZ 1" >>confdefs.h
1414214110

1414314111
fi
14144-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_ctzl" >&5
14145-
$as_echo_n "checking for __builtin_ctzl... " >&6; }
14146-
if ${pgac_cv__builtin_ctzl+:} false; then :
14147-
$as_echo_n "(cached) " >&6
14148-
else
14149-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14150-
/* end confdefs.h. */
14151-
static int x = __builtin_ctzl(256);
14152-
14153-
_ACEOF
14154-
if ac_fn_c_try_compile "$LINENO"; then :
14155-
pgac_cv__builtin_ctzl=yes
14156-
else
14157-
pgac_cv__builtin_ctzl=no
14158-
fi
14159-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14160-
fi
14161-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_ctzl" >&5
14162-
$as_echo "$pgac_cv__builtin_ctzl" >&6; }
14163-
if test x"$pgac_cv__builtin_ctzl" = xyes ; then
14164-
14165-
$as_echo "#define HAVE__BUILTIN_CTZL 1" >>confdefs.h
14166-
14167-
fi
14168-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clz" >&5
14169-
$as_echo_n "checking for __builtin_clz... " >&6; }
14170-
if ${pgac_cv__builtin_clz+:} false; then :
14112+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_popcount" >&5
14113+
$as_echo_n "checking for __builtin_popcount... " >&6; }
14114+
if ${pgac_cv_popcount+:} false; then :
1417114115
$as_echo_n "(cached) " >&6
1417214116
else
14173-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14117+
pgac_save_CFLAGS=$CFLAGS
14118+
CFLAGS="$pgac_save_CFLAGS -mpopcnt"
14119+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
1417414120
/* end confdefs.h. */
14175-
static int x = __builtin_clz(256);
14176-
14121+
static int x = __builtin_popcount(255);
1417714122
_ACEOF
1417814123
if ac_fn_c_try_compile "$LINENO"; then :
14179-
pgac_cv__builtin_clz=yes
14124+
pgac_cv_popcount=yes
1418014125
else
14181-
pgac_cv__builtin_clz=no
14126+
pgac_cv_popcount=no
1418214127
fi
1418314128
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14129+
CFLAGS="$pgac_save_CFLAGS"
1418414130
fi
14185-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_clz" >&5
14186-
$as_echo "$pgac_cv__builtin_clz" >&6; }
14187-
if test x"$pgac_cv__builtin_clz" = xyes ; then
14188-
14189-
$as_echo "#define HAVE__BUILTIN_CLZ 1" >>confdefs.h
14131+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_popcount" >&5
14132+
$as_echo "$pgac_cv_popcount" >&6; }
14133+
if test x"$pgac_cv_popcount" = x"yes"; then
14134+
CFLAGS_POPCNT="-mpopcnt"
1419014135

14191-
fi
14192-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_clzl" >&5
14193-
$as_echo_n "checking for __builtin_clzl... " >&6; }
14194-
if ${pgac_cv__builtin_clzl+:} false; then :
14195-
$as_echo_n "(cached) " >&6
14196-
else
14197-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
14198-
/* end confdefs.h. */
14199-
static int x = __builtin_clzl(256);
14136+
$as_echo "#define HAVE__BUILTIN_POPCOUNT 1" >>confdefs.h
1420014137

14201-
_ACEOF
14202-
if ac_fn_c_try_compile "$LINENO"; then :
14203-
pgac_cv__builtin_clzl=yes
14204-
else
14205-
pgac_cv__builtin_clzl=no
1420614138
fi
14207-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
14208-
fi
14209-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_clzl" >&5
14210-
$as_echo "$pgac_cv__builtin_clzl" >&6; }
14211-
if test x"$pgac_cv__builtin_clzl" = xyes ; then
14212-
14213-
$as_echo "#define HAVE__BUILTIN_CLZL 1" >>confdefs.h
1421414139

14215-
fi
1421614140
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_unreachable" >&5
1421714141
$as_echo_n "checking for __builtin_unreachable... " >&6; }
1421814142
if ${pgac_cv__builtin_unreachable+:} false; then :

‎configure.in

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,13 +1488,10 @@ PGAC_C_TYPES_COMPATIBLE
14881488
PGAC_C_BUILTIN_BSWAP16
14891489
PGAC_C_BUILTIN_BSWAP32
14901490
PGAC_C_BUILTIN_BSWAP64
1491+
PGAC_C_BUILTIN_CLZ
14911492
PGAC_C_BUILTIN_CONSTANT_P
1492-
PGAC_C_BUILTIN_POPCOUNT
1493-
PGAC_C_BUILTIN_POPCOUNTL
14941493
PGAC_C_BUILTIN_CTZ
1495-
PGAC_C_BUILTIN_CTZL
1496-
PGAC_C_BUILTIN_CLZ
1497-
PGAC_C_BUILTIN_CLZL
1494+
PGAC_C_BUILTIN_POPCOUNT
14981495
PGAC_C_BUILTIN_UNREACHABLE
14991496
PGAC_C_COMPUTED_GOTO
15001497
PGAC_STRUCT_TIMEZONE

‎src/include/pg_config.h.in

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -748,30 +748,21 @@
748748
/* Define to 1 if your compiler understands __builtin_bswap64. */
749749
#undef HAVE__BUILTIN_BSWAP64
750750

751+
/* Define to 1 if your compiler understands __builtin_clz. */
752+
#undef HAVE__BUILTIN_CLZ
753+
751754
/* Define to 1 if your compiler understands __builtin_constant_p. */
752755
#undef HAVE__BUILTIN_CONSTANT_P
753756

757+
/* Define to 1 if your compiler understands __builtin_ctz. */
758+
#undef HAVE__BUILTIN_CTZ
759+
754760
/* Define to 1 if your compiler understands __builtin_$op_overflow. */
755761
#undef HAVE__BUILTIN_OP_OVERFLOW
756762

757763
/* Define to 1 if your compiler understands __builtin_popcount. */
758764
#undef HAVE__BUILTIN_POPCOUNT
759765

760-
/* Define to 1 if your compiler understands __builtin_popcountl. */
761-
#undef HAVE__BUILTIN_POPCOUNTL
762-
763-
/* Define to 1 if your compiler understands __builtin_ctz. */
764-
#undef HAVE__BUILTIN_CTZ
765-
766-
/* Define to 1 if your compiler understands __builtin_ctzl. */
767-
#undef HAVE__BUILTIN_CTZL
768-
769-
/* Define to 1 if your compiler understands __builtin_clz. */
770-
#undef HAVE__BUILTIN_CLZ
771-
772-
/* Define to 1 if your compiler understands __builtin_clzl. */
773-
#undef HAVE__BUILTIN_CLZL
774-
775766
/* Define to 1 if your compiler understands __builtin_types_compatible_p. */
776767
#undef HAVE__BUILTIN_TYPES_COMPATIBLE_P
777768

‎src/include/pg_config.h.win32

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -587,30 +587,21 @@
587587
/* Define to 1 if your compiler understands __builtin_bswap64. */
588588
/* #undef HAVE__BUILTIN_BSWAP64 */
589589

590+
/* Define to 1 if your compiler understands __builtin_clz. */
591+
/* #undef HAVE__BUILTIN_CLZ */
592+
590593
/* Define to 1 if your compiler understands __builtin_constant_p. */
591594
/* #undef HAVE__BUILTIN_CONSTANT_P */
592595

596+
/* Define to 1 if your compiler understands __builtin_ctz. */
597+
/* #undef HAVE__BUILTIN_CTZ */
598+
593599
/* Define to 1 if your compiler understands __builtin_$op_overflow. */
594600
/* #undef HAVE__BUILTIN_OP_OVERFLOW */
595601

596602
/* Define to 1 if your compiler understands __builtin_popcount. */
597603
/* #undef HAVE__BUILTIN_POPCOUNT */
598604

599-
/* Define to 1 if your compiler understands __builtin_popcountl. */
600-
/* #undef HAVE__BUILTIN_POPCOUNTL */
601-
602-
/* Define to 1 if your compiler understands __builtin_ctz. */
603-
/* #undef HAVE__BUILTIN_CTZ */
604-
605-
/* Define to 1 if your compiler understands __builtin_ctzl. */
606-
/* #undef HAVE__BUILTIN_CTZL */
607-
608-
/* Define to 1 if your compiler understands __builtin_clz. */
609-
/* #undef HAVE__BUILTIN_CLZ */
610-
611-
/* Define to 1 if your compiler understands __builtin_clzl. */
612-
/* #undef HAVE__BUILTIN_CLZL */
613-
614605
/* Define to 1 if your compiler understands __builtin_types_compatible_p. */
615606
/* #undef HAVE__BUILTIN_TYPES_COMPATIBLE_P */
616607

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp