[PATCH vkd3d 02/12] build: Add VKD3D_CHECK_FUNC() macro.

Józef Kucia joseph.kucia at gmail.com
Thu Jan 11 10:03:45 CST 2018


From: Józef Kucia <jkucia at codeweavers.com>

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 configure.ac                  |  8 ++++----
 m4/check-builtin-functions.m4 | 39 ---------------------------------------
 m4/check-functions.m4         |  9 +++++++++
 3 files changed, 13 insertions(+), 43 deletions(-)
 delete mode 100644 m4/check-builtin-functions.m4
 create mode 100644 m4/check-functions.m4

diff --git a/configure.ac b/configure.ac
index d13b440755cd..5614f791fe64 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,10 +79,10 @@ AS_IF([test "x$with_spirv_tools" = "xyes"],
 PKG_CHECK_MODULES([XCB], [xcb xcb-keysyms])
 
 dnl Check for functions
-VKD3D_CHECK_BUILTIN_CLZ
-VKD3D_CHECK_BUILTIN_POPCOUNT
-VKD3D_CHECK_SYNC_ADD_AND_FETCH_FUNC
-VKD3D_CHECK_SYNC_SUB_AND_FETCH_FUNC
+VKD3D_CHECK_FUNC([HAVE_BUILTIN_CLZ], [__builtin_clz], [__builtin_clz(0)])
+VKD3D_CHECK_FUNC([HAVE_BUILTIN_POPCOUNT], [__builtin_popcount], [__builtin_popcount(0)])
+VKD3D_CHECK_FUNC([HAVE_SYNC_ADD_AND_FETCH], [__sync_add_and_fetch], [__sync_add_and_fetch((int *)0, 0)])
+VKD3D_CHECK_FUNC([HAVE_SYNC_SUB_AND_FETCH], [__sync_sub_and_fetch], [__sync_sub_and_fetch((int *)0, 0)])
 
 AM_CONDITIONAL([HAS_CROSSTARGET32], [test "x$CROSSTARGET32" != "xno"])
 AM_CONDITIONAL([HAS_CROSSTARGET64], [test "x$CROSSTARGET64" != "xno"])
diff --git a/m4/check-builtin-functions.m4 b/m4/check-builtin-functions.m4
deleted file mode 100644
index 2b24a802a3e3..000000000000
--- a/m4/check-builtin-functions.m4
+++ /dev/null
@@ -1,39 +0,0 @@
-dnl VKD3D_CHECK_SYNC_ADD_AND_FETCH_FUNC
-AC_DEFUN([VKD3D_CHECK_SYNC_ADD_AND_FETCH_FUNC],
-[AC_MSG_CHECKING([for __sync_add_and_fetch])
-AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __sync_add_and_fetch((int *)0, 0); }])],
-               [AC_MSG_RESULT([yes])
-               AC_DEFINE([HAVE_SYNC_ADD_AND_FETCH],
-                         [1],
-                         [Define to 1 if you have __sync_add_and_fetch.])],
-               [AC_MSG_RESULT([no])])])
-
-dnl VKD3D_CHECK_SYNC_SUB_AND_FETCH_FUNC
-AC_DEFUN([VKD3D_CHECK_SYNC_SUB_AND_FETCH_FUNC],
-[AC_MSG_CHECKING([for __sync_sub_and_fetch])
-AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __sync_sub_and_fetch((int *)0, 0); }])],
-               [AC_MSG_RESULT([yes])
-               AC_DEFINE([HAVE_SYNC_SUB_AND_FETCH],
-                         [1],
-                         [Define to 1 if you have __sync_sub_and_fetch.])],
-               [AC_MSG_RESULT([no])])])
-
-dnl VKD3D_CHECK_BUILTIN_CLZ
-AC_DEFUN([VKD3D_CHECK_BUILTIN_CLZ],
-[AC_MSG_CHECKING([for __builtin_clz])
-AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_clz(0); }])],
-               [AC_MSG_RESULT([yes])
-               AC_DEFINE([HAVE_BUILTIN_CLZ],
-                         [1],
-                         [Define to 1 if you have __builtin_clz.])],
-               [AC_MSG_RESULT([no])])])
-
-dnl VKD3D_CHECK_BUILTIN_POPCOUNT
-AC_DEFUN([VKD3D_CHECK_BUILTIN_POPCOUNT],
-[AC_MSG_CHECKING([for __builtin_popcount])
-AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __builtin_popcount(0); }])],
-               [AC_MSG_RESULT([yes])
-               AC_DEFINE([HAVE_BUILTIN_POPCOUNT],
-                         [1],
-                         [Define to 1 if you have __builtin_popcount.])],
-               [AC_MSG_RESULT([no])])])
diff --git a/m4/check-functions.m4 b/m4/check-functions.m4
new file mode 100644
index 000000000000..8bb8213153af
--- /dev/null
+++ b/m4/check-functions.m4
@@ -0,0 +1,9 @@
+dnl VKD3D_CHECK_FUNC
+AC_DEFUN([VKD3D_CHECK_FUNC],
+[AC_MSG_CHECKING([for $2])
+AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return [$3]; }])],
+               [AC_MSG_RESULT([yes])
+               AC_DEFINE([$1],
+                         [1],
+                         [Define to 1 if you have $2.])],
+               [AC_MSG_RESULT([no])])])
-- 
2.13.6




More information about the wine-devel mailing list