]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: fix building with PostgreSQL v18 libpq
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 9 May 2025 13:00:34 +0000 (15:00 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 9 May 2025 14:40:44 +0000 (16:40 +0200)
Use 64 bits support from C99 types.

Fix #1082

docs/news.rst
psycopg_c/psycopg_c/types/numutils.c

index e253078ffd8522f174b3104fd17d0f35732848ac..151e8114d7efbd86d5e88e36f1cd1164feb8e9d0 100644 (file)
@@ -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
index 4be7108bba0aedf6a8affd7e46e35b6d4f5f04ac..2be6b3973299f17a97e6911c84578d5b3dc2c944 100644 (file)
 /*
  * 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;