mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
build: Use __builtin_popcount() if available.
This commit is contained in:
@@ -39,9 +39,13 @@ static inline size_t align(size_t addr, size_t alignment)
|
||||
|
||||
static inline unsigned int vkd3d_popcount(unsigned int v)
|
||||
{
|
||||
#ifdef HAVE_BUILTIN_POPCOUNT
|
||||
return __builtin_popcount(v);
|
||||
#else
|
||||
v -= (v >> 1) & 0x55555555;
|
||||
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
|
||||
return (((v + (v >> 4)) & 0x0f0f0f0f) * 0x01010101) >> 24;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
|
Reference in New Issue
Block a user