mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
build: Use __builtin_popcount() if available.
This commit is contained in:
parent
d9bc635d1a
commit
09658e3b9b
@ -88,6 +88,7 @@ AS_IF([test "x$with_spirv_tools" = "xyes"],
|
|||||||
PKG_CHECK_MODULES([XCB], [xcb xcb-keysyms])
|
PKG_CHECK_MODULES([XCB], [xcb xcb-keysyms])
|
||||||
|
|
||||||
dnl Check for functions
|
dnl Check for functions
|
||||||
|
VKD3D_CHECK_BUILTIN_POPCOUNT
|
||||||
VKD3D_CHECK_SYNC_ADD_AND_FETCH_FUNC
|
VKD3D_CHECK_SYNC_ADD_AND_FETCH_FUNC
|
||||||
VKD3D_CHECK_SYNC_SUB_AND_FETCH_FUNC
|
VKD3D_CHECK_SYNC_SUB_AND_FETCH_FUNC
|
||||||
|
|
||||||
|
@ -39,9 +39,13 @@ static inline size_t align(size_t addr, size_t alignment)
|
|||||||
|
|
||||||
static inline unsigned int vkd3d_popcount(unsigned int v)
|
static inline unsigned int vkd3d_popcount(unsigned int v)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_BUILTIN_POPCOUNT
|
||||||
|
return __builtin_popcount(v);
|
||||||
|
#else
|
||||||
v -= (v >> 1) & 0x55555555;
|
v -= (v >> 1) & 0x55555555;
|
||||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
||||||
return (((v + (v >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
|
return (((v + (v >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
@ -17,3 +17,13 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([int main(void) { return __sync_sub_and_fetch((in
|
|||||||
[1],
|
[1],
|
||||||
[Define to 1 if you have __sync_sub_and_fetch.])],
|
[Define to 1 if you have __sync_sub_and_fetch.])],
|
||||||
[AC_MSG_RESULT([no])])])
|
[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])])])
|
Loading…
Reference in New Issue
Block a user