Make sure IOV_MAX is defined.
authorTom Lane
Tue, 1 Jul 2025 16:40:35 +0000 (12:40 -0400)
committerTom Lane
Tue, 1 Jul 2025 16:40:35 +0000 (12:40 -0400)
We stopped defining IOV_MAX on non-Windows systems in 75357ab94, on
the assumption that every non-Windows system defines it in 
as required by X/Open.  GNU Hurd, however, doesn't follow that
standard either.  Put back the old logic to assume 16 if it's
not defined.

Author: Michael Banck 
Co-authored-by: Christoph Berg
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/6862e8d1.050a0220[email protected]
Discussion: https://postgr.es/m/6846e0c3.df0a0220[email protected]
Backpatch-through: 16

src/include/port/pg_iovec.h

index df40c7208be48137f7a07b286f1c9fa9778a5aa1..90be3af449d6fe679d4ea05e83596a6e46ade8fe 100644 (file)
@@ -21,9 +21,6 @@
 
 #else
 
-/* POSIX requires at least 16 as a maximum iovcnt. */
-#define IOV_MAX 16
-
 /* Define our own POSIX-compatible iovec struct. */
 struct iovec
 {
@@ -33,6 +30,15 @@ struct iovec
 
 #endif
 
+/*
+ * If  didn't define IOV_MAX, define our own.  X/Open requires at
+ * least 16.  (GNU Hurd apparently feel that they're not bound by X/Open,
+ * because they don't define this symbol at all.)
+ */
+#ifndef IOV_MAX
+#define IOV_MAX 16
+#endif
+
 /*
  * Define a reasonable maximum that is safe to use on the stack in arrays of
  * struct iovec and other small types.  The operating system could limit us to