From 3f4b1715239022d89c792d823026fef51fc9e459 Mon Sep 17 00:00:00 2001
From: Gerhard Rieger <gerhard@dest-unreach.org>
Date: Sat, 11 Jan 2025 18:48:58 +0100
Subject: [PATCH] Fixed flock() on AIX, Solaris

---
 CHANGES   | 3 +++
 xioopts.c | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/CHANGES b/CHANGES
index 66c0c65..5fb94ee 100644
--- a/CHANGES
+++ b/CHANGES
@@ -76,6 +76,9 @@ Porting:
 
 	Fixes for old Scientific/RHEL
 
+	Socat failed to build on platforms without flock() function (AIX,
+	Solaris) due to a missing guard.
+
 Testing:
 	test.sh produces file results.txt with columns of test numbers, names,
 	and results.
diff --git a/xioopts.c b/xioopts.c
index 3781529..d36179c 100644
--- a/xioopts.c
+++ b/xioopts.c
@@ -3837,6 +3837,7 @@ int applyopt_sockopt_generic(
 
 #endif /* _WITH_SOCKET */
 
+#if HAVE_FLOCK
 int applyopt_flock(
 	int fd,
 	struct opt *opt)
@@ -3848,6 +3849,7 @@ int applyopt_flock(
 	}
 	return 0;
 }
+#endif /* defined(HAVE_FLOCK) */
 
 /* Applies an option that needs handling specific to its OPT_* setting.
    Does not overwrite the option instance with ODESC_DONE or ODESC_ERROR,