From: Daniele Varrazzo Date: Fri, 9 May 2025 13:00:34 +0000 (+0200) Subject: fix: fix building with PostgreSQL v18 libpq X-Git-Tag: 3.2.8~11^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23e72941ff560f75e398975daee28f3e7db9b37c;p=thirdparty%2Fpsycopg.git fix: fix building with PostgreSQL v18 libpq Use 64 bits support from C99 types. Fix #1082 --- diff --git a/docs/news.rst b/docs/news.rst index e253078ff..151e8114d 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -26,6 +26,7 @@ Psycopg 3.2.8 (unreleased) returns `None` (:ticket:`#1073`). - Fix `ConnectionInfo.port` when the port is specified as an empty string (:ticket:`#1078`). +- Add support for PostgreSQL 18 libpq (:ticket:`#1082`). Current release diff --git a/psycopg_c/psycopg_c/types/numutils.c b/psycopg_c/psycopg_c/types/numutils.c index 4be7108bb..2be6b3973 100644 --- a/psycopg_c/psycopg_c/types/numutils.c +++ b/psycopg_c/psycopg_c/types/numutils.c @@ -15,32 +15,10 @@ /* * 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 +typedef uint64_t uint64; +typedef int64_t int64; + +#define UINT64CONST(x) UINT64_C(x) #ifndef HAVE__BUILTIN_CLZ @@ -90,13 +68,15 @@ static inline int pg_leftmost_one_pos64(uint64_t word) { #ifdef HAVE__BUILTIN_CLZ -#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 +#error "cannot find integer type of the same size as uint64_t" #endif + #else /* !HAVE__BUILTIN_CLZ */ int shift = 64 - 8;