mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Use <stdint.h> and <inttypes.h> for c.h integers.
Redefine our exact width types with standard C99 types and macros, including int64_t, INT64_MAX, INT64_C(), PRId64 etc. We were already using <stdint.h> types in a few places. One complication is that Windows' <inttypes.h> uses format strings like "%I64d", "%I32", "%I" for PRI*64, PRI*32, PTR*PTR, instead of mapping to other standardized format strings like "%lld" etc as seen on other known systems. Teach our snprintf.c to understand them. This removes a lot of configure clutter, and should also allow 64-bit numbers and other standard types to be used in localized messages without casting. Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/ME3P282MB3166F9D1F71F787929C0C7E7B6312%40ME3P282MB3166.AUSP282.PROD.OUTLOOK.COM
This commit is contained in:
@@ -840,12 +840,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 ;
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -6568,13 +6568,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,
|
||||
|
||||
2
src/include/.gitignore
vendored
2
src/include/.gitignore
vendored
@@ -1,5 +1,3 @@
|
||||
/stamp-h
|
||||
/stamp-ext-h
|
||||
/pg_config.h
|
||||
/pg_config_ext.h
|
||||
/pg_config_os.h
|
||||
|
||||
@@ -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
|
||||
|
||||
101
src/include/c.h
101
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>
|
||||
@@ -471,25 +469,15 @@ typedef void (*pg_funcptr_t) (void);
|
||||
*/
|
||||
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
|
||||
@@ -502,30 +490,14 @@ typedef uint32 bits32; /* >= 32 bits */
|
||||
/*
|
||||
* 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
|
||||
@@ -554,22 +526,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
|
||||
@@ -1272,21 +1241,25 @@ extern int fdatasync(int fildes);
|
||||
* 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
|
||||
|
||||
/*
|
||||
|
||||
@@ -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/@0@.h'.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,
|
||||
@@ -186,4 +176,4 @@ install_subdir('catalog',
|
||||
)
|
||||
|
||||
# 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']}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -153,8 +153,8 @@
|
||||
/* 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. */
|
||||
@@ -265,12 +265,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
|
||||
|
||||
@@ -544,9 +538,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 as the maximum alignment requirement of any C data type. */
|
||||
#undef MAXIMUM_ALIGNOF
|
||||
|
||||
@@ -578,9 +569,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
|
||||
@@ -630,6 +618,9 @@
|
||||
/* 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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -74,13 +74,13 @@ 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)
|
||||
#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;
|
||||
@@ -147,13 +147,13 @@ 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)
|
||||
#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;
|
||||
|
||||
@@ -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.
|
||||
@@ -44,7 +44,7 @@ typedef unsigned int Oid;
|
||||
|
||||
|
||||
/* 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
|
||||
|
||||
@@ -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. */
|
||||
|
||||
@@ -131,11 +131,12 @@ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
|
||||
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:
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* 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
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
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()
|
||||
|
||||
@@ -3,21 +3,17 @@
|
||||
#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
|
||||
|
||||
@@ -46,12 +46,14 @@
|
||||
#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 */
|
||||
|
||||
@@ -97,12 +97,14 @@ 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
|
||||
#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 */
|
||||
|
||||
@@ -370,12 +370,12 @@ 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)
|
||||
#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;
|
||||
|
||||
@@ -560,6 +560,28 @@ nextch2:
|
||||
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;
|
||||
@@ -567,16 +589,12 @@ nextch2:
|
||||
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':
|
||||
@@ -827,6 +845,28 @@ nextch1:
|
||||
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;
|
||||
@@ -834,16 +874,12 @@ nextch1:
|
||||
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':
|
||||
|
||||
Reference in New Issue
Block a user