public inbox for [email protected]
help / color / mirror / Atom feed[PATCH v30 6/6] Doc: Add Collation Versions section.
10+ messages / 4 participants
[nested] [flat]
* [PATCH v30 6/6] Doc: Add Collation Versions section.
@ 2020-03-11 02:01 Thomas Munro <[email protected]>
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Munro @ 2020-03-11 02:01 UTC (permalink / raw)
Supply a brief introduction to collation version concepts.
Author: Thomas Munro <[email protected]>
Reviewed-by: Julien Rouhaud <[email protected]>
Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
---
doc/src/sgml/charset.sgml | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml
index 2745b44417..9008d094bb 100644
--- a/doc/src/sgml/charset.sgml
+++ b/doc/src/sgml/charset.sgml
@@ -948,6 +948,41 @@ CREATE COLLATION ignore_accents (provider = icu, locale = 'und-u-ks-level1-kc-tr
</tip>
</sect3>
</sect2>
+
+ <sect2 id="collation-versions">
+ <title>Collation Versions</title>
+
+ <para>
+ The ordering defined by a collation is not necessarily fixed over time.
+ If a collation changes for any reason, persistent data structures such as
+ b-trees that depend on a stable ordering of text might be corrupted.
+ <productname>PostgreSQL</productname> defends against this by recording
+ the current version of each referenced collation for any index that
+ depends on it in the
+ <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>
+ catalog, if the collation provider makes it available. If the provider
+ later begins to report a different version, a warning will be issued
+ when the index is accessed, until either the <xref linkend="sql-reindex"/>
+ or the <xref linkend="sql-alterindex"/> command is used to update the
+ version.
+ </para>
+ <para>
+ Version information is available for collations from the
+ <literal>icu</literal> provider on all operating systems. For the
+ <literal>libc</literal> provider, versions are currently only available
+ on systems using the GNU C library (most Linux systems).
+ </para>
+
+ <note>
+ <para>
+ When using the GNU C library for collations, the C library's version
+ is used as a proxy for the collation version. Many Linux distributions
+ change collation definitions only when upgrading the C library, but this
+ approach is imperfect as maintainers are free to back-port newer
+ collation definitions to older C library releases.
+ </para>
+ </note>
+ </sect2>
</sect1>
<sect1 id="multibyte">
--
2.20.1
--vy36zrg552ym33jw--
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
@ 2024-04-18 00:31 Thomas Munro <[email protected]>
2024-04-18 06:07 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
2024-04-18 08:46 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
2024-04-19 08:34 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
0 siblings, 3 replies; 10+ messages in thread
From: Thomas Munro @ 2024-04-18 00:31 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Sat, Mar 23, 2024 at 3:23 PM Tom Lane <[email protected]> wrote:
> Thomas Munro <[email protected]> writes:
> > . o O ( int64_t, PRIdi64, etc were standardised a quarter of a century ago )
>
> Yeah. Now that we require C99 it's probably reasonable to assume
> that those things exist. I wouldn't be in favor of ripping out our
> existing notations like UINT64CONST, because the code churn would be
> substantial and the gain minimal. But we could imagine reimplementing
> that stuff atop <stdint.h> and then getting rid of the configure-time
> probes.
I played around with this a bit, but am not quite there yet.
printf() is a little tricky. The standard wants us to use
<inttypes.h>'s PRId64 etc, but that might confuse our snprintf.c (in
theory, probably not in practice). "ll" should have the right size on
all systems, but gets warnings from the printf format string checker
on systems where "l" is the right type. So I think we still need to
probe for INT64_MODIFIER at configure-time. Here's one way, but I can
see it's not working on Clang/Linux... perhaps instead of that dubious
incantation I should try compiling some actual printfs and check for
warnings/errors.
I think INT64CONST should just point to standard INT64_C().
For limits, why do we have this:
- * stdint.h limits aren't guaranteed to have compatible types with our fixed
- * width types. So just define our own.
? I mean, how could they not have compatible types?
I noticed that configure.ac checks if int64 (no "_t") might be defined
already by system header pollution, but meson.build doesn't. That's
an inconsistency that should be fixed, but which way? Hmm, commit
15abc7788e6 said that was done for BeOS, which we de-supported. So
maybe we should get rid of that?
Attachments:
[application/octet-stream] 0001-Use-int64_t-and-friends-from-stdint.h.patch (36.5K, ../../CA+hUKG+ZwX-reVMHak3yo-63rrh9AJwEVGW4rCbsoLeSKO54Pg@mail.gmail.com/2-0001-Use-int64_t-and-friends-from-stdint.h.patch)
download | inline diff:
From af2d279f76d05f1323e0f6e67bf3cb4fd4f68d98 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Thu, 18 Apr 2024 07:53:10 +1200
Subject: [PATCH 1/2] Use int64_t and friends from <stdint.h>.
Remove most of the configure probes for 64 bit integers. Map our names
to the standard C99 names for types like int64_t, limits like INT64_MAX,
constant constructors like INT64_C().
We don't use printf format strings like PRId64 from <inttypes.h>,
though, because in theory they might not be understood by our
snprintf.c. That means we still need a configure probe to find out if
it's "long" or not, so we can choose between "l" and "ll", when
implementing our own PRId64-like macros while keeping the system printf
happy too.
We can get rid of pg_config_ext.h.
XXX WIP
XXX The way of probing INT64_MODIFIER is not good enough yet
---
configure | 261 +++---------------
configure.ac | 57 +---
meson.build | 52 ++--
src/Makefile.global.in | 6 -
src/include/.gitignore | 2 -
src/include/Makefile | 8 +-
src/include/c.h | 83 +++---
src/include/meson.build | 10 -
src/include/pg_config.h.in | 17 +-
src/include/pg_config_ext.h.in | 7 -
src/include/pg_config_ext.h.meson | 7 -
src/include/port/pg_bitutils.h | 18 +-
src/include/postgres_ext.h | 7 +-
src/interfaces/ecpg/ecpglib/typename.c | 5 +-
src/interfaces/ecpg/include/ecpg_config.h.in | 12 -
src/interfaces/ecpg/include/meson.build | 3 -
.../ecpg/include/pgtypes_interval.h | 13 +-
src/interfaces/ecpg/include/sqltypes.h | 2 +-
.../test/expected/compat_informix-sqlda.c | 2 +-
src/port/pg_bitutils.c | 7 +-
src/port/snprintf.c | 14 +-
21 files changed, 153 insertions(+), 440 deletions(-)
delete mode 100644 src/include/pg_config_ext.h.in
delete mode 100644 src/include/pg_config_ext.h.meson
diff --git a/configure b/configure
index cfbd2a096f..e084fd2210 100755
--- a/configure
+++ b/configure
@@ -16439,197 +16439,6 @@ fi
# Run tests below here
# --------------------
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long int is 64 bits" >&5
-$as_echo_n "checking whether long int is 64 bits... " >&6; }
-if ${pgac_cv_type_long_int_64+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- # If cross-compiling, check the size reported by the compiler and
-# trust that the arithmetic works.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof(long int) == 8)];
-test_array [0] = 0;
-return test_array [0];
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_type_long_int_64=yes
-else
- pgac_cv_type_long_int_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-typedef long int ac_int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-ac_int64 a = 20000001;
-ac_int64 b = 40000005;
-
-int does_int64_work()
-{
- ac_int64 c,d;
-
- if (sizeof(ac_int64) != 8)
- return 0; /* definitely not the right size */
-
- /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
- c = a * b;
- d = (c + b) / b;
- if (d != a+1)
- return 0;
- return 1;
-}
-
-int
-main() {
- return (! does_int64_work());
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- pgac_cv_type_long_int_64=yes
-else
- pgac_cv_type_long_int_64=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_long_int_64" >&5
-$as_echo "$pgac_cv_type_long_int_64" >&6; }
-
-HAVE_LONG_INT_64=$pgac_cv_type_long_int_64
-if test x"$pgac_cv_type_long_int_64" = xyes ; then
-
-$as_echo "#define HAVE_LONG_INT_64 1" >>confdefs.h
-
-fi
-
-
-if test x"$HAVE_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long int"
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long long int is 64 bits" >&5
-$as_echo_n "checking whether long long int is 64 bits... " >&6; }
-if ${pgac_cv_type_long_long_int_64+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- # If cross-compiling, check the size reported by the compiler and
-# trust that the arithmetic works.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof(long long int) == 8)];
-test_array [0] = 0;
-return test_array [0];
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_type_long_long_int_64=yes
-else
- pgac_cv_type_long_long_int_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-typedef long long int ac_int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-ac_int64 a = 20000001;
-ac_int64 b = 40000005;
-
-int does_int64_work()
-{
- ac_int64 c,d;
-
- if (sizeof(ac_int64) != 8)
- return 0; /* definitely not the right size */
-
- /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
- c = a * b;
- d = (c + b) / b;
- if (d != a+1)
- return 0;
- return 1;
-}
-
-int
-main() {
- return (! does_int64_work());
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- pgac_cv_type_long_long_int_64=yes
-else
- pgac_cv_type_long_long_int_64=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_long_long_int_64" >&5
-$as_echo "$pgac_cv_type_long_long_int_64" >&6; }
-
-HAVE_LONG_LONG_INT_64=$pgac_cv_type_long_long_int_64
-if test x"$pgac_cv_type_long_long_int_64" = xyes ; then
-
-$as_echo "#define HAVE_LONG_LONG_INT_64 1" >>confdefs.h
-
-fi
-
- if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long long int"
- else
- as_fn_error $? "Cannot find a working 64-bit integer type." "$LINENO" 5
- fi
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define PG_INT64_TYPE $pg_int64_type
-_ACEOF
-
-
-# Select the printf length modifier that goes with that, too.
-if test x"$pg_int64_type" = x"long long int" ; then
- INT64_MODIFIER='"ll"'
-else
- INT64_MODIFIER='"l"'
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define INT64_MODIFIER $INT64_MODIFIER
-_ACEOF
-
-
# has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_mul_overflow" >&5
@@ -16877,43 +16686,41 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- # The cast to long int works around a bug in the HP C Compiler,
+# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of long long int" >&5
-$as_echo_n "checking alignment of long long int... " >&6; }
-if ${ac_cv_alignof_long_long_int+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of int64_t" >&5
+$as_echo_n "checking alignment of int64_t... " >&6; }
+if ${ac_cv_alignof_int64_t+:} false; then :
$as_echo_n "(cached) " >&6
else
- if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_long_long_int" "$ac_includes_default
+ if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_int64_t" "$ac_includes_default
#ifndef offsetof
# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
#endif
-typedef struct { char x; long long int y; } ac__type_alignof_;"; then :
+typedef struct { char x; int64_t y; } ac__type_alignof_;"; then :
else
- if test "$ac_cv_type_long_long_int" = yes; then
+ if test "$ac_cv_type_int64_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute alignment of long long int
+as_fn_error 77 "cannot compute alignment of int64_t
See \`config.log' for more details" "$LINENO" 5; }
else
- ac_cv_alignof_long_long_int=0
+ ac_cv_alignof_int64_t=0
fi
fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_long_long_int" >&5
-$as_echo "$ac_cv_alignof_long_long_int" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_int64_t" >&5
+$as_echo "$ac_cv_alignof_int64_t" >&6; }
cat >>confdefs.h <<_ACEOF
-#define ALIGNOF_LONG_LONG_INT $ac_cv_alignof_long_long_int
+#define ALIGNOF_INT64_T $ac_cv_alignof_int64_t
_ACEOF
-fi
# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of double" >&5
@@ -16971,8 +16778,8 @@ MAX_ALIGNOF=$ac_cv_alignof_double
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long long int' is greater than the alignment of 'double'" "$LINENO" 5
+if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
+ as_fn_error $? "alignment of 'int64_t' is greater than the alignment of 'double'" "$LINENO" 5
fi
cat >>confdefs.h <<_ACEOF
@@ -17025,6 +16832,38 @@ _ACEOF
fi
+# Check how printf should display if int64_t. "ll" has the right size on all
+# systems, but "l" might be required on some systems to avoid GCC's print type
+# mismatch warnings.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+#include <stdint.h>
+int main(int arg, char **argv)
+{
+ _Static_assert(__builtin_types_compatible_p(long, int64_t));
+}
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ int64_modifier='"l"'
+else
+ int64_modifier='"ll"'
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+cat >>confdefs.h <<_ACEOF
+#define INT64_MODIFIER $int64_modifier
+_ACEOF
+
+
# Some compilers offer a 128-bit integer scalar type.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __int128" >&5
$as_echo_n "checking for __int128... " >&6; }
@@ -19272,9 +19111,6 @@ fi
ac_config_headers="$ac_config_headers src/include/pg_config.h"
-ac_config_headers="$ac_config_headers src/include/pg_config_ext.h"
-
-
ac_config_headers="$ac_config_headers src/interfaces/ecpg/include/ecpg_config.h"
@@ -19989,7 +19825,6 @@ do
"src/Makefile.port") CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;
"check_win32_symlinks") CONFIG_COMMANDS="$CONFIG_COMMANDS check_win32_symlinks" ;;
"src/include/pg_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config.h" ;;
- "src/include/pg_config_ext.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config_ext.h" ;;
"src/interfaces/ecpg/include/ecpg_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/interfaces/ecpg/include/ecpg_config.h" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -20597,10 +20432,6 @@ $as_echo "$as_me: WARNING: *** link for $FILE -- please fix by hand" >&2;}
"src/include/pg_config.h":H)
# Update timestamp for pg_config.h (see Makefile.global)
echo >src/include/stamp-h
- ;;
- "src/include/pg_config_ext.h":H)
-# Update timestamp for pg_config_ext.h (see Makefile.global)
-echo >src/include/stamp-ext-h
;;
"src/interfaces/ecpg/include/ecpg_config.h":H) echo >src/interfaces/ecpg/include/stamp-h ;;
diff --git a/configure.ac b/configure.ac
index 67e738d92b..e8cac06a72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1945,37 +1945,6 @@ for the exact reason.]])],
# Run tests below here
# --------------------
-dnl Check to see if we have a working 64-bit integer type.
-dnl Since Postgres 8.4, we no longer support compilers without a working
-dnl 64-bit type; but we have to determine whether that type is called
-dnl "long int" or "long long int".
-
-PGAC_TYPE_64BIT_INT([long int])
-
-if test x"$HAVE_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long int"
-else
- PGAC_TYPE_64BIT_INT([long long int])
- if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long long int"
- else
- AC_MSG_ERROR([Cannot find a working 64-bit integer type.])
- fi
-fi
-
-AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
- [Define to the name of a signed 64-bit integer type.])
-
-# Select the printf length modifier that goes with that, too.
-if test x"$pg_int64_type" = x"long long int" ; then
- INT64_MODIFIER='"ll"'
-else
- INT64_MODIFIER='"l"'
-fi
-
-AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
- [Define to the appropriate printf length modifier for 64-bit ints.])
-
# has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE.
PGAC_C_BUILTIN_OP_OVERFLOW
@@ -1990,9 +1959,7 @@ AC_CHECK_SIZEOF([long])
AC_CHECK_ALIGNOF(short)
AC_CHECK_ALIGNOF(int)
AC_CHECK_ALIGNOF(long)
-if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- AC_CHECK_ALIGNOF(long long int)
-fi
+AC_CHECK_ALIGNOF(int64_t)
AC_CHECK_ALIGNOF(double)
# Compute maximum alignment of any basic type.
@@ -2016,8 +1983,8 @@ MAX_ALIGNOF=$ac_cv_alignof_double
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double'])
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- AC_MSG_ERROR([alignment of 'long long int' is greater than the alignment of 'double'])
+if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
+ AC_MSG_ERROR([alignment of 'int64_t' is greater than the alignment of 'double'])
fi
AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
@@ -2027,6 +1994,18 @@ AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignme
AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
[#include <stdio.h>])
+# Check how printf should display if int64_t. "ll" has the right size on all
+# systems, but "l" might be required on some systems to avoid GCC's print type
+# mismatch warnings.
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
+#include <stdint.h>
+int main(int arg, char **argv)
+{
+ _Static_assert(__builtin_types_compatible_p(long, int64_t));
+}
+])], [int64_modifier='"l"'], [int64_modifier='"ll"'])
+AC_DEFINE_UNQUOTED(INT64_MODIFIER, $int64_modifier, [Define to the appropriate printf length modifier for int64_t.])
+
# Some compilers offer a 128-bit integer scalar type.
PGAC_TYPE_128BIT_INT
@@ -2520,12 +2499,6 @@ AC_CONFIG_HEADERS([src/include/pg_config.h],
echo >src/include/stamp-h
])
-AC_CONFIG_HEADERS([src/include/pg_config_ext.h],
-[
-# Update timestamp for pg_config_ext.h (see Makefile.global)
-echo >src/include/stamp-ext-h
-])
-
AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
[echo >src/interfaces/ecpg/include/stamp-h])
diff --git a/meson.build b/meson.build
index 43fad5323c..9b01cef209 100644
--- a/meson.build
+++ b/meson.build
@@ -1488,18 +1488,6 @@ endif
sizeof_long = cc.sizeof('long', args: test_c_args)
cdata.set('SIZEOF_LONG', sizeof_long)
-if sizeof_long == 8
- cdata.set('HAVE_LONG_INT_64', 1)
- pg_int64_type = 'long int'
- cdata.set_quoted('INT64_MODIFIER', 'l')
-elif sizeof_long == 4 and cc.sizeof('long long', args: test_c_args) == 8
- cdata.set('HAVE_LONG_LONG_INT_64', 1)
- pg_int64_type = 'long long int'
- cdata.set_quoted('INT64_MODIFIER', 'll')
-else
- error('do not know how to get a 64bit int')
-endif
-cdata.set('PG_INT64_TYPE', pg_int64_type)
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
@@ -1529,11 +1517,28 @@ endforeach
# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8
# would be too much of a penalty for disk and memory space.
alignof_double = cdata.get('ALIGNOF_DOUBLE')
-if cc.alignment(pg_int64_type, args: test_c_args) > alignof_double
- error('alignment of int64 is greater than the alignment of double')
+if cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
+ error('alignment of int64_t is greater than the alignment of double')
endif
cdata.set('MAXIMUM_ALIGNOF', alignof_double)
+# Check how printf should display if int64_t. "ll" has the right size on all
+# systems, but "l" might be required on some systems to avoid GCC's print type
+# mismatch warnings.
+if cc.compiles('''
+ #include <stdint.h>
+ int main(int arg, char **argv)
+ {
+ _Static_assert(__builtin_types_compatible_p(long, int64_t));
+ }
+ ''',
+ args: test_c_args)
+ int64_modifier = 'l'
+else
+ int64_modifier = 'll'
+endif
+cdata.set_quoted('INT64_MODIFIER', int64_modifier)
+
cdata.set('SIZEOF_VOID_P', cc.sizeof('void *', args: test_c_args))
cdata.set('SIZEOF_SIZE_T', cc.sizeof('size_t', args: test_c_args))
@@ -1742,17 +1747,17 @@ endif
# compile, and store the results in global variables so the compiler doesn't
# optimize away the call.
if cc.links('''
- INT64 a = 1;
- INT64 b = 1;
- INT64 result;
+ #include <stdint.h>
+ int64_t a = 1;
+ int64_t b = 1;
+ int64_t result;
int main(void)
{
return __builtin_mul_overflow(a, b, &result);
}''',
name: '__builtin_mul_overflow',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))],
- )
+ args: test_c_args)
cdata.set('HAVE__BUILTIN_OP_OVERFLOW', 1)
endif
@@ -2013,7 +2018,7 @@ int main(void)
cdata.set(check['name'],
cc.links(test,
name: check['desc'],
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))]) ? 1 : false
+ args: test_c_args) ? 1 : false
)
endforeach
@@ -2057,11 +2062,12 @@ if host_cpu == 'x86_64'
prog = '''
#include <immintrin.h>
+#include <stdint.h>
int main(void)
{
const char buf[sizeof(__m512i)];
- INT64 popcnt = 0;
+ int64_t popcnt = 0;
__m512i accum = _mm512_setzero_si512();
const __m512i val = _mm512_maskz_loadu_epi8((__mmask64) 0xf0f0f0f0f0f0f0f0, (const __m512i *) buf);
const __m512i cnt = _mm512_popcnt_epi64(val);
@@ -2073,10 +2079,10 @@ int main(void)
'''
if cc.links(prog, name: 'AVX-512 popcount without -mavx512vpopcntdq -mavx512bw',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))])
+ args: test_c_args)
cdata.set('USE_AVX512_POPCNT_WITH_RUNTIME_CHECK', 1)
elif cc.links(prog, name: 'AVX-512 popcount with -mavx512vpopcntdq -mavx512bw',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))] + ['-mavx512vpopcntdq'] + ['-mavx512bw'])
+ args: test_c_args + ['-mavx512vpopcntdq'] + ['-mavx512bw'])
cdata.set('USE_AVX512_POPCNT_WITH_RUNTIME_CHECK', 1)
cflags_popcnt += ['-mavx512vpopcntdq'] + ['-mavx512bw']
endif
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 36d880d225..1928fc2f2c 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -833,12 +833,6 @@ $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/include/pg_config.h
-# Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
-$(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
-
-$(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
- cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
-
# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
# logic as above.
$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
diff --git a/src/include/.gitignore b/src/include/.gitignore
index 51819fb4dd..6e99e82fe0 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -1,5 +1,3 @@
/stamp-h
-/stamp-ext-h
/pg_config.h
-/pg_config_ext.h
/pg_config_os.h
diff --git a/src/include/Makefile b/src/include/Makefile
index b8b576a4de..26332ff9cb 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -13,7 +13,7 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global
-all: pg_config.h pg_config_ext.h pg_config_os.h
+all: pg_config.h pg_config_os.h
# Subdirectories containing installable headers
@@ -32,7 +32,6 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/postgres_ext.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq/libpq-fs.h '$(DESTDIR)$(includedir)/libpq'
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
- $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/pg_config_manual.h '$(DESTDIR)$(includedir)'
# These headers are needed by the not-so-public headers of the interfaces.
@@ -43,7 +42,6 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/libpq/protocol.h '$(DESTDIR)$(includedir_internal)/libpq'
# These headers are needed for server-side development
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
- $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir_server)'
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
$(INSTALL_DATA) nodes/nodetags.h '$(DESTDIR)$(includedir_server)/nodes'
$(INSTALL_DATA) utils/errcodes.h '$(DESTDIR)$(includedir_server)/utils'
@@ -66,7 +64,7 @@ installdirs:
uninstall:
- rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_ext.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
+ rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
@@ -80,4 +78,4 @@ clean:
$(MAKE) -C catalog clean
distclean: clean
- rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
+ rm -f pg_config.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/c.h b/src/include/c.h
index dc1841346c..b7f97d412c 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -48,9 +48,6 @@
#include "postgres_ext.h"
-/* Must undef pg_config_ext.h symbols before including pg_config.h */
-#undef PG_INT64_TYPE
-
#include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */
#include "pg_config_os.h" /* must be before any system header files */
@@ -489,10 +486,13 @@ typedef char *Pointer;
* frontend/backend protocol.
*/
#ifndef HAVE_INT8
-typedef signed char int8; /* == 8 bits */
-typedef signed short int16; /* == 16 bits */
-typedef signed int int32; /* == 32 bits */
+typedef int8_t int8; /* == 8 bits */
+typedef int16_t int16; /* == 16 bits */
+typedef int32_t int32; /* == 32 bits */
#endif /* not HAVE_INT8 */
+#ifndef HAVE_INT64
+typedef int64_t int64; /* == 64 bits */
+#endif /* not HAVE_INT64 */
/*
* uintN
@@ -501,10 +501,13 @@ typedef signed int int32; /* == 32 bits */
* frontend/backend protocol.
*/
#ifndef HAVE_UINT8
-typedef unsigned char uint8; /* == 8 bits */
-typedef unsigned short uint16; /* == 16 bits */
-typedef unsigned int uint32; /* == 32 bits */
+typedef uint8_t uint8; /* == 8 bits */
+typedef uint16_t uint16; /* == 16 bits */
+typedef uint32_t uint32; /* == 32 bits */
#endif /* not HAVE_UINT8 */
+#ifndef HAVE_UINT64
+typedef uint64_t uint64; /* == 64 bits */
+#endif /* not HAVE_UINT64 */
/*
* bitsN
@@ -517,34 +520,13 @@ typedef uint32 bits32; /* >= 32 bits */
/*
* 64-bit integers
*/
-#ifdef HAVE_LONG_INT_64
-/* Plain "long int" fits, use it */
-
-#ifndef HAVE_INT64
-typedef long int int64;
-#endif
-#ifndef HAVE_UINT64
-typedef unsigned long int uint64;
-#endif
-#define INT64CONST(x) (x##L)
-#define UINT64CONST(x) (x##UL)
-#elif defined(HAVE_LONG_LONG_INT_64)
-/* We have working support for "long long int", use that */
+#define INT64CONST(x) INT64_C(x)
+#define UINT64CONST(x) UINT64_C(x)
-#ifndef HAVE_INT64
-typedef long long int int64;
-#endif
-#ifndef HAVE_UINT64
-typedef unsigned long long int uint64;
-#endif
-#define INT64CONST(x) (x##LL)
-#define UINT64CONST(x) (x##ULL)
-#else
-/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
-#error must have a working 64-bit integer datatype
-#endif
-
-/* snprintf format strings to use for 64-bit integers */
+/*
+ * snprintf format strings to use for 64-bit integers, instead of PRId64 etc
+ * which might confuse our snprintf.c.
+ */
#define INT64_FORMAT "%" INT64_MODIFIER "d"
#define UINT64_FORMAT "%" INT64_MODIFIER "u"
@@ -575,22 +557,19 @@ typedef unsigned PG_INT128_TYPE uint128
#endif
#endif
-/*
- * stdint.h limits aren't guaranteed to have compatible types with our fixed
- * width types. So just define our own.
- */
-#define PG_INT8_MIN (-0x7F-1)
-#define PG_INT8_MAX (0x7F)
-#define PG_UINT8_MAX (0xFF)
-#define PG_INT16_MIN (-0x7FFF-1)
-#define PG_INT16_MAX (0x7FFF)
-#define PG_UINT16_MAX (0xFFFF)
-#define PG_INT32_MIN (-0x7FFFFFFF-1)
-#define PG_INT32_MAX (0x7FFFFFFF)
-#define PG_UINT32_MAX (0xFFFFFFFFU)
-#define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
-#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
-#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
+/* Historical names for limits in stdint.h. */
+#define PG_INT8_MIN INT8_MIN
+#define PG_INT8_MAX INT8_MAX
+#define PG_UINT8_MAX UINT8_MAX
+#define PG_INT16_MIN INT16_MIN
+#define PG_INT16_MAX INT16_MAX
+#define PG_UINT16_MAX UINT16_MAX
+#define PG_INT32_MIN INT32_MIN
+#define PG_INT32_MAX INT32_MAX
+#define PG_UINT32_MAX UINT32_MAX
+#define PG_INT64_MIN INT64_MIN
+#define PG_INT64_MAX INT64_MAX
+#define PG_UINT64_MAX UINT64_MAX
/*
* We now always use int64 timestamps, but keep this symbol defined for the
diff --git a/src/include/meson.build b/src/include/meson.build
index a28f115d86..6b9116341f 100644
--- a/src/include/meson.build
+++ b/src/include/meson.build
@@ -1,14 +1,5 @@
# Copyright (c) 2022-2024, PostgreSQL Global Development Group
-pg_config_ext = configure_file(
- input: 'pg_config_ext.h.meson',
- output: 'pg_config_ext.h',
- configuration: cdata,
- install: true,
- install_dir: dir_include,
-)
-configure_files += pg_config_ext
-
pg_config_os = configure_file(
output: 'pg_config_os.h',
input: files('port/@[email protected]'.format(portname)),
@@ -116,7 +107,6 @@ install_headers(
'postgres_fe.h',
'varatt.h',
'windowapi.h',
- pg_config_ext,
pg_config_os,
pg_config,
install_dir: dir_include_server,
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f8d3e3b6b8..2141010487 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -9,12 +9,12 @@
/* The normal alignment of `int', in bytes. */
#undef ALIGNOF_INT
+/* The normal alignment of `int64_t', in bytes. */
+#undef ALIGNOF_INT64_T
+
/* The normal alignment of `long', in bytes. */
#undef ALIGNOF_LONG
-/* The normal alignment of `long long int', in bytes. */
-#undef ALIGNOF_LONG_LONG_INT
-
/* The normal alignment of `PG_INT128_TYPE', in bytes. */
#undef ALIGNOF_PG_INT128_TYPE
@@ -282,12 +282,6 @@
/* Define to 1 if you have the `zstd' library (-lzstd). */
#undef HAVE_LIBZSTD
-/* Define to 1 if `long int' works and is 64 bits. */
-#undef HAVE_LONG_INT_64
-
-/* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
-
/* Define to 1 if you have the <mbarrier.h> header file. */
#undef HAVE_MBARRIER_H
@@ -570,7 +564,7 @@
/* Define to 1 if your compiler understands _Static_assert. */
#undef HAVE__STATIC_ASSERT
-/* Define to the appropriate printf length modifier for 64-bit ints. */
+/* Define to the appropriate printf length modifier for int64_t. */
#undef INT64_MODIFIER
/* Define to 1 if `locale_t' requires <xlocale.h>. */
@@ -607,9 +601,6 @@
/* Define to the name of a signed 128-bit integer type. */
#undef PG_INT128_TYPE
-/* Define to the name of a signed 64-bit integer type. */
-#undef PG_INT64_TYPE
-
/* Define to the name of the default PostgreSQL service principal in Kerberos
(GSSAPI). (--with-krb-srvnam=NAME) */
#undef PG_KRB_SRVNAM
diff --git a/src/include/pg_config_ext.h.in b/src/include/pg_config_ext.h.in
deleted file mode 100644
index 8acadbdafd..0000000000
--- a/src/include/pg_config_ext.h.in
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * src/include/pg_config_ext.h.in. This is generated manually, not by
- * autoheader, since we want to limit which symbols get defined here.
- */
-
-/* Define to the name of a signed 64-bit integer type. */
-#undef PG_INT64_TYPE
diff --git a/src/include/pg_config_ext.h.meson b/src/include/pg_config_ext.h.meson
deleted file mode 100644
index 57cdfca0cf..0000000000
--- a/src/include/pg_config_ext.h.meson
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * src/include/pg_config_ext.h.in. This is generated manually, not by
- * autoheader, since we want to limit which symbols get defined here.
- */
-
-/* Define to the name of a signed 64-bit integer type. */
-#mesondefine PG_INT64_TYPE
diff --git a/src/include/port/pg_bitutils.h b/src/include/port/pg_bitutils.h
index 4d88478c9c..1c09bf0ff2 100644
--- a/src/include/port/pg_bitutils.h
+++ b/src/include/port/pg_bitutils.h
@@ -74,13 +74,12 @@ pg_leftmost_one_pos64(uint64 word)
#ifdef HAVE__BUILTIN_CLZ
Assert(word != 0);
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return 63 - __builtin_clzl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return 63 - __builtin_clzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return 63 - __builtin_clzll(word);
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
@@ -147,13 +146,12 @@ pg_rightmost_one_pos64(uint64 word)
#ifdef HAVE__BUILTIN_CTZ
Assert(word != 0);
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return __builtin_ctzl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return __builtin_ctzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return __builtin_ctzll(word);
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h
index 240ad4e93b..034056e7d9 100644
--- a/src/include/postgres_ext.h
+++ b/src/include/postgres_ext.h
@@ -23,7 +23,7 @@
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
-#include "pg_config_ext.h"
+#include <stdint.h>
/*
* Object ID is a fundamental type in Postgres.
@@ -36,15 +36,14 @@ typedef unsigned int Oid;
#define InvalidOid ((Oid) 0)
#endif
-#define OID_MAX UINT_MAX
-/* you will need to include <limits.h> to use the above #define */
+#define OID_MAX UINT32_MAX
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
/* the above needs <stdlib.h> */
/* Define a signed 64-bit integer type for use in client API declarations. */
-typedef PG_INT64_TYPE pg_int64;
+typedef int64_t pg_int64;
/*
* Identifiers of error message fields. Kept here to keep common
diff --git a/src/interfaces/ecpg/ecpglib/typename.c b/src/interfaces/ecpg/ecpglib/typename.c
index 1d482c4fa6..1ab2cda848 100644
--- a/src/interfaces/ecpg/ecpglib/typename.c
+++ b/src/interfaces/ecpg/ecpglib/typename.c
@@ -131,10 +131,9 @@ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
case INTERVALOID:
return ECPGt_interval;
case INT8OID:
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
return ECPGt_long_long;
-#endif
-#ifdef HAVE_LONG_INT_64
+#else
return ECPGt_long;
#endif
/* Unhandled types always return a string */
diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in
index 5d0f448a86..48bce0878a 100644
--- a/src/interfaces/ecpg/include/ecpg_config.h.in
+++ b/src/interfaces/ecpg/include/ecpg_config.h.in
@@ -1,17 +1,5 @@
/* Define to 1 to build client libraries as thread-safe code. */
#define ENABLE_THREAD_SAFETY 1
-/* Define to 1 if the system has the type `int64'. */
-#undef HAVE_INT64
-
-/* Define to 1 if `long int' works and is 64 bits. */
-#undef HAVE_LONG_INT_64
-
-/* Define to 1 if the system has the type `long long int'. */
-#define HAVE_LONG_LONG_INT 1
-
-/* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
-
/* Define to 1 to use <stdbool.h> to define type bool. */
#undef PG_USE_STDBOOL
diff --git a/src/interfaces/ecpg/include/meson.build b/src/interfaces/ecpg/include/meson.build
index 31610fef58..d0234413fc 100644
--- a/src/interfaces/ecpg/include/meson.build
+++ b/src/interfaces/ecpg/include/meson.build
@@ -3,9 +3,6 @@
ecpg_inc = include_directories('.')
ecpg_conf_keys = [
- 'HAVE_INT64',
- 'HAVE_LONG_INT_64',
- 'HAVE_LONG_LONG_INT_64',
'PG_USE_STDBOOL',
]
diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h
index 2809b356f7..d16f74970c 100644
--- a/src/interfaces/ecpg/include/pgtypes_interval.h
+++ b/src/interfaces/ecpg/include/pgtypes_interval.h
@@ -8,18 +8,7 @@
#ifndef C_H
-#ifdef HAVE_LONG_INT_64
-#ifndef HAVE_INT64
-typedef long int int64;
-#endif
-#elif defined(HAVE_LONG_LONG_INT_64)
-#ifndef HAVE_INT64
-typedef long long int int64;
-#endif
-#else
-/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
-#error must have a working 64-bit integer datatype
-#endif
+typedef int64_t int64;
#define HAVE_INT64_TIMESTAMP
#endif /* C_H */
diff --git a/src/interfaces/ecpg/include/sqltypes.h b/src/interfaces/ecpg/include/sqltypes.h
index e7cbfa4795..aed055eb4a 100644
--- a/src/interfaces/ecpg/include/sqltypes.h
+++ b/src/interfaces/ecpg/include/sqltypes.h
@@ -46,7 +46,7 @@
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index 7e19319d27..02ec7b668d 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
@@ -97,7 +97,7 @@ typedef struct sqlda_struct sqlda_t;
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c
index 87f56e82b8..d4413a299a 100644
--- a/src/port/pg_bitutils.c
+++ b/src/port/pg_bitutils.c
@@ -370,12 +370,11 @@ static inline int
pg_popcount64_slow(uint64 word)
{
#ifdef HAVE__BUILTIN_POPCOUNT
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return __builtin_popcountl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return __builtin_popcountll(word);
#else
-#error must have a working 64-bit integer datatype
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return __builtin_popcountll(word);
#endif
#else /* !HAVE__BUILTIN_POPCOUNT */
int result = 0;
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 884f0262dd..291148b4e8 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -568,12 +568,11 @@ nextch2:
goto nextch2;
case 'z':
#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
- longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
+ StaticAssertStmt(sizeof(size_t) == sizeof(long long), "unexpected size");
+ longlongflag = 1;
#endif
#else
/* assume size_t is same size as int */
@@ -835,12 +834,11 @@ nextch1:
goto nextch1;
case 'z':
#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
- longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
+ StaticAssertStmt(sizeof(size_t) == sizeof(long long), "unexpected size");
+ longlongflag = 1;
#endif
#else
/* assume size_t is same size as int */
--
2.39.3 (Apple Git-146)
[application/octet-stream] 0002-Remove-traces-of-BeOS.patch (4.3K, ../../CA+hUKG+ZwX-reVMHak3yo-63rrh9AJwEVGW4rCbsoLeSKO54Pg@mail.gmail.com/3-0002-Remove-traces-of-BeOS.patch)
download | inline diff:
From 6b773c9489ee1117cea8ec7e03f3e585eb9960c7 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Thu, 18 Apr 2024 12:06:17 +1200
Subject: [PATCH 2/2] Remove traces of BeOS.
Commit 15abc7788e6 tolerated namespace pollution from BeOS system
headers. Commit 44f902122 de-supported BeOS. Since that stuff didn't
make it into the Meson build system, synchronize by removing from
configure.
---
configure | 45 --------------------------------------
configure.ac | 6 -----
src/include/c.h | 8 -------
src/include/pg_config.h.in | 12 ----------
4 files changed, 71 deletions(-)
diff --git a/configure b/configure
index e084fd2210..d5da3712e6 100755
--- a/configure
+++ b/configure
@@ -16787,51 +16787,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-
-# Some platforms predefine the types int8, int16, etc. Only check
-# a (hopefully) representative subset.
-ac_fn_c_check_type "$LINENO" "int8" "ac_cv_type_int8" "#include <stdio.h>
-"
-if test "x$ac_cv_type_int8" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_INT8 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "uint8" "ac_cv_type_uint8" "#include <stdio.h>
-"
-if test "x$ac_cv_type_uint8" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_UINT8 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "int64" "ac_cv_type_int64" "#include <stdio.h>
-"
-if test "x$ac_cv_type_int64" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_INT64 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "uint64" "ac_cv_type_uint64" "#include <stdio.h>
-"
-if test "x$ac_cv_type_uint64" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_UINT64 1
-_ACEOF
-
-
-fi
-
-
# Check how printf should display if int64_t. "ll" has the right size on all
# systems, but "l" might be required on some systems to avoid GCC's print type
# mismatch warnings.
diff --git a/configure.ac b/configure.ac
index e8cac06a72..49b9287585 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1988,12 +1988,6 @@ if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
fi
AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
-
-# Some platforms predefine the types int8, int16, etc. Only check
-# a (hopefully) representative subset.
-AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
-[#include <stdio.h>])
-
# Check how printf should display if int64_t. "ll" has the right size on all
# systems, but "l" might be required on some systems to avoid GCC's print type
# mismatch warnings.
diff --git a/src/include/c.h b/src/include/c.h
index b7f97d412c..90d70d6491 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -485,14 +485,10 @@ typedef char *Pointer;
* used for numerical computations and the
* frontend/backend protocol.
*/
-#ifndef HAVE_INT8
typedef int8_t int8; /* == 8 bits */
typedef int16_t int16; /* == 16 bits */
typedef int32_t int32; /* == 32 bits */
-#endif /* not HAVE_INT8 */
-#ifndef HAVE_INT64
typedef int64_t int64; /* == 64 bits */
-#endif /* not HAVE_INT64 */
/*
* uintN
@@ -500,14 +496,10 @@ typedef int64_t int64; /* == 64 bits */
* used for numerical computations and the
* frontend/backend protocol.
*/
-#ifndef HAVE_UINT8
typedef uint8_t uint8; /* == 8 bits */
typedef uint16_t uint16; /* == 16 bits */
typedef uint32_t uint32; /* == 32 bits */
-#endif /* not HAVE_UINT8 */
-#ifndef HAVE_UINT64
typedef uint64_t uint64; /* == 64 bits */
-#endif /* not HAVE_UINT64 */
/*
* bitsN
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 2141010487..8a34a8d295 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -213,12 +213,6 @@
/* Define to 1 if you have the `inet_pton' function. */
#undef HAVE_INET_PTON
-/* Define to 1 if the system has the type `int64'. */
-#undef HAVE_INT64
-
-/* Define to 1 if the system has the type `int8'. */
-#undef HAVE_INT8
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -465,12 +459,6 @@
/* Define to 1 if you have the <ucred.h> header file. */
#undef HAVE_UCRED_H
-/* Define to 1 if the system has the type `uint64'. */
-#undef HAVE_UINT64
-
-/* Define to 1 if the system has the type `uint8'. */
-#undef HAVE_UINT8
-
/* Define to 1 if the system has the type `union semun'. */
#undef HAVE_UNION_SEMUN
--
2.39.3 (Apple Git-146)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
@ 2024-04-18 06:07 ` Japin Li <[email protected]>
2024-04-18 21:22 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2 siblings, 1 reply; 10+ messages in thread
From: Japin Li @ 2024-04-18 06:07 UTC (permalink / raw)
To: Thomas Munro <[email protected]>; +Cc: Tom Lane <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Thu, 18 Apr 2024 at 08:31, Thomas Munro <[email protected]> wrote:
> On Sat, Mar 23, 2024 at 3:23 PM Tom Lane <[email protected]> wrote:
>> Thomas Munro <[email protected]> writes:
>> > . o O ( int64_t, PRIdi64, etc were standardised a quarter of a century ago )
>>
>> Yeah. Now that we require C99 it's probably reasonable to assume
>> that those things exist. I wouldn't be in favor of ripping out our
>> existing notations like UINT64CONST, because the code churn would be
>> substantial and the gain minimal. But we could imagine reimplementing
>> that stuff atop <stdint.h> and then getting rid of the configure-time
>> probes.
>
> I played around with this a bit, but am not quite there yet.
>
> printf() is a little tricky. The standard wants us to use
> <inttypes.h>'s PRId64 etc, but that might confuse our snprintf.c (in
> theory, probably not in practice). "ll" should have the right size on
> all systems, but gets warnings from the printf format string checker
> on systems where "l" is the right type. So I think we still need to
> probe for INT64_MODIFIER at configure-time. Here's one way, but I can
> see it's not working on Clang/Linux... perhaps instead of that dubious
> incantation I should try compiling some actual printfs and check for
> warnings/errors.
>
> I think INT64CONST should just point to standard INT64_C().
>
> For limits, why do we have this:
>
> - * stdint.h limits aren't guaranteed to have compatible types with our fixed
> - * width types. So just define our own.
>
> ? I mean, how could they not have compatible types?
>
> I noticed that configure.ac checks if int64 (no "_t") might be defined
> already by system header pollution, but meson.build doesn't. That's
> an inconsistency that should be fixed, but which way? Hmm, commit
> 15abc7788e6 said that was done for BeOS, which we de-supported. So
> maybe we should get rid of that?
Thanks for working on this! I test the patch and it now works on Illumos when
configure with -Werror option. However, there are some errors when compiling.
In file included from /home/japin/postgres/build/../src/include/c.h:834,
from /home/japin/postgres/build/../src/include/postgres_fe.h:25,
from /home/japin/postgres/build/../src/common/config_info.c:20:
/home/japin/postgres/build/../src/common/config_info.c: In function 'get_configdata':
/home/japin/postgres/build/../src/common/config_info.c:198:11: error: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Werror=sign-compare]
198 | Assert(i == *configdata_len);
| ^~
/home/japin/postgres/build/../src/common/config_info.c:198:2: note: in expansion of macro 'Assert'
198 | Assert(i == *configdata_len);
| ^~~~~~
In file included from /home/japin/postgres/build/../src/common/blkreftable.c:36:
/home/japin/postgres/build/../src/include/lib/simplehash.h: In function 'blockreftable_stat':
/home/japin/postgres/build/../src/include/lib/simplehash.h:1138:9: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64' {aka 'long unsigned int'} [-Werror=format=]
1138 | sh_log("size: " UINT64_FORMAT ", members: %u, filled: %f, total chain: %u, max chain: %u, avg chain: %f, total_collisions: %u, max_collisions: %u, avg_collisions: %f",
| ^~~~~~~~
1139 | tb->size, tb->members, fillfactor, total_chain_length, max_chain_length, avg_chain_length,
| ~~~~~~~~
| |
| uint64 {aka long unsigned int}
/home/japin/postgres/build/../src/include/common/logging.h:125:46: note: in definition of macro 'pg_log_info'
125 | pg_log_generic(PG_LOG_INFO, PG_LOG_PRIMARY, __VA_ARGS__)
| ^~~~~~~~~~~
/home/japin/postgres/build/../src/include/lib/simplehash.h:1138:2: note: in expansion of macro 'sh_log'
1138 | sh_log("size: " UINT64_FORMAT ", members: %u, filled: %f, total chain: %u, max chain: %u, avg chain: %f, total_collisions: %u, max_collisions: %u, avg_collisions: %f",
| ^~~~~~
In file included from /home/japin/postgres/build/../src/include/access/xlogrecord.h:14,
from /home/japin/postgres/build/../src/include/access/xlogreader.h:41,
from /home/japin/postgres/build/../src/include/access/xlog_internal.h:23,
from /home/japin/postgres/build/../src/common/controldata_utils.c:28:
/home/japin/postgres/build/../src/include/access/rmgr.h: In function 'RmgrIdIsCustom':
/home/japin/postgres/build/../src/include/access/rmgr.h:50:42: error: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Werror=sign-compare]
50 | return rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID;
| ^~
/home/japin/postgres/build/../src/common/blkreftable.c: In function 'BlockRefTableReaderGetBlocks':
/home/japin/postgres/build/../src/common/blkreftable.c:716:22: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
716 | blocks_found < nblocks)
| ^
/home/japin/postgres/build/../src/common/blkreftable.c:732:22: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
732 | blocks_found < nblocks)
| ^
/home/japin/postgres/build/../src/common/blkreftable.c:742:20: error: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Werror=sign-compare]
742 | if (blocks_found >= nblocks)
| ^~
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: config_info.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [../../src/Makefile.global:947: controldata_utils.o] Error 1
In file included from /home/japin/postgres/build/../src/include/postgres_fe.h:25,
from /home/japin/postgres/build/../src/common/logging.c:15:
/home/japin/postgres/build/../src/common/logging.c: In function 'pg_log_generic_v':
/home/japin/postgres/build/../src/include/c.h:523:23: error: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64' {aka 'long unsigned int'} [-Werror=format=]
523 | #define UINT64_FORMAT "%" INT64_MODIFIER "u"
| ^~~
/home/japin/postgres/build/../src/common/logging.c:259:21: note: in expansion of macro 'UINT64_FORMAT'
259 | fprintf(stderr, UINT64_FORMAT ":", lineno);
| ^~~~~~~~~~~~~
/home/japin/postgres/build/../src/include/c.h:523:43: note: format string is defined here
523 | #define UINT64_FORMAT "%" INT64_MODIFIER "u"
| ~~~~~~~~~~~~~~~~~~~^
| |
| long long unsigned int
/home/japin/postgres/build/../src/common/unicode_norm.c: In function 'recompose_code':
/home/japin/postgres/build/../src/common/unicode_norm.c:290:17: error: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Werror=sign-compare]
290 | for (i = 0; i < lengthof(UnicodeDecompMain); i++)
| ^
In file included from /home/japin/postgres/build/../src/include/c.h:834,
from /home/japin/postgres/build/../src/common/encnames.c:13:
/home/japin/postgres/build/../src/common/encnames.c: In function 'pg_encoding_to_char_private':
/home/japin/postgres/build/../src/common/encnames.c:593:19: error: comparison of integer expressions of different signedness: 'int' and 'pg_enc' [-Werror=sign-compare]
593 | Assert(encoding == p->encoding);
| ^~
/home/japin/postgres/build/../src/common/encnames.c:593:3: note: in expansion of macro 'Assert'
593 | Assert(encoding == p->encoding);
| ^~~~~~
/home/japin/postgres/build/../src/common/jsonapi.c: In function 'pg_parse_json_incremental':
/home/japin/postgres/build/../src/common/jsonapi.c:693:11: error: comparison of integer expressions of different signedness: 'char' and 'JsonTokenType' [-Werror=sign-compare]
693 | if (top == tok)
| ^~
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: logging.o] Error 1
make[2]: *** [../../src/Makefile.global:947: blkreftable.o] Error 1
/home/japin/postgres/build/../src/common/kwlookup.c: In function 'ScanKeywordLookup':
/home/japin/postgres/build/../src/common/kwlookup.c:50:10: error: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'int' [-Werror=sign-compare]
50 | if (len > keywords->max_kw_len)
| ^
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: encnames.o] Error 1
cc1: all warnings being treated as errors
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: kwlookup.o] Error 1
In file included from /home/japin/postgres/build/../src/include/c.h:834,
from /home/japin/postgres/build/../src/include/postgres_fe.h:25,
from /home/japin/postgres/build/../src/common/file_utils.c:19:
/home/japin/postgres/build/../src/common/file_utils.c: In function 'pg_pwrite_zeros':
/home/japin/postgres/build/../src/common/file_utils.c:725:23: error: comparison of integer expressions of different signedness: 'ssize_t' {aka 'long int'} and 'size_t' {aka 'long unsigned int'} [-Werror=sign-compare]
725 | Assert(total_written == size);
| ^~
/home/japin/postgres/build/../src/common/file_utils.c:725:2: note: in expansion of macro 'Assert'
725 | Assert(total_written == size);
| ^~~~~~
make[2]: *** [../../src/Makefile.global:947: unicode_norm.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: file_utils.o] Error 1
/home/japin/postgres/build/../src/common/unicode_case.c: In function 'convert_case':
/home/japin/postgres/build/../src/common/unicode_case.c:155:31: error: comparison of integer expressions of different signedness: 'size_t' {aka 'long unsigned int'} and 'ssize_t' {aka 'long int'} [-Werror=sign-compare]
155 | while ((srclen < 0 || srcoff < srclen) && src[srcoff] != '\0')
| ^
/home/japin/postgres/build/../src/common/wchar.c: In function 'pg_utf8_verifystr':
/home/japin/postgres/build/../src/common/wchar.c:1868:10: error: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Werror=sign-compare]
1868 | if (len >= STRIDE_LENGTH)
| ^~
/home/japin/postgres/build/../src/common/wchar.c:1870:14: error: comparison of integer expressions of different signedness: 'int' and 'long unsigned int' [-Werror=sign-compare]
1870 | while (len >= STRIDE_LENGTH)
| ^~
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: unicode_case.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: jsonapi.o] Error 1
cc1: all warnings being treated as errors
make[2]: *** [../../src/Makefile.global:947: wchar.o] Error 1
make[1]: *** [Makefile:42: all-common-recurse] Error 2
make: *** [GNUmakefile:11: all-src-recurse] Error 2
For rmid >= RM_MIN_CUSTOM_ID && rmid <= RM_MAX_CUSTOM_ID comparison error, I
found that UINT8_MAX is defined as '255U' on Illumos, however, Linux glibc
uses '255' for UINT8_MAX, which is signed.
[1] https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/int_limits.h#L92
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=stdlib/stdint.h;h=bb3e8b5cc61fb3df8842225d2286de67e...
--
Regards,
Japin Li
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 06:07 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
@ 2024-04-18 21:22 ` Thomas Munro <[email protected]>
2024-04-19 05:25 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
0 siblings, 1 reply; 10+ messages in thread
From: Thomas Munro @ 2024-04-18 21:22 UTC (permalink / raw)
To: Japin Li <[email protected]>; +Cc: Tom Lane <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Thu, Apr 18, 2024 at 6:09 PM Japin Li <[email protected]> wrote:
> /home/japin/postgres/build/../src/common/config_info.c:198:11: error: comparison of integer expressions of different signedness: 'int' and 'size_t' {aka 'long unsigned int'} [-Werror=sign-compare]
> 198 | Assert(i == *configdata_len);
Right, PostgreSQL doesn't compile cleanly with the "sign-compare"
warning. There have been a few threads about that, and someone might
want to think harder about it, but it's a different topic unrelated to
<stdint.h>.
> /home/japin/postgres/build/../src/include/lib/simplehash.h:1138:9: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64' {aka 'long unsigned int'} [-Werror=format=]
It seems my v1 patch's configure probe for INT64_FORMAT was broken.
In the v2 patch I tried not doing that probe at all, and instead
inviting <inttypes.h> into our world (that's the standardised way to
produce format strings, which has the slight complication that we are
intercepting printf calls...). I suspect that'll work better for you.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 06:07 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
2024-04-18 21:22 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
@ 2024-04-19 05:25 ` Japin Li <[email protected]>
0 siblings, 0 replies; 10+ messages in thread
From: Japin Li @ 2024-04-19 05:25 UTC (permalink / raw)
To: Thomas Munro <[email protected]>; +Cc: Tom Lane <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Fri, 19 Apr 2024 at 05:22, Thomas Munro <[email protected]> wrote:
> On Thu, Apr 18, 2024 at 6:09 PM Japin Li <[email protected]> wrote:
>> /home/japin/postgres/build/../src/include/lib/simplehash.h:1138:9: error: format '%llu' expects argument of type 'long long unsigned int', but argument 4 has type 'uint64' {aka 'long unsigned int'} [-Werror=format=]
>
> It seems my v1 patch's configure probe for INT64_FORMAT was broken.
> In the v2 patch I tried not doing that probe at all, and instead
> inviting <inttypes.h> into our world (that's the standardised way to
> produce format strings, which has the slight complication that we are
> intercepting printf calls...). I suspect that'll work better for you.
Yeah, the v2 patch fixed this problem.
--
Regards,
Japin Li
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
@ 2024-04-18 08:46 ` Peter Eisentraut <[email protected]>
2024-04-18 20:29 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 21:00 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2 siblings, 2 replies; 10+ messages in thread
From: Peter Eisentraut @ 2024-04-18 08:46 UTC (permalink / raw)
To: Thomas Munro <[email protected]>; Tom Lane <[email protected]>; +Cc: Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On 18.04.24 02:31, Thomas Munro wrote:
> On Sat, Mar 23, 2024 at 3:23 PM Tom Lane <[email protected]> wrote:
>> Thomas Munro <[email protected]> writes:
>>> . o O ( int64_t, PRIdi64, etc were standardised a quarter of a century ago )
>>
>> Yeah. Now that we require C99 it's probably reasonable to assume
>> that those things exist. I wouldn't be in favor of ripping out our
>> existing notations like UINT64CONST, because the code churn would be
>> substantial and the gain minimal. But we could imagine reimplementing
>> that stuff atop <stdint.h> and then getting rid of the configure-time
>> probes.
>
> I played around with this a bit, but am not quite there yet.
Looks promising.
> printf() is a little tricky. The standard wants us to use
> <inttypes.h>'s PRId64 etc, but that might confuse our snprintf.c (in
> theory, probably not in practice). "ll" should have the right size on
> all systems, but gets warnings from the printf format string checker
> on systems where "l" is the right type.
I'm not sure I understand the problem here. Do you mean that in theory
a platform's PRId64 could be something other than "l" or "ll"?
> For limits, why do we have this:
>
> - * stdint.h limits aren't guaranteed to have compatible types with our fixed
> - * width types. So just define our own.
>
> ? I mean, how could they not have compatible types?
Maybe this means something like our int64 is long long int but the
system's int64_t is long int underneath, but I don't see how that would
matter for the limit macros.
> I noticed that configure.ac checks if int64 (no "_t") might be defined
> already by system header pollution, but meson.build doesn't. That's
> an inconsistency that should be fixed, but which way? Hmm, commit
> 15abc7788e6 said that was done for BeOS, which we de-supported. So
> maybe we should get rid of that?
I had a vague recollection that it was for AIX, but the commit indeed
mentions BeOS. Could be removed in either case.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 08:46 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
@ 2024-04-18 20:29 ` Thomas Munro <[email protected]>
2024-07-02 13:34 ` Re: Cannot find a working 64-bit integer type on Illumos Heikki Linnakangas <[email protected]>
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Munro @ 2024-04-18 20:29 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: Tom Lane <[email protected]>; Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Thu, Apr 18, 2024 at 8:47 PM Peter Eisentraut <[email protected]> wrote:
> I'm not sure I understand the problem here. Do you mean that in theory
> a platform's PRId64 could be something other than "l" or "ll"?
Yes. I don't know why anyone would do that, and the systems I checked
all have the obvious definitions, eg "ld", "lld" etc. Perhaps it's an
acceptable risk? It certainly gives us a tidier result.
For discussion, here is a variant that fully embraces <inttypes.h> and
the PRI*64 macros.
Attachments:
[application/octet-stream] v2-0001-Use-int64_t-support-from-stdint.h-and-inttypes.h.patch (38.2K, ../../CA+hUKGKXEdVSfR6UHXfR3tSQ+TfBNk-ssYmO2F0wCdw7qcx86Q@mail.gmail.com/2-v2-0001-Use-int64_t-support-from-stdint.h-and-inttypes.h.patch)
download | inline diff:
From 0d25af2a59c6d4b9f6972ca02830713cf156b527 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Thu, 18 Apr 2024 07:53:10 +1200
Subject: [PATCH v2 1/2] Use int64_t support from <stdint.h> and <inttypes.h>.
Remove most of the configure probes for 64 bit integers. Map our names
to the standard C99 names for types like int64_t, limits like INT64_MAX,
constant constructors like INT64_C(). Also use printf format strings
like PRId64 from <inttypes.h>.
There is a slight risk that some system will invent a definition of
PRId64 that our own snprintf.c doesn't understand (ie something other
than "ld" or "lld"), but that seems unlikely and we could easily deal
with it if a report arrives. In practice, format strings made with
PRI*64 macros are expected to work on both the system printf-family and
our own in-tree snprintf.c.
We can get rid of pg_config_ext.h.
XXX WIP
---
configure | 230 ++----------------
configure.ac | 46 +---
meson.build | 35 +--
src/Makefile.global.in | 6 -
src/bin/pg_waldump/pg_waldump.c | 16 +-
src/bin/pgbench/pgbench.c | 4 +-
src/include/.gitignore | 2 -
src/include/Makefile | 8 +-
src/include/c.h | 83 +++----
src/include/meson.build | 10 -
src/include/pg_config.h.in | 18 +-
src/include/pg_config_ext.h.in | 7 -
src/include/pg_config_ext.h.meson | 7 -
src/include/port/pg_bitutils.h | 18 +-
src/include/postgres_ext.h | 7 +-
src/include/utils/dsa.h | 2 +-
src/interfaces/ecpg/ecpglib/typename.c | 5 +-
src/interfaces/ecpg/include/ecpg_config.h.in | 12 -
src/interfaces/ecpg/include/meson.build | 3 -
.../ecpg/include/pgtypes_interval.h | 13 +-
src/interfaces/ecpg/include/sqltypes.h | 2 +-
.../test/expected/compat_informix-sqlda.c | 2 +-
src/port/pg_bitutils.c | 7 +-
src/port/snprintf.c | 14 +-
.../modules/test_radixtree/test_radixtree.c | 2 +-
25 files changed, 102 insertions(+), 457 deletions(-)
delete mode 100644 src/include/pg_config_ext.h.in
delete mode 100644 src/include/pg_config_ext.h.meson
diff --git a/configure b/configure
index cfbd2a096f..52b5f666ce 100755
--- a/configure
+++ b/configure
@@ -16439,197 +16439,6 @@ fi
# Run tests below here
# --------------------
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long int is 64 bits" >&5
-$as_echo_n "checking whether long int is 64 bits... " >&6; }
-if ${pgac_cv_type_long_int_64+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- # If cross-compiling, check the size reported by the compiler and
-# trust that the arithmetic works.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof(long int) == 8)];
-test_array [0] = 0;
-return test_array [0];
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_type_long_int_64=yes
-else
- pgac_cv_type_long_int_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-typedef long int ac_int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-ac_int64 a = 20000001;
-ac_int64 b = 40000005;
-
-int does_int64_work()
-{
- ac_int64 c,d;
-
- if (sizeof(ac_int64) != 8)
- return 0; /* definitely not the right size */
-
- /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
- c = a * b;
- d = (c + b) / b;
- if (d != a+1)
- return 0;
- return 1;
-}
-
-int
-main() {
- return (! does_int64_work());
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- pgac_cv_type_long_int_64=yes
-else
- pgac_cv_type_long_int_64=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_long_int_64" >&5
-$as_echo "$pgac_cv_type_long_int_64" >&6; }
-
-HAVE_LONG_INT_64=$pgac_cv_type_long_int_64
-if test x"$pgac_cv_type_long_int_64" = xyes ; then
-
-$as_echo "#define HAVE_LONG_INT_64 1" >>confdefs.h
-
-fi
-
-
-if test x"$HAVE_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long int"
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether long long int is 64 bits" >&5
-$as_echo_n "checking whether long long int is 64 bits... " >&6; }
-if ${pgac_cv_type_long_long_int_64+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- if test "$cross_compiling" = yes; then :
- # If cross-compiling, check the size reported by the compiler and
-# trust that the arithmetic works.
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-int
-main ()
-{
-static int test_array [1 - 2 * !(sizeof(long long int) == 8)];
-test_array [0] = 0;
-return test_array [0];
-
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
- pgac_cv_type_long_long_int_64=yes
-else
- pgac_cv_type_long_long_int_64=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-typedef long long int ac_int64;
-
-/*
- * These are globals to discourage the compiler from folding all the
- * arithmetic tests down to compile-time constants.
- */
-ac_int64 a = 20000001;
-ac_int64 b = 40000005;
-
-int does_int64_work()
-{
- ac_int64 c,d;
-
- if (sizeof(ac_int64) != 8)
- return 0; /* definitely not the right size */
-
- /* Do perfunctory checks to see if 64-bit arithmetic seems to work */
- c = a * b;
- d = (c + b) / b;
- if (d != a+1)
- return 0;
- return 1;
-}
-
-int
-main() {
- return (! does_int64_work());
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
- pgac_cv_type_long_long_int_64=yes
-else
- pgac_cv_type_long_long_int_64=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
- conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_type_long_long_int_64" >&5
-$as_echo "$pgac_cv_type_long_long_int_64" >&6; }
-
-HAVE_LONG_LONG_INT_64=$pgac_cv_type_long_long_int_64
-if test x"$pgac_cv_type_long_long_int_64" = xyes ; then
-
-$as_echo "#define HAVE_LONG_LONG_INT_64 1" >>confdefs.h
-
-fi
-
- if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long long int"
- else
- as_fn_error $? "Cannot find a working 64-bit integer type." "$LINENO" 5
- fi
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define PG_INT64_TYPE $pg_int64_type
-_ACEOF
-
-
-# Select the printf length modifier that goes with that, too.
-if test x"$pg_int64_type" = x"long long int" ; then
- INT64_MODIFIER='"ll"'
-else
- INT64_MODIFIER='"l"'
-fi
-
-
-cat >>confdefs.h <<_ACEOF
-#define INT64_MODIFIER $INT64_MODIFIER
-_ACEOF
-
-
# has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_mul_overflow" >&5
@@ -16877,43 +16686,41 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- # The cast to long int works around a bug in the HP C Compiler,
+# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of long long int" >&5
-$as_echo_n "checking alignment of long long int... " >&6; }
-if ${ac_cv_alignof_long_long_int+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of int64_t" >&5
+$as_echo_n "checking alignment of int64_t... " >&6; }
+if ${ac_cv_alignof_int64_t+:} false; then :
$as_echo_n "(cached) " >&6
else
- if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_long_long_int" "$ac_includes_default
+ if ac_fn_c_compute_int "$LINENO" "(long int) offsetof (ac__type_alignof_, y)" "ac_cv_alignof_int64_t" "$ac_includes_default
#ifndef offsetof
# define offsetof(type, member) ((char *) &((type *) 0)->member - (char *) 0)
#endif
-typedef struct { char x; long long int y; } ac__type_alignof_;"; then :
+typedef struct { char x; int64_t y; } ac__type_alignof_;"; then :
else
- if test "$ac_cv_type_long_long_int" = yes; then
+ if test "$ac_cv_type_int64_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "cannot compute alignment of long long int
+as_fn_error 77 "cannot compute alignment of int64_t
See \`config.log' for more details" "$LINENO" 5; }
else
- ac_cv_alignof_long_long_int=0
+ ac_cv_alignof_int64_t=0
fi
fi
fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_long_long_int" >&5
-$as_echo "$ac_cv_alignof_long_long_int" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_alignof_int64_t" >&5
+$as_echo "$ac_cv_alignof_int64_t" >&6; }
cat >>confdefs.h <<_ACEOF
-#define ALIGNOF_LONG_LONG_INT $ac_cv_alignof_long_long_int
+#define ALIGNOF_INT64_T $ac_cv_alignof_int64_t
_ACEOF
-fi
# The cast to long int works around a bug in the HP C Compiler,
# see AC_CHECK_SIZEOF for more information.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking alignment of double" >&5
@@ -16971,8 +16778,8 @@ MAX_ALIGNOF=$ac_cv_alignof_double
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
as_fn_error $? "alignment of 'long' is greater than the alignment of 'double'" "$LINENO" 5
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- as_fn_error $? "alignment of 'long long int' is greater than the alignment of 'double'" "$LINENO" 5
+if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
+ as_fn_error $? "alignment of 'int64_t' is greater than the alignment of 'double'" "$LINENO" 5
fi
cat >>confdefs.h <<_ACEOF
@@ -16980,7 +16787,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-
# Some platforms predefine the types int8, int16, etc. Only check
# a (hopefully) representative subset.
ac_fn_c_check_type "$LINENO" "int8" "ac_cv_type_int8" "#include <stdio.h>
@@ -19272,9 +19078,6 @@ fi
ac_config_headers="$ac_config_headers src/include/pg_config.h"
-ac_config_headers="$ac_config_headers src/include/pg_config_ext.h"
-
-
ac_config_headers="$ac_config_headers src/interfaces/ecpg/include/ecpg_config.h"
@@ -19989,7 +19792,6 @@ do
"src/Makefile.port") CONFIG_LINKS="$CONFIG_LINKS src/Makefile.port:src/makefiles/Makefile.${template}" ;;
"check_win32_symlinks") CONFIG_COMMANDS="$CONFIG_COMMANDS check_win32_symlinks" ;;
"src/include/pg_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config.h" ;;
- "src/include/pg_config_ext.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/pg_config_ext.h" ;;
"src/interfaces/ecpg/include/ecpg_config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/interfaces/ecpg/include/ecpg_config.h" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@@ -20597,10 +20399,6 @@ $as_echo "$as_me: WARNING: *** link for $FILE -- please fix by hand" >&2;}
"src/include/pg_config.h":H)
# Update timestamp for pg_config.h (see Makefile.global)
echo >src/include/stamp-h
- ;;
- "src/include/pg_config_ext.h":H)
-# Update timestamp for pg_config_ext.h (see Makefile.global)
-echo >src/include/stamp-ext-h
;;
"src/interfaces/ecpg/include/ecpg_config.h":H) echo >src/interfaces/ecpg/include/stamp-h ;;
diff --git a/configure.ac b/configure.ac
index 67e738d92b..1c4cd3ab72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1945,37 +1945,6 @@ for the exact reason.]])],
# Run tests below here
# --------------------
-dnl Check to see if we have a working 64-bit integer type.
-dnl Since Postgres 8.4, we no longer support compilers without a working
-dnl 64-bit type; but we have to determine whether that type is called
-dnl "long int" or "long long int".
-
-PGAC_TYPE_64BIT_INT([long int])
-
-if test x"$HAVE_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long int"
-else
- PGAC_TYPE_64BIT_INT([long long int])
- if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- pg_int64_type="long long int"
- else
- AC_MSG_ERROR([Cannot find a working 64-bit integer type.])
- fi
-fi
-
-AC_DEFINE_UNQUOTED(PG_INT64_TYPE, $pg_int64_type,
- [Define to the name of a signed 64-bit integer type.])
-
-# Select the printf length modifier that goes with that, too.
-if test x"$pg_int64_type" = x"long long int" ; then
- INT64_MODIFIER='"ll"'
-else
- INT64_MODIFIER='"l"'
-fi
-
-AC_DEFINE_UNQUOTED(INT64_MODIFIER, $INT64_MODIFIER,
- [Define to the appropriate printf length modifier for 64-bit ints.])
-
# has to be down here, rather than with the other builtins, because
# the test uses PG_INT64_TYPE.
PGAC_C_BUILTIN_OP_OVERFLOW
@@ -1990,9 +1959,7 @@ AC_CHECK_SIZEOF([long])
AC_CHECK_ALIGNOF(short)
AC_CHECK_ALIGNOF(int)
AC_CHECK_ALIGNOF(long)
-if test x"$HAVE_LONG_LONG_INT_64" = x"yes" ; then
- AC_CHECK_ALIGNOF(long long int)
-fi
+AC_CHECK_ALIGNOF(int64_t)
AC_CHECK_ALIGNOF(double)
# Compute maximum alignment of any basic type.
@@ -2016,12 +1983,11 @@ MAX_ALIGNOF=$ac_cv_alignof_double
if test $ac_cv_alignof_long -gt $MAX_ALIGNOF ; then
AC_MSG_ERROR([alignment of 'long' is greater than the alignment of 'double'])
fi
-if test x"$HAVE_LONG_LONG_INT_64" = xyes && test $ac_cv_alignof_long_long_int -gt $MAX_ALIGNOF ; then
- AC_MSG_ERROR([alignment of 'long long int' is greater than the alignment of 'double'])
+if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
+ AC_MSG_ERROR([alignment of 'int64_t' is greater than the alignment of 'double'])
fi
AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
-
# Some platforms predefine the types int8, int16, etc. Only check
# a (hopefully) representative subset.
AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
@@ -2520,12 +2486,6 @@ AC_CONFIG_HEADERS([src/include/pg_config.h],
echo >src/include/stamp-h
])
-AC_CONFIG_HEADERS([src/include/pg_config_ext.h],
-[
-# Update timestamp for pg_config_ext.h (see Makefile.global)
-echo >src/include/stamp-ext-h
-])
-
AC_CONFIG_HEADERS([src/interfaces/ecpg/include/ecpg_config.h],
[echo >src/interfaces/ecpg/include/stamp-h])
diff --git a/meson.build b/meson.build
index cdfd31377d..96e5edc53f 100644
--- a/meson.build
+++ b/meson.build
@@ -1488,18 +1488,6 @@ endif
sizeof_long = cc.sizeof('long', args: test_c_args)
cdata.set('SIZEOF_LONG', sizeof_long)
-if sizeof_long == 8
- cdata.set('HAVE_LONG_INT_64', 1)
- pg_int64_type = 'long int'
- cdata.set_quoted('INT64_MODIFIER', 'l')
-elif sizeof_long == 4 and cc.sizeof('long long', args: test_c_args) == 8
- cdata.set('HAVE_LONG_LONG_INT_64', 1)
- pg_int64_type = 'long long int'
- cdata.set_quoted('INT64_MODIFIER', 'll')
-else
- error('do not know how to get a 64bit int')
-endif
-cdata.set('PG_INT64_TYPE', pg_int64_type)
if host_machine.endian() == 'big'
cdata.set('WORDS_BIGENDIAN', 1)
@@ -1529,8 +1517,8 @@ endforeach
# any types wider than 64 bits, as allowing MAXIMUM_ALIGNOF to exceed 8
# would be too much of a penalty for disk and memory space.
alignof_double = cdata.get('ALIGNOF_DOUBLE')
-if cc.alignment(pg_int64_type, args: test_c_args) > alignof_double
- error('alignment of int64 is greater than the alignment of double')
+if cc.alignment('int64_t', args: test_c_args, prefix: '#include <stdint.h>') > alignof_double
+ error('alignment of int64_t is greater than the alignment of double')
endif
cdata.set('MAXIMUM_ALIGNOF', alignof_double)
@@ -1742,17 +1730,17 @@ endif
# compile, and store the results in global variables so the compiler doesn't
# optimize away the call.
if cc.links('''
- INT64 a = 1;
- INT64 b = 1;
- INT64 result;
+ #include <stdint.h>
+ int64_t a = 1;
+ int64_t b = 1;
+ int64_t result;
int main(void)
{
return __builtin_mul_overflow(a, b, &result);
}''',
name: '__builtin_mul_overflow',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))],
- )
+ args: test_c_args)
cdata.set('HAVE__BUILTIN_OP_OVERFLOW', 1)
endif
@@ -2013,7 +2001,7 @@ int main(void)
cdata.set(check['name'],
cc.links(test,
name: check['desc'],
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))]) ? 1 : false
+ args: test_c_args) ? 1 : false
)
endforeach
@@ -2057,11 +2045,12 @@ if host_cpu == 'x86_64'
prog = '''
#include <immintrin.h>
+#include <stdint.h>
int main(void)
{
const char buf[sizeof(__m512i)];
- INT64 popcnt = 0;
+ int64_t popcnt = 0;
__m512i accum = _mm512_setzero_si512();
const __m512i val = _mm512_maskz_loadu_epi8((__mmask64) 0xf0f0f0f0f0f0f0f0, (const __m512i *) buf);
const __m512i cnt = _mm512_popcnt_epi64(val);
@@ -2073,10 +2062,10 @@ int main(void)
'''
if cc.links(prog, name: 'AVX-512 popcount without -mavx512vpopcntdq -mavx512bw',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))])
+ args: test_c_args)
cdata.set('USE_AVX512_POPCNT_WITH_RUNTIME_CHECK', 1)
elif cc.links(prog, name: 'AVX-512 popcount with -mavx512vpopcntdq -mavx512bw',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))] + ['-mavx512vpopcntdq'] + ['-mavx512bw'])
+ args: test_c_args + ['-mavx512vpopcntdq'] + ['-mavx512bw'])
cdata.set('USE_AVX512_POPCNT_WITH_RUNTIME_CHECK', 1)
cflags_popcnt += ['-mavx512vpopcntdq'] + ['-mavx512bw']
endif
diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 36d880d225..1928fc2f2c 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -833,12 +833,6 @@ $(top_builddir)/src/include/pg_config.h: $(top_builddir)/src/include/stamp-h ;
$(top_builddir)/src/include/stamp-h: $(top_srcdir)/src/include/pg_config.h.in $(top_builddir)/config.status
cd $(top_builddir) && ./config.status src/include/pg_config.h
-# Also remake pg_config_ext.h from pg_config_ext.h.in, same logic as above.
-$(top_builddir)/src/include/pg_config_ext.h: $(top_builddir)/src/include/stamp-ext-h ;
-
-$(top_builddir)/src/include/stamp-ext-h: $(top_srcdir)/src/include/pg_config_ext.h.in $(top_builddir)/config.status
- cd $(top_builddir) && ./config.status src/include/pg_config_ext.h
-
# Also remake ecpg_config.h from ecpg_config.h.in if the latter changed, same
# logic as above.
$(top_builddir)/src/interfaces/ecpg/include/ecpg_config.h: $(top_builddir)/src/interfaces/ecpg/include/stamp-h ;
diff --git a/src/bin/pg_waldump/pg_waldump.c b/src/bin/pg_waldump/pg_waldump.c
index 1f9403fc5c..c4b04d6296 100644
--- a/src/bin/pg_waldump/pg_waldump.c
+++ b/src/bin/pg_waldump/pg_waldump.c
@@ -610,10 +610,10 @@ XLogDumpStatsRow(const char *name,
tot_len_pct = 100 * (double) tot_len / total_len;
printf("%-27s "
- "%20" INT64_MODIFIER "u (%6.02f) "
- "%20" INT64_MODIFIER "u (%6.02f) "
- "%20" INT64_MODIFIER "u (%6.02f) "
- "%20" INT64_MODIFIER "u (%6.02f)\n",
+ "%20" PRIu64 " (%6.02f) "
+ "%20" PRIu64 " (%6.02f) "
+ "%20" PRIu64 " (%6.02f) "
+ "%20" PRIu64 " (%6.02f)\n",
name, n, n_pct, rec_len, rec_len_pct, fpi_len, fpi_len_pct,
tot_len, tot_len_pct);
}
@@ -742,10 +742,10 @@ XLogDumpDisplayStats(XLogDumpConfig *config, XLogStats *stats)
fpi_len_pct = 100 * (double) total_fpi_len / total_len;
printf("%-27s "
- "%20" INT64_MODIFIER "u %-9s"
- "%20" INT64_MODIFIER "u %-9s"
- "%20" INT64_MODIFIER "u %-9s"
- "%20" INT64_MODIFIER "u %-6s\n",
+ "%20" PRIu64 " %-9s"
+ "%20" PRIu64 " %-9s"
+ "%20" PRIu64 " %-9s"
+ "%20" PRIu64 " %-6s\n",
"Total", stats->count, "",
total_rec_len, psprintf("[%.02f%%]", rec_len_pct),
total_fpi_len, psprintf("[%.02f%%]", fpi_len_pct),
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index af776b31d8..088c5fa0c7 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -6545,13 +6545,13 @@ printResults(StatsData *total,
SimpleStats *cstats = &(*commands)->stats;
if (max_tries == 1)
- printf(" %11.3f %10" INT64_MODIFIER "d %s\n",
+ printf(" %11.3f %10" PRId64 " %s\n",
(cstats->count > 0) ?
1000.0 * cstats->sum / cstats->count : 0.0,
(*commands)->failures,
(*commands)->first_line);
else
- printf(" %11.3f %10" INT64_MODIFIER "d %10" INT64_MODIFIER "d %s\n",
+ printf(" %11.3f %10" PRId64 " %10" PRId64 " %s\n",
(cstats->count > 0) ?
1000.0 * cstats->sum / cstats->count : 0.0,
(*commands)->failures,
diff --git a/src/include/.gitignore b/src/include/.gitignore
index 51819fb4dd..6e99e82fe0 100644
--- a/src/include/.gitignore
+++ b/src/include/.gitignore
@@ -1,5 +1,3 @@
/stamp-h
-/stamp-ext-h
/pg_config.h
-/pg_config_ext.h
/pg_config_os.h
diff --git a/src/include/Makefile b/src/include/Makefile
index b8b576a4de..26332ff9cb 100644
--- a/src/include/Makefile
+++ b/src/include/Makefile
@@ -13,7 +13,7 @@ top_builddir = ../..
include $(top_builddir)/src/Makefile.global
-all: pg_config.h pg_config_ext.h pg_config_os.h
+all: pg_config.h pg_config_os.h
# Subdirectories containing installable headers
@@ -32,7 +32,6 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/postgres_ext.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/libpq/libpq-fs.h '$(DESTDIR)$(includedir)/libpq'
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir)'
- $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir)'
$(INSTALL_DATA) $(srcdir)/pg_config_manual.h '$(DESTDIR)$(includedir)'
# These headers are needed by the not-so-public headers of the interfaces.
@@ -43,7 +42,6 @@ install: all installdirs
$(INSTALL_DATA) $(srcdir)/libpq/protocol.h '$(DESTDIR)$(includedir_internal)/libpq'
# These headers are needed for server-side development
$(INSTALL_DATA) pg_config.h '$(DESTDIR)$(includedir_server)'
- $(INSTALL_DATA) pg_config_ext.h '$(DESTDIR)$(includedir_server)'
$(INSTALL_DATA) pg_config_os.h '$(DESTDIR)$(includedir_server)'
$(INSTALL_DATA) nodes/nodetags.h '$(DESTDIR)$(includedir_server)/nodes'
$(INSTALL_DATA) utils/errcodes.h '$(DESTDIR)$(includedir_server)/utils'
@@ -66,7 +64,7 @@ installdirs:
uninstall:
- rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_ext.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
+ rm -f $(addprefix '$(DESTDIR)$(includedir)'/, pg_config.h pg_config_os.h pg_config_manual.h postgres_ext.h libpq/libpq-fs.h)
rm -f $(addprefix '$(DESTDIR)$(includedir_internal)'/, c.h port.h postgres_fe.h libpq/pqcomm.h libpq/protocol.h)
# heuristic...
rm -rf $(addprefix '$(DESTDIR)$(includedir_server)'/, $(SUBDIRS) *.h)
@@ -80,4 +78,4 @@ clean:
$(MAKE) -C catalog clean
distclean: clean
- rm -f pg_config.h pg_config_ext.h pg_config_os.h stamp-h stamp-ext-h
+ rm -f pg_config.h pg_config_os.h stamp-h stamp-ext-h
diff --git a/src/include/c.h b/src/include/c.h
index dc1841346c..fd876c32af 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -48,14 +48,12 @@
#include "postgres_ext.h"
-/* Must undef pg_config_ext.h symbols before including pg_config.h */
-#undef PG_INT64_TYPE
-
#include "pg_config.h"
#include "pg_config_manual.h" /* must be after pg_config.h */
#include "pg_config_os.h" /* must be before any system header files */
/* System header files that should be available everywhere in Postgres */
+#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -489,10 +487,13 @@ typedef char *Pointer;
* frontend/backend protocol.
*/
#ifndef HAVE_INT8
-typedef signed char int8; /* == 8 bits */
-typedef signed short int16; /* == 16 bits */
-typedef signed int int32; /* == 32 bits */
+typedef int8_t int8; /* == 8 bits */
+typedef int16_t int16; /* == 16 bits */
+typedef int32_t int32; /* == 32 bits */
#endif /* not HAVE_INT8 */
+#ifndef HAVE_INT64
+typedef int64_t int64; /* == 64 bits */
+#endif /* not HAVE_INT64 */
/*
* uintN
@@ -501,10 +502,13 @@ typedef signed int int32; /* == 32 bits */
* frontend/backend protocol.
*/
#ifndef HAVE_UINT8
-typedef unsigned char uint8; /* == 8 bits */
-typedef unsigned short uint16; /* == 16 bits */
-typedef unsigned int uint32; /* == 32 bits */
+typedef uint8_t uint8; /* == 8 bits */
+typedef uint16_t uint16; /* == 16 bits */
+typedef uint32_t uint32; /* == 32 bits */
#endif /* not HAVE_UINT8 */
+#ifndef HAVE_UINT64
+typedef uint64_t uint64; /* == 64 bits */
+#endif /* not HAVE_UINT64 */
/*
* bitsN
@@ -517,36 +521,12 @@ typedef uint32 bits32; /* >= 32 bits */
/*
* 64-bit integers
*/
-#ifdef HAVE_LONG_INT_64
-/* Plain "long int" fits, use it */
-
-#ifndef HAVE_INT64
-typedef long int int64;
-#endif
-#ifndef HAVE_UINT64
-typedef unsigned long int uint64;
-#endif
-#define INT64CONST(x) (x##L)
-#define UINT64CONST(x) (x##UL)
-#elif defined(HAVE_LONG_LONG_INT_64)
-/* We have working support for "long long int", use that */
-
-#ifndef HAVE_INT64
-typedef long long int int64;
-#endif
-#ifndef HAVE_UINT64
-typedef unsigned long long int uint64;
-#endif
-#define INT64CONST(x) (x##LL)
-#define UINT64CONST(x) (x##ULL)
-#else
-/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
-#error must have a working 64-bit integer datatype
-#endif
+#define INT64CONST(x) INT64_C(x)
+#define UINT64CONST(x) UINT64_C(x)
/* snprintf format strings to use for 64-bit integers */
-#define INT64_FORMAT "%" INT64_MODIFIER "d"
-#define UINT64_FORMAT "%" INT64_MODIFIER "u"
+#define INT64_FORMAT "%" PRId64
+#define UINT64_FORMAT "%" PRIu64
/*
* 128-bit signed and unsigned integers
@@ -575,22 +555,19 @@ typedef unsigned PG_INT128_TYPE uint128
#endif
#endif
-/*
- * stdint.h limits aren't guaranteed to have compatible types with our fixed
- * width types. So just define our own.
- */
-#define PG_INT8_MIN (-0x7F-1)
-#define PG_INT8_MAX (0x7F)
-#define PG_UINT8_MAX (0xFF)
-#define PG_INT16_MIN (-0x7FFF-1)
-#define PG_INT16_MAX (0x7FFF)
-#define PG_UINT16_MAX (0xFFFF)
-#define PG_INT32_MIN (-0x7FFFFFFF-1)
-#define PG_INT32_MAX (0x7FFFFFFF)
-#define PG_UINT32_MAX (0xFFFFFFFFU)
-#define PG_INT64_MIN (-INT64CONST(0x7FFFFFFFFFFFFFFF) - 1)
-#define PG_INT64_MAX INT64CONST(0x7FFFFFFFFFFFFFFF)
-#define PG_UINT64_MAX UINT64CONST(0xFFFFFFFFFFFFFFFF)
+/* Historical names for limits in stdint.h. */
+#define PG_INT8_MIN INT8_MIN
+#define PG_INT8_MAX INT8_MAX
+#define PG_UINT8_MAX UINT8_MAX
+#define PG_INT16_MIN INT16_MIN
+#define PG_INT16_MAX INT16_MAX
+#define PG_UINT16_MAX UINT16_MAX
+#define PG_INT32_MIN INT32_MIN
+#define PG_INT32_MAX INT32_MAX
+#define PG_UINT32_MAX UINT32_MAX
+#define PG_INT64_MIN INT64_MIN
+#define PG_INT64_MAX INT64_MAX
+#define PG_UINT64_MAX UINT64_MAX
/*
* We now always use int64 timestamps, but keep this symbol defined for the
diff --git a/src/include/meson.build b/src/include/meson.build
index a28f115d86..6b9116341f 100644
--- a/src/include/meson.build
+++ b/src/include/meson.build
@@ -1,14 +1,5 @@
# Copyright (c) 2022-2024, PostgreSQL Global Development Group
-pg_config_ext = configure_file(
- input: 'pg_config_ext.h.meson',
- output: 'pg_config_ext.h',
- configuration: cdata,
- install: true,
- install_dir: dir_include,
-)
-configure_files += pg_config_ext
-
pg_config_os = configure_file(
output: 'pg_config_os.h',
input: files('port/@[email protected]'.format(portname)),
@@ -116,7 +107,6 @@ install_headers(
'postgres_fe.h',
'varatt.h',
'windowapi.h',
- pg_config_ext,
pg_config_os,
pg_config,
install_dir: dir_include_server,
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index f8d3e3b6b8..2791ec5fab 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -9,12 +9,12 @@
/* The normal alignment of `int', in bytes. */
#undef ALIGNOF_INT
+/* The normal alignment of `int64_t', in bytes. */
+#undef ALIGNOF_INT64_T
+
/* The normal alignment of `long', in bytes. */
#undef ALIGNOF_LONG
-/* The normal alignment of `long long int', in bytes. */
-#undef ALIGNOF_LONG_LONG_INT
-
/* The normal alignment of `PG_INT128_TYPE', in bytes. */
#undef ALIGNOF_PG_INT128_TYPE
@@ -282,12 +282,6 @@
/* Define to 1 if you have the `zstd' library (-lzstd). */
#undef HAVE_LIBZSTD
-/* Define to 1 if `long int' works and is 64 bits. */
-#undef HAVE_LONG_INT_64
-
-/* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
-
/* Define to 1 if you have the <mbarrier.h> header file. */
#undef HAVE_MBARRIER_H
@@ -570,9 +564,6 @@
/* Define to 1 if your compiler understands _Static_assert. */
#undef HAVE__STATIC_ASSERT
-/* Define to the appropriate printf length modifier for 64-bit ints. */
-#undef INT64_MODIFIER
-
/* Define to 1 if `locale_t' requires <xlocale.h>. */
#undef LOCALE_T_IN_XLOCALE
@@ -607,9 +598,6 @@
/* Define to the name of a signed 128-bit integer type. */
#undef PG_INT128_TYPE
-/* Define to the name of a signed 64-bit integer type. */
-#undef PG_INT64_TYPE
-
/* Define to the name of the default PostgreSQL service principal in Kerberos
(GSSAPI). (--with-krb-srvnam=NAME) */
#undef PG_KRB_SRVNAM
diff --git a/src/include/pg_config_ext.h.in b/src/include/pg_config_ext.h.in
deleted file mode 100644
index 8acadbdafd..0000000000
--- a/src/include/pg_config_ext.h.in
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * src/include/pg_config_ext.h.in. This is generated manually, not by
- * autoheader, since we want to limit which symbols get defined here.
- */
-
-/* Define to the name of a signed 64-bit integer type. */
-#undef PG_INT64_TYPE
diff --git a/src/include/pg_config_ext.h.meson b/src/include/pg_config_ext.h.meson
deleted file mode 100644
index 57cdfca0cf..0000000000
--- a/src/include/pg_config_ext.h.meson
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * src/include/pg_config_ext.h.in. This is generated manually, not by
- * autoheader, since we want to limit which symbols get defined here.
- */
-
-/* Define to the name of a signed 64-bit integer type. */
-#mesondefine PG_INT64_TYPE
diff --git a/src/include/port/pg_bitutils.h b/src/include/port/pg_bitutils.h
index 4d88478c9c..1c09bf0ff2 100644
--- a/src/include/port/pg_bitutils.h
+++ b/src/include/port/pg_bitutils.h
@@ -74,13 +74,12 @@ pg_leftmost_one_pos64(uint64 word)
#ifdef HAVE__BUILTIN_CLZ
Assert(word != 0);
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return 63 - __builtin_clzl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return 63 - __builtin_clzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return 63 - __builtin_clzll(word);
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
@@ -147,13 +146,12 @@ pg_rightmost_one_pos64(uint64 word)
#ifdef HAVE__BUILTIN_CTZ
Assert(word != 0);
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return __builtin_ctzl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return __builtin_ctzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return __builtin_ctzll(word);
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
diff --git a/src/include/postgres_ext.h b/src/include/postgres_ext.h
index 240ad4e93b..034056e7d9 100644
--- a/src/include/postgres_ext.h
+++ b/src/include/postgres_ext.h
@@ -23,7 +23,7 @@
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
-#include "pg_config_ext.h"
+#include <stdint.h>
/*
* Object ID is a fundamental type in Postgres.
@@ -36,15 +36,14 @@ typedef unsigned int Oid;
#define InvalidOid ((Oid) 0)
#endif
-#define OID_MAX UINT_MAX
-/* you will need to include <limits.h> to use the above #define */
+#define OID_MAX UINT32_MAX
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
/* the above needs <stdlib.h> */
/* Define a signed 64-bit integer type for use in client API declarations. */
-typedef PG_INT64_TYPE pg_int64;
+typedef int64_t pg_int64;
/*
* Identifiers of error message fields. Kept here to keep common
diff --git a/src/include/utils/dsa.h b/src/include/utils/dsa.h
index 8dff964bf3..6c952a43f7 100644
--- a/src/include/utils/dsa.h
+++ b/src/include/utils/dsa.h
@@ -66,7 +66,7 @@ typedef pg_atomic_uint64 dsa_pointer_atomic;
#define dsa_pointer_atomic_write pg_atomic_write_u64
#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u64
#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u64
-#define DSA_POINTER_FORMAT "%016" INT64_MODIFIER "x"
+#define DSA_POINTER_FORMAT "%016" PRIx64
#endif
/* Flags for dsa_allocate_extended. */
diff --git a/src/interfaces/ecpg/ecpglib/typename.c b/src/interfaces/ecpg/ecpglib/typename.c
index 1d482c4fa6..1ab2cda848 100644
--- a/src/interfaces/ecpg/ecpglib/typename.c
+++ b/src/interfaces/ecpg/ecpglib/typename.c
@@ -131,10 +131,9 @@ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
case INTERVALOID:
return ECPGt_interval;
case INT8OID:
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
return ECPGt_long_long;
-#endif
-#ifdef HAVE_LONG_INT_64
+#else
return ECPGt_long;
#endif
/* Unhandled types always return a string */
diff --git a/src/interfaces/ecpg/include/ecpg_config.h.in b/src/interfaces/ecpg/include/ecpg_config.h.in
index 5d0f448a86..48bce0878a 100644
--- a/src/interfaces/ecpg/include/ecpg_config.h.in
+++ b/src/interfaces/ecpg/include/ecpg_config.h.in
@@ -1,17 +1,5 @@
/* Define to 1 to build client libraries as thread-safe code. */
#define ENABLE_THREAD_SAFETY 1
-/* Define to 1 if the system has the type `int64'. */
-#undef HAVE_INT64
-
-/* Define to 1 if `long int' works and is 64 bits. */
-#undef HAVE_LONG_INT_64
-
-/* Define to 1 if the system has the type `long long int'. */
-#define HAVE_LONG_LONG_INT 1
-
-/* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
-
/* Define to 1 to use <stdbool.h> to define type bool. */
#undef PG_USE_STDBOOL
diff --git a/src/interfaces/ecpg/include/meson.build b/src/interfaces/ecpg/include/meson.build
index 31610fef58..d0234413fc 100644
--- a/src/interfaces/ecpg/include/meson.build
+++ b/src/interfaces/ecpg/include/meson.build
@@ -3,9 +3,6 @@
ecpg_inc = include_directories('.')
ecpg_conf_keys = [
- 'HAVE_INT64',
- 'HAVE_LONG_INT_64',
- 'HAVE_LONG_LONG_INT_64',
'PG_USE_STDBOOL',
]
diff --git a/src/interfaces/ecpg/include/pgtypes_interval.h b/src/interfaces/ecpg/include/pgtypes_interval.h
index 2809b356f7..d16f74970c 100644
--- a/src/interfaces/ecpg/include/pgtypes_interval.h
+++ b/src/interfaces/ecpg/include/pgtypes_interval.h
@@ -8,18 +8,7 @@
#ifndef C_H
-#ifdef HAVE_LONG_INT_64
-#ifndef HAVE_INT64
-typedef long int int64;
-#endif
-#elif defined(HAVE_LONG_LONG_INT_64)
-#ifndef HAVE_INT64
-typedef long long int int64;
-#endif
-#else
-/* neither HAVE_LONG_INT_64 nor HAVE_LONG_LONG_INT_64 */
-#error must have a working 64-bit integer datatype
-#endif
+typedef int64_t int64;
#define HAVE_INT64_TIMESTAMP
#endif /* C_H */
diff --git a/src/interfaces/ecpg/include/sqltypes.h b/src/interfaces/ecpg/include/sqltypes.h
index e7cbfa4795..aed055eb4a 100644
--- a/src/interfaces/ecpg/include/sqltypes.h
+++ b/src/interfaces/ecpg/include/sqltypes.h
@@ -46,7 +46,7 @@
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
diff --git a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
index 7e19319d27..02ec7b668d 100644
--- a/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
+++ b/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
@@ -97,7 +97,7 @@ typedef struct sqlda_struct sqlda_t;
#define SQLINTERVAL ECPGt_interval
#define SQLNCHAR ECPGt_char
#define SQLNVCHAR ECPGt_char
-#ifdef HAVE_LONG_LONG_INT_64
+#if SIZEOF_LONG < 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c
index 87f56e82b8..d4413a299a 100644
--- a/src/port/pg_bitutils.c
+++ b/src/port/pg_bitutils.c
@@ -370,12 +370,11 @@ static inline int
pg_popcount64_slow(uint64 word)
{
#ifdef HAVE__BUILTIN_POPCOUNT
-#if defined(HAVE_LONG_INT_64)
+#if SIZEOF_LONG == 8
return __builtin_popcountl(word);
-#elif defined(HAVE_LONG_LONG_INT_64)
- return __builtin_popcountll(word);
#else
-#error must have a working 64-bit integer datatype
+ StaticAssertStmt(sizeof(word) == sizeof(long long), "unexpected size");
+ return __builtin_popcountll(word);
#endif
#else /* !HAVE__BUILTIN_POPCOUNT */
int result = 0;
diff --git a/src/port/snprintf.c b/src/port/snprintf.c
index 884f0262dd..291148b4e8 100644
--- a/src/port/snprintf.c
+++ b/src/port/snprintf.c
@@ -568,12 +568,11 @@ nextch2:
goto nextch2;
case 'z':
#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
- longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
+ StaticAssertStmt(sizeof(size_t) == sizeof(long long), "unexpected size");
+ longlongflag = 1;
#endif
#else
/* assume size_t is same size as int */
@@ -835,12 +834,11 @@ nextch1:
goto nextch1;
case 'z':
#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
- longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
+ StaticAssertStmt(sizeof(size_t) == sizeof(long long), "unexpected size");
+ longlongflag = 1;
#endif
#else
/* assume size_t is same size as int */
diff --git a/src/test/modules/test_radixtree/test_radixtree.c b/src/test/modules/test_radixtree/test_radixtree.c
index d301c60d00..f8a80b1a8e 100644
--- a/src/test/modules/test_radixtree/test_radixtree.c
+++ b/src/test/modules/test_radixtree/test_radixtree.c
@@ -23,7 +23,7 @@
/* uncomment to use shared memory for the tree */
/* #define TEST_SHARED_RT */
-#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "X"
+#define UINT64_HEX_FORMAT "%" PRIX64
/* Convenient macros to test results */
#define EXPECT_TRUE(expr) \
--
2.39.3 (Apple Git-146)
[application/octet-stream] v2-0002-Remove-traces-of-BeOS.patch (4.2K, ../../CA+hUKGKXEdVSfR6UHXfR3tSQ+TfBNk-ssYmO2F0wCdw7qcx86Q@mail.gmail.com/3-v2-0002-Remove-traces-of-BeOS.patch)
download | inline diff:
From 74d09d7a3c91aef776df143407c4363c55939003 Mon Sep 17 00:00:00 2001
From: Thomas Munro <[email protected]>
Date: Thu, 18 Apr 2024 12:06:17 +1200
Subject: [PATCH v2 2/2] Remove traces of BeOS.
Commit 15abc7788e6 tolerated namespace pollution from BeOS system
headers. Commit 44f902122 de-supported BeOS. Since that stuff didn't
make it into the Meson build system, synchronize by removing from
configure.
---
configure | 44 --------------------------------------
configure.ac | 5 -----
src/include/c.h | 8 -------
src/include/pg_config.h.in | 12 -----------
4 files changed, 69 deletions(-)
diff --git a/configure b/configure
index 52b5f666ce..1a1fa7cbe2 100755
--- a/configure
+++ b/configure
@@ -16787,50 +16787,6 @@ cat >>confdefs.h <<_ACEOF
_ACEOF
-# Some platforms predefine the types int8, int16, etc. Only check
-# a (hopefully) representative subset.
-ac_fn_c_check_type "$LINENO" "int8" "ac_cv_type_int8" "#include <stdio.h>
-"
-if test "x$ac_cv_type_int8" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_INT8 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "uint8" "ac_cv_type_uint8" "#include <stdio.h>
-"
-if test "x$ac_cv_type_uint8" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_UINT8 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "int64" "ac_cv_type_int64" "#include <stdio.h>
-"
-if test "x$ac_cv_type_int64" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_INT64 1
-_ACEOF
-
-
-fi
-ac_fn_c_check_type "$LINENO" "uint64" "ac_cv_type_uint64" "#include <stdio.h>
-"
-if test "x$ac_cv_type_uint64" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_UINT64 1
-_ACEOF
-
-
-fi
-
-
# Some compilers offer a 128-bit integer scalar type.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __int128" >&5
$as_echo_n "checking for __int128... " >&6; }
diff --git a/configure.ac b/configure.ac
index 1c4cd3ab72..f5dc1b03a3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1988,11 +1988,6 @@ if test $ac_cv_alignof_int64_t -gt $MAX_ALIGNOF ; then
fi
AC_DEFINE_UNQUOTED(MAXIMUM_ALIGNOF, $MAX_ALIGNOF, [Define as the maximum alignment requirement of any C data type.])
-# Some platforms predefine the types int8, int16, etc. Only check
-# a (hopefully) representative subset.
-AC_CHECK_TYPES([int8, uint8, int64, uint64], [], [],
-[#include <stdio.h>])
-
# Some compilers offer a 128-bit integer scalar type.
PGAC_TYPE_128BIT_INT
diff --git a/src/include/c.h b/src/include/c.h
index fd876c32af..31a0400539 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -486,14 +486,10 @@ typedef char *Pointer;
* used for numerical computations and the
* frontend/backend protocol.
*/
-#ifndef HAVE_INT8
typedef int8_t int8; /* == 8 bits */
typedef int16_t int16; /* == 16 bits */
typedef int32_t int32; /* == 32 bits */
-#endif /* not HAVE_INT8 */
-#ifndef HAVE_INT64
typedef int64_t int64; /* == 64 bits */
-#endif /* not HAVE_INT64 */
/*
* uintN
@@ -501,14 +497,10 @@ typedef int64_t int64; /* == 64 bits */
* used for numerical computations and the
* frontend/backend protocol.
*/
-#ifndef HAVE_UINT8
typedef uint8_t uint8; /* == 8 bits */
typedef uint16_t uint16; /* == 16 bits */
typedef uint32_t uint32; /* == 32 bits */
-#endif /* not HAVE_UINT8 */
-#ifndef HAVE_UINT64
typedef uint64_t uint64; /* == 64 bits */
-#endif /* not HAVE_UINT64 */
/*
* bitsN
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 2791ec5fab..3a3caf9b0a 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -213,12 +213,6 @@
/* Define to 1 if you have the `inet_pton' function. */
#undef HAVE_INET_PTON
-/* Define to 1 if the system has the type `int64'. */
-#undef HAVE_INT64
-
-/* Define to 1 if the system has the type `int8'. */
-#undef HAVE_INT8
-
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
@@ -465,12 +459,6 @@
/* Define to 1 if you have the <ucred.h> header file. */
#undef HAVE_UCRED_H
-/* Define to 1 if the system has the type `uint64'. */
-#undef HAVE_UINT64
-
-/* Define to 1 if the system has the type `uint8'. */
-#undef HAVE_UINT8
-
/* Define to 1 if the system has the type `union semun'. */
#undef HAVE_UNION_SEMUN
--
2.39.3 (Apple Git-146)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 08:46 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
2024-04-18 20:29 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
@ 2024-07-02 13:34 ` Heikki Linnakangas <[email protected]>
0 siblings, 0 replies; 10+ messages in thread
From: Heikki Linnakangas @ 2024-07-02 13:34 UTC (permalink / raw)
To: Thomas Munro <[email protected]>; Peter Eisentraut <[email protected]>; +Cc: Tom Lane <[email protected]>; Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On 18/04/2024 23:29, Thomas Munro wrote:
> On Thu, Apr 18, 2024 at 8:47 PM Peter Eisentraut <[email protected]> wrote:
>> I'm not sure I understand the problem here. Do you mean that in theory
>> a platform's PRId64 could be something other than "l" or "ll"?
>
> Yes. I don't know why anyone would do that, and the systems I checked
> all have the obvious definitions, eg "ld", "lld" etc. Perhaps it's an
> acceptable risk? It certainly gives us a tidier result.
Could we have a configure check or static assertion for that?
> For discussion, here is a variant that fully embraces <inttypes.h> and
> the PRI*64 macros.
Looks good to me.
Personally, I find "PRId64" pretty unreadable. "INT64_MODIFIER" wasn't
nice either, though, and following standards is good, so I'm sure I'll
get used to it.
They're both less readable than INT64_FORMAT and "%lld", which we use in
most places, though. Perhaps "%lld" and casting the arguments to "long
long" would be more readable in the places where this patch replaces
INT64_MODIFIER with PRI*64, too.
--
Heikki Linnakangas
Neon (https://neon.tech)
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 08:46 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
@ 2024-04-18 21:00 ` Thomas Munro <[email protected]>
1 sibling, 0 replies; 10+ messages in thread
From: Thomas Munro @ 2024-04-18 21:00 UTC (permalink / raw)
To: Peter Eisentraut <[email protected]>; +Cc: Tom Lane <[email protected]>; Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On Thu, Apr 18, 2024 at 8:47 PM Peter Eisentraut <[email protected]> wrote:
> Maybe this means something like our int64 is long long int but the
> system's int64_t is long int underneath, but I don't see how that would
> matter for the limit macros.
Agreed, so I don't think it's long vs long long (when they have the same width).
I wonder if this comment is a clue:
static char *
inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size)
{
/*
* Note that int32_t and int16_t need only be "at least" large enough to
* contain a value of the specified size. On some systems, like Crays,
* there is no such thing as an integer variable with 16 bits. Keep this
* in mind if you think this function should have been coded to use
* pointer overlays. All the world's not a VAX.
*/
I'd seen that claim before somewhere else but I can't recall where.
So there were systems using those names in an ad hoc unspecified way
before C99 nailed this stuff down? In modern C, int32_t is definitely
an exact width type (but there are other standardised variants like
int_fast32_t to allow for Cray-like systems that would prefer to use a
wider type, ie "at least", 32 bits wide, so I guess that's what
happened to that idea?).
Or perhaps it's referring to worries about the width of char, short,
int or the assumption of two's-complement. I think if any of that
stuff weren't as assumed we'd have many problems in many places, so
I'm not seeing a problem. (FTR C23 finally nailed down
two's-complement as a requirement, and although C might not say so,
POSIX says that char is a byte, and our assumption that int = int32_t
is pretty deeply baked into PostgreSQL, so it's almost impossible to
imagine that short has a size other than 16 bits; but these are all
assumptions made by the OLD coding, not by the patch I posted). In
short, I guess that isn't what was meant.
^ permalink raw reply [nested|flat] 10+ messages in thread
* Re: Cannot find a working 64-bit integer type on Illumos
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
@ 2024-04-19 08:34 ` Peter Eisentraut <[email protected]>
2 siblings, 0 replies; 10+ messages in thread
From: Peter Eisentraut @ 2024-04-19 08:34 UTC (permalink / raw)
To: Thomas Munro <[email protected]>; Tom Lane <[email protected]>; +Cc: Japin Li <[email protected]>; Andres Freund <[email protected]>; PostgreSQL Hackers <[email protected]>
On 18.04.24 02:31, Thomas Munro wrote:
> For limits, why do we have this:
>
> - * stdint.h limits aren't guaranteed to have compatible types with our fixed
> - * width types. So just define our own.
>
> ? I mean, how could they not have compatible types?
The commit for this was 62e2a8dc2c7 and the thread was
<https://www.postgresql.org/message-id/flat/E1YatAv-0007cu-KW%40gemulon.postgresql.org;.
The problem was that something like
snprintf(bufm, sizeof(bufm), INT64_FORMAT, SEQ_MINVALUE);
could issue a warning if, say, INT64_FORMAT, which refers to our own
int64, is based on long int, but SEQ_MINVALUE, which was then INT64_MIN,
which refers to int64_t, which could be long long int.
So this is correct. If we introduce the use of int64_t, then you need
to be consistent still:
int64, PG_INT64_MIN, PG_INT64_MAX, INT64_FORMAT
int64_t, INT64_MIN, INT64_MAX, PRId64
^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2024-07-02 13:34 UTC | newest]
Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 02:01 [PATCH v30 6/6] Doc: Add Collation Versions section. Thomas Munro <[email protected]>
2024-04-18 00:31 Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-18 06:07 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
2024-04-18 21:22 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-19 05:25 ` Re: Cannot find a working 64-bit integer type on Illumos Japin Li <[email protected]>
2024-04-18 08:46 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
2024-04-18 20:29 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-07-02 13:34 ` Re: Cannot find a working 64-bit integer type on Illumos Heikki Linnakangas <[email protected]>
2024-04-18 21:00 ` Re: Cannot find a working 64-bit integer type on Illumos Thomas Munro <[email protected]>
2024-04-19 08:34 ` Re: Cannot find a working 64-bit integer type on Illumos Peter Eisentraut <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox