])# PGAC_TEST_PRINTF_ARCHETYPE
-# PGAC_TYPE_64BIT_INT(TYPE)
-# -------------------------
-# Check if TYPE is a working 64 bit integer type. Set HAVE_TYPE_64 to
-# yes or no respectively, and define HAVE_TYPE_64 if yes.
-AC_DEFUN([PGAC_TYPE_64BIT_INT],
-[define([Ac_define], [translit([have_$1_64], [a-z *], [A-Z_P])])dnl
-define([Ac_cachevar], [translit([pgac_cv_type_$1_64], [ *], [_p])])dnl
-AC_CACHE_CHECK([whether $1 is 64 bits], [Ac_cachevar],
-[AC_RUN_IFELSE([AC_LANG_SOURCE(
-[typedef $1 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());
-}])],
-[Ac_cachevar=yes],
-[Ac_cachevar=no],
-[# If cross-compiling, check the size reported by the compiler and
-# trust that the arithmetic works.
-AC_COMPILE_IFELSE([AC_LANG_BOOL_COMPILE_TRY([], [sizeof($1) == 8])],
- Ac_cachevar=yes,
- Ac_cachevar=no)])])
-
-Ac_define=$Ac_cachevar
-if test x"$Ac_cachevar" = xyes ; then
- AC_DEFINE(Ac_define, 1, [Define to 1 if `]$1[' works and is 64 bits.])
-fi
-undefine([Ac_define])dnl
-undefine([Ac_cachevar])dnl
-])# PGAC_TYPE_64BIT_INT
-
-
# PGAC_TYPE_128BIT_INT
# --------------------
# Check if __int128 is a working 128 bit integer type, and if so
AC_DEFUN([PGAC_C_BUILTIN_OP_OVERFLOW],
[AC_CACHE_CHECK(for __builtin_mul_overflow, pgac_cv__builtin_op_overflow,
[AC_LINK_IFELSE([AC_LANG_PROGRAM([
-PG_INT64_TYPE a = 1;
-PG_INT64_TYPE b = 1;
-PG_INT64_TYPE result;
+#include <stdint.h>
+int64_t a = 1;
+int64_t b = 1;
+int64_t result;
int oflo;
],
[oflo = __builtin_mul_overflow(a, b, &result);])],
# types, and define HAVE_GCC__SYNC_INT64_CAS if so.
AC_DEFUN([PGAC_HAVE_GCC__SYNC_INT64_CAS],
[AC_CACHE_CHECK(for builtin __sync int64 atomic operations, pgac_cv_gcc_sync_int64_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
- [PG_INT64_TYPE lock = 0;
- __sync_val_compare_and_swap(&lock, 0, (PG_INT64_TYPE) 37);])],
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
+ [int64_t lock = 0;
+ __sync_val_compare_and_swap(&lock, 0, (int64_t) 37);])],
[pgac_cv_gcc_sync_int64_cas="yes"],
[pgac_cv_gcc_sync_int64_cas="no"])])
if test x"$pgac_cv_gcc_sync_int64_cas" = x"yes"; then
- AC_DEFINE(HAVE_GCC__SYNC_INT64_CAS, 1, [Define to 1 if you have __sync_val_compare_and_swap(int64 *, int64, int64).])
+ AC_DEFINE(HAVE_GCC__SYNC_INT64_CAS, 1, [Define to 1 if you have __sync_val_compare_and_swap(int64_t *, int64_t, int64_t).])
fi])# PGAC_HAVE_GCC__SYNC_INT64_CAS
# PGAC_HAVE_GCC__ATOMIC_INT32_CAS
# types, and define HAVE_GCC__ATOMIC_INT64_CAS if so.
AC_DEFUN([PGAC_HAVE_GCC__ATOMIC_INT64_CAS],
[AC_CACHE_CHECK(for builtin __atomic int64 atomic operations, pgac_cv_gcc_atomic_int64_cas,
-[AC_LINK_IFELSE([AC_LANG_PROGRAM([],
- [PG_INT64_TYPE val = 0;
- PG_INT64_TYPE expect = 0;
+[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>],
+ [int64_t val = 0;
+ int64_t expect = 0;
__atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);])],
[pgac_cv_gcc_atomic_int64_cas="yes"],
[pgac_cv_gcc_atomic_int64_cas="no"])])
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_avx512_popcnt_intrinsics])])dnl
AC_CACHE_CHECK([for _mm512_popcnt_epi64], [Ac_cachevar],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <immintrin.h>
+ #include <stdint.h>
#if defined(__has_attribute) && __has_attribute (target)
__attribute__((target("avx512vpopcntdq,avx512bw")))
#endif
static int popcount_test(void)
{
const char buf@<:@sizeof(__m512i)@:>@;
- PG_INT64_TYPE 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);
$as_echo "#define HAVE__BUILTIN_CONSTANT_P 1" >>confdefs.h
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_mul_overflow" >&5
+$as_echo_n "checking for __builtin_mul_overflow... " >&6; }
+if ${pgac_cv__builtin_op_overflow+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+#include <stdint.h>
+int64_t a = 1;
+int64_t b = 1;
+int64_t result;
+int oflo;
+
+int
+main ()
+{
+oflo = __builtin_mul_overflow(a, b, &result);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ pgac_cv__builtin_op_overflow=yes
+else
+ pgac_cv__builtin_op_overflow=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_op_overflow" >&5
+$as_echo "$pgac_cv__builtin_op_overflow" >&6; }
+if test x"$pgac_cv__builtin_op_overflow" = xyes ; then
+
+$as_echo "#define HAVE__BUILTIN_OP_OVERFLOW 1" >>confdefs.h
+
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_unreachable" >&5
$as_echo_n "checking for __builtin_unreachable... " >&6; }
# 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
-$as_echo_n "checking for __builtin_mul_overflow... " >&6; }
-if ${pgac_cv__builtin_op_overflow+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h. */
-
-PG_INT64_TYPE a = 1;
-PG_INT64_TYPE b = 1;
-PG_INT64_TYPE result;
-int oflo;
-
-int
-main ()
-{
-oflo = __builtin_mul_overflow(a, b, &result);
- ;
- return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
- pgac_cv__builtin_op_overflow=yes
-else
- pgac_cv__builtin_op_overflow=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
- conftest$ac_exeext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__builtin_op_overflow" >&5
-$as_echo "$pgac_cv__builtin_op_overflow" >&6; }
-if test x"$pgac_cv__builtin_op_overflow" = xyes ; then
-
-$as_echo "#define HAVE__BUILTIN_OP_OVERFLOW 1" >>confdefs.h
-
-fi
-
# Check size of void *, size_t (enables tweaks for > 32bit address space)
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
_ACEOF
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long long" >&5
+$as_echo_n "checking size of long long... " >&6; }
+if ${ac_cv_sizeof_long_long+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long long))" "ac_cv_sizeof_long_long" "$ac_includes_default"; then :
+
+else
+ if test "$ac_cv_type_long_long" = 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 sizeof (long long)
+See \`config.log' for more details" "$LINENO" 5; }
+ else
+ ac_cv_sizeof_long_long=0
+ fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_long" >&5
+$as_echo "$ac_cv_sizeof_long_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_LONG $ac_cv_sizeof_long_long
+_ACEOF
+
+
# Determine memory alignment requirements for the basic C data types.
_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
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
_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; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
+#include <stdint.h>
int
main ()
{
-PG_INT64_TYPE lock = 0;
- __sync_val_compare_and_swap(&lock, 0, (PG_INT64_TYPE) 37);
+int64_t lock = 0;
+ __sync_val_compare_and_swap(&lock, 0, (int64_t) 37);
;
return 0;
}
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
+#include <stdint.h>
int
main ()
{
-PG_INT64_TYPE val = 0;
- PG_INT64_TYPE expect = 0;
+int64_t val = 0;
+ int64_t expect = 0;
__atomic_compare_exchange_n(&val, &expect, 37, 0, __ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
;
return 0;
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <immintrin.h>
+ #include <stdint.h>
#if defined(__has_attribute) && __has_attribute (target)
__attribute__((target("avx512vpopcntdq,avx512bw")))
#endif
static int popcount_test(void)
{
const char buf[sizeof(__m512i)];
- PG_INT64_TYPE 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);
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"
"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;;
"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 ;;
PGAC_C_TYPEOF
PGAC_C_TYPES_COMPATIBLE
PGAC_C_BUILTIN_CONSTANT_P
+PGAC_C_BUILTIN_OP_OVERFLOW
PGAC_C_BUILTIN_UNREACHABLE
PGAC_C_COMPUTED_GOTO
PGAC_STRUCT_TIMEZONE
# 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
-
# Check size of void *, size_t (enables tweaks for > 32bit address space)
AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([size_t])
AC_CHECK_SIZEOF([long])
+AC_CHECK_SIZEOF([long long])
# Determine memory alignment requirements for the basic C data types.
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.
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 compilers offer a 128-bit integer scalar type.
PGAC_TYPE_128BIT_INT
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])
endif
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)
endif
# of MAXIMUM_ALIGNOF to avoid that, but we no longer support any platforms
# where TYPALIGN_DOUBLE != MAXIMUM_ALIGNOF.
#
-# We assume without checking that int64's alignment is at least as strong
+# We assume without checking that int64_t's alignment is at least as strong
# as long, char, short, or int. Note that we intentionally do not consider
# 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)
+cdata.set('SIZEOF_LONG', cc.sizeof('long', args: test_c_args))
+cdata.set('SIZEOF_LONG_LONG', cc.sizeof('long long', args: test_c_args))
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))
# 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
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
prog = '''
#include <immintrin.h>
+#include <stdint.h>
#if defined(__has_attribute) && __has_attribute (target)
__attribute__((target("avx512vpopcntdq,avx512bw")))
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);
}
'''
- if cc.links(prog, name: 'AVX-512 popcount',
- args: test_c_args + ['-DINT64=@0@'.format(cdata.get('PG_INT64_TYPE'))])
+ if cc.links(prog, name: 'AVX-512 popcount', args: test_c_args)
cdata.set('USE_AVX512_POPCNT_WITH_RUNTIME_CHECK', 1)
endif
$(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 ;
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);
}
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),
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,
/stamp-h
-/stamp-ext-h
/pg_config.h
-/pg_config_ext.h
/pg_config_os.h
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
$(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.
$(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'
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)
$(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
#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>
*/
typedef char *Pointer;
-/*
- * intN
- * Signed integer, EXACTLY N BITS IN SIZE,
- * used for numerical computations and the
- * frontend/backend protocol.
- */
-typedef signed char int8; /* == 8 bits */
-typedef signed short int16; /* == 16 bits */
-typedef signed int int32; /* == 32 bits */
-
-/*
- * uintN
- * Unsigned integer, EXACTLY N BITS IN SIZE,
- * used for numerical computations and the
- * frontend/backend protocol.
- */
-typedef unsigned char uint8; /* == 8 bits */
-typedef unsigned short uint16; /* == 16 bits */
-typedef unsigned int uint32; /* == 32 bits */
+/* Historical names for types in <stdint.h>. */
+typedef int8_t int8;
+typedef int16_t int16;
+typedef int32_t int32;
+typedef int64_t int64;
+typedef uint8_t uint8;
+typedef uint16_t uint16;
+typedef uint32_t uint32;
+typedef uint64_t uint64;
/*
* bitsN
/*
* 64-bit integers
*/
-#ifdef HAVE_LONG_INT_64
-/* Plain "long int" fits, use it */
-
-typedef long int int64;
-typedef unsigned long int uint64;
-#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 */
-
-typedef long long int int64;
-typedef unsigned long long int uint64;
-#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_HEX_FORMAT "%" INT64_MODIFIER "x"
-#define UINT64_HEX_FORMAT "%" INT64_MODIFIER "x"
+#define INT64_FORMAT "%" PRId64
+#define UINT64_FORMAT "%" PRIu64
+#define INT64_HEX_FORMAT "%" PRIx64
+#define UINT64_HEX_FORMAT "%" PRIx64
/*
* 128-bit signed and unsigned integers
#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
* definition of int64. (For the naming, compare that POSIX has
* strtoimax()/strtoumax() which return intmax_t/uintmax_t.)
*/
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
#define strtoi64(str, endptr, base) ((int64) strtol(str, endptr, base))
#define strtou64(str, endptr, base) ((uint64) strtoul(str, endptr, base))
-#else
+#elif SIZEOF_LONG_LONG == 8
#define strtoi64(str, endptr, base) ((int64) strtoll(str, endptr, base))
#define strtou64(str, endptr, base) ((uint64) strtoull(str, endptr, base))
+#else
+#error "cannot find integer type of the same size as int64_t"
#endif
/*
* Similarly, wrappers around labs()/llabs() matching our int64.
*/
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
#define i64abs(i) labs(i)
-#else
+#elif SIZEOF_LONG_LONG == 8
#define i64abs(i) llabs(i)
+#else
+#error "cannot find integer type of the same size as int64_t"
#endif
/*
# 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/@0@.h'.format(portname)),
'postgres_fe.h',
'varatt.h',
'windowapi.h',
- pg_config_ext,
pg_config_os,
pg_config,
install_dir: dir_include_server,
)
# autoconf generates the file there, ensure we get a conflict
-generated_sources_ac += {'src/include': ['stamp-h', 'stamp-ext-h']}
+generated_sources_ac += {'src/include': ['stamp-h']}
/* 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
/* Define to 1 if you have __sync_lock_test_and_set(int *) and friends. */
#undef HAVE_GCC__SYNC_INT32_TAS
-/* Define to 1 if you have __sync_val_compare_and_swap(int64 *, int64, int64).
- */
+/* Define to 1 if you have __sync_val_compare_and_swap(int64_t *, int64_t,
+ int64_t). */
#undef HAVE_GCC__SYNC_INT64_CAS
/* Define to 1 if you have the `getauxval' function. */
/* 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
/* 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 as the maximum alignment requirement of any C data type. */
#undef MAXIMUM_ALIGNOF
/* 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
/* The size of `long', as computed by sizeof. */
#undef SIZEOF_LONG
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
+
/* The size of `off_t', as computed by sizeof. */
#undef SIZEOF_OFF_T
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
#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)
+#elif SIZEOF_LONG_LONG == 8
return 63 - __builtin_clzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+#error "cannot find integer type of the same size as uint64_t"
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
#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)
+#elif SIZEOF_LONG_LONG == 8
return __builtin_ctzll(word);
#else
-#error must have a working 64-bit integer datatype
-#endif /* HAVE_LONG_INT_64 */
+#error "cannot find integer type of the same size as uint64_t"
+#endif
#elif defined(_MSC_VER) && (defined(_M_AMD64) || defined(_M_ARM64))
unsigned long result;
#ifndef POSTGRES_EXT_H
#define POSTGRES_EXT_H
-#include "pg_config_ext.h"
+#include <stdint.h>
/*
* Object ID is a fundamental type in Postgres.
/* 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
#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. */
case INTERVALOID:
return ECPGt_interval;
case INT8OID:
-#ifdef HAVE_LONG_LONG_INT_64
- return ECPGt_long_long;
-#endif
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_LONG == 8
return ECPGt_long;
+#elif SIZEOF_LONG_LONG == 8
+ return ECPGt_long_long;
+#else
+#error "cannot find integer type of the same size as INT8OID"
#endif
/* Unhandled types always return a string */
default:
/* Define to 1 to build client libraries as thread-safe code. */
#define ENABLE_THREAD_SAFETY 1
-/* Define to 1 if `long int' works and is 64 bits. */
-#undef HAVE_LONG_INT_64
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
-/* Define to 1 if `long long int' works and is 64 bits. */
-#undef HAVE_LONG_LONG_INT_64
+/* The size of `long long', as computed by sizeof. */
+#undef SIZEOF_LONG_LONG
ecpg_inc = include_directories('.')
ecpg_conf_keys = [
- 'HAVE_LONG_INT_64',
- 'HAVE_LONG_LONG_INT_64',
+ 'SIZEOF_LONG',
+ 'SIZEOF_LONG_LONG',
]
ecpg_conf_data = configuration_data()
#ifndef PGTYPES_INTERVAL
#define PGTYPES_INTERVAL
+#include <stdint.h>
+
#include <ecpg_config.h>
#include <pgtypes.h>
#ifndef C_H
-#ifdef HAVE_LONG_INT_64
-typedef long int int64;
-#elif defined(HAVE_LONG_LONG_INT_64)
-typedef long long int int64;
-#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 */
typedef struct
#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
+#define SQLSERIAL8 ECPGt_long
+#elif SIZEOF_LONG_LONG == 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
-#define SQLINT8 ECPGt_long
-#define SQLSERIAL8 ECPGt_long
+#error "cannot find integer type of the same size as SQLINT8"
#endif
#endif /* ndef ECPG_SQLTYPES_H */
#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
+#define SQLSERIAL8 ECPGt_long
+#elif SIZEOF_LONG_LONG == 8
#define SQLINT8 ECPGt_long_long
#define SQLSERIAL8 ECPGt_long_long
#else
-#define SQLINT8 ECPGt_long
-#define SQLSERIAL8 ECPGt_long
+#error "cannot find integer type of the same size as SQLINT8"
#endif
#endif /* ndef ECPG_SQLTYPES_H */
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)
+#elif SIZEOF_LONG_LONG == 8
return __builtin_popcountll(word);
#else
-#error must have a working 64-bit integer datatype
+#error "cannot find integer of the same size as uint64_t"
#endif
#else /* !HAVE__BUILTIN_POPCOUNT */
int result = 0;
fmtpos = accum;
accum = 0;
goto nextch2;
+#ifdef WIN32
+ case 'I':
+ /* Windows PRI*{32,64,PTR} size */
+ if (format[0] == '3' && format[1] == '2')
+ format += 2;
+ else if (format[0] == '6' && format[1] == '4')
+ {
+ format += 2;
+ longlongflag = 1;
+ }
+ else
+ {
+#if SIZEOF_VOID_P == SIZEOF_LONG
+ longflag = 1;
+#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
+ longlongflag = 1;
+#else
+#error "cannot find integer type of the same size as intptr_t"
+#endif
+ }
+ goto nextch2;
+#endif
case 'l':
if (longflag)
longlongflag = 1;
longflag = 1;
goto nextch2;
case 'z':
-#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_SIZE_T == SIZEOF_LONG
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
+#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
-#endif
-#else
- /* assume size_t is same size as int */
+#error "cannot find integer type of the same size as size_t"
#endif
goto nextch2;
case 'h':
fmtpos = accum;
accum = 0;
goto nextch1;
+#ifdef WIN32
+ case 'I':
+ /* Windows PRI*{32,64,PTR} size */
+ if (format[0] == '3' && format[1] == '2')
+ format += 2;
+ else if (format[0] == '6' && format[1] == '4')
+ {
+ format += 2;
+ longlongflag = 1;
+ }
+ else
+ {
+#if SIZEOF_VOID_P == SIZEOF_LONG
+ longflag = 1;
+#elif SIZEOF_VOID_P == SIZEOF_LONG_LONG
+ longlongflag = 1;
+#else
+#error "cannot find integer type of the same size as intptr_t"
+#endif
+ }
+ goto nextch1;
+#endif
case 'l':
if (longflag)
longlongflag = 1;
longflag = 1;
goto nextch1;
case 'z':
-#if SIZEOF_SIZE_T == 8
-#ifdef HAVE_LONG_INT_64
+#if SIZEOF_SIZE_T == SIZEOF_LONG
longflag = 1;
-#elif defined(HAVE_LONG_LONG_INT_64)
+#elif SIZEOF_SIZE_T == SIZEOF_LONG_LONG
longlongflag = 1;
#else
-#error "Don't know how to print 64bit integers"
-#endif
-#else
- /* assume size_t is same size as int */
+#error "cannot find integer type of the same size as size_t"
#endif
goto nextch1;
case 'h':