build: Add VKD3D_CHECK_FUNC() macro.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2018-01-11 17:03:45 +01:00 committed by Alexandre Julliard
parent ee8eb9b4e4
commit 54dd321729
3 changed files with 13 additions and 43 deletions

View File

@ -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"])

View File

@ -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])])])

9
m4/check-functions.m4 Normal file
View File

@ -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])])])