autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/1] Add AC_FUNC_PWRITEV which respects OSX Deployment Targets.


From: James Hilliard
Subject: [PATCH 1/1] Add AC_FUNC_PWRITEV which respects OSX Deployment Targets.
Date: Mon, 22 Feb 2021 06:16:55 -0700

Since we can't reliably use AC_REPLACE_FUNCS to detect pwritev
availability on OSX add a dedicated AC_FUNC_PWRITEV which can.

To detect pwritev support on OSX we need to ensure that the
<sys/uio.h> header is included.

In addition we need to ensure that we get a build error with
-Wunguarded-availability-new so that the test fails if the
fuction is marked as requiring a deployment target newer than
what is configured.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
 lib/autoconf/functions.m4 | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lib/autoconf/functions.m4 b/lib/autoconf/functions.m4
index c5add9f8..dd8e882e 100644
--- a/lib/autoconf/functions.m4
+++ b/lib/autoconf/functions.m4
@@ -1448,6 +1448,39 @@ fi
 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
 
 
+# _AC_FUNC_PWRITEV_IF(IF-WORKS, IF-NOT)
+# -------------------------------------
+AC_DEFUN([_AC_FUNC_PWRITEV_IF],
+[AC_CACHE_CHECK([for pwritev], ac_cv_func_pwritev,
+[AC_LINK_IFELSE(
+[AC_LANG_PROGRAM([
+#if defined(__clang__) && (__clang_major__ >= 5)
+ #pragma clang diagnostic error "-Wunguarded-availability-new"
+#endif
+#include <sys/types.h>
+#include <sys/uio.h>],
+[struct iovec *iov;
+off_t offset;
+offset = 0;
+pwritev(0, iov, 0, offset);])],
+[ac_cv_func_pwritev=yes],
+[ac_cv_func_pwritev=no])])
+AS_IF([test $ac_cv_func_pwritev = yes], [$1], [$2])
+])# _AC_FUNC_PWRITEV_IF
+
+
+# AC_FUNC_PWRITEV
+# --------------
+AN_FUNCTION([pwritev], [AC_FUNC_PWRITEV])
+AC_DEFUN([AC_FUNC_PWRITEV],
+[_AC_FUNC_PWRITEV_IF(
+  [AC_DEFINE([HAVE_PWRITEV], 1,
+       [Define to 1 if your system has a working `pwritev'
+        function, and to 0 otherwise.])],
+  [AC_DEFINE([HAVE_PWRITEV], 0)
+   AC_LIBOBJ(pwritev)]
+)])# AC_FUNC_PWRITEV
+
 
 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
 # -------------------------------------
-- 
2.30.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]