pgpool2: Define SIZEOF_LONG and SIZEOF_LONG_LONG

When cross compiling for a 32-bit target such as riscv32, configure
cannot test the long long snprintf format and builds the replacement
snprintf(), which fails because SIZEOF_LONG and SIZEOF_LONG_LONG are
never defined:

  snprintf.c:651:2: error: "cannot find integer type of the same size as size_t"

Add a patch that checks the size of long and long long in configure.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-10-21 08:52:53 -07:00
1 parent 8b9d954126
commit 63c3072f5f
2 files changed
+40

No files matched your search

@@ -0,0 +1,39 @@
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Wed, 21 Oct 2026 01:00:00 -0700
Subject: [PATCH] configure: Check the size of long and long long
The replacement snprintf() in src/parser/snprintf.c handles the %z
length modifier by comparing SIZEOF_SIZE_T with SIZEOF_LONG and
SIZEOF_LONG_LONG, but configure only defines SIZEOF_UNSIGNED_LONG,
SIZEOF_VOID_P and SIZEOF_SIZE_T. The undefined macros evaluate to 0 in
the #if, so whenever the replacement snprintf() is built it fails with
snprintf.c:651:2: error: "cannot find integer type of the same size as size_t"
This happens e.g. when cross compiling for a 32-bit target such as
riscv32, where configure cannot run its long long snprintf format test
and falls back to the replacement implementation.
Check the size of long and long long so these are defined on every
target.
Upstream-Status: Submitted [https://www.postgresql.org/message-id/20261021153104.43840-1-khem.raj%40oss.qualcomm.com]
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
configure.ac | 5 +++++
1 file changed, 5 insertions(+)
--- a/configure.ac
+++ b/configure.ac
@@ -211,6 +211,11 @@
AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([size_t])
+# The replacement snprintf() compares SIZEOF_SIZE_T against these to handle
+# the %z length modifier
+AC_CHECK_SIZEOF([long])
+AC_CHECK_SIZEOF([long long])
+
# Decide whether float4 is passed by value: user-selectable, enabled by default
AC_MSG_CHECKING([whether to build with float4 passed by value])
PGAC_ARG_BOOL(enable, float4-byval, yes, [disable float4 passed by value],
@@ -13,6 +13,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=e4b38de086d73e0521de0bbdbaa4a1a9"
SRC_URI = "https://www.pgpool.net/source/pgpool-II-${PV}.tar.gz \
file://0001-Fix-build-error-when-build-this-file.patch \
file://define_SIGNAL_ARGS.patch \
file://0002-configure-Check-the-size-of-long-and-long-long.patch \
file://pgpool.sysconfig \
file://pgpool.service \
"