mirror of
https://github.com/X11Libre/xserver.git
synced 2026-03-24 05:54:08 +00:00
Old compilers used on some platforms (e.g. DragonFlyBSD) do not support __has_builtin, so now we fall back to #if define if __has_builtin is not found. Signed-off-by: b-aaz <b-aazbsd@proton.me>
37 lines
894 B
C
37 lines
894 B
C
#include <dix-config.h>
|
|
|
|
#include <X11/Xfuncproto.h>
|
|
|
|
#undef Ones
|
|
|
|
/*
|
|
* this is specifically for NVidia proprietary driver: they're again lagging
|
|
* behind a year, doing at least some minimal cleanup of their code base.
|
|
* All attempts to get in direct contact with them have failed.
|
|
*/
|
|
|
|
/*
|
|
* this is only needed for the 570.x nvidia drivers
|
|
*/
|
|
|
|
_X_EXPORT int Ones(unsigned long /*mask */ );
|
|
|
|
int
|
|
Ones(unsigned long mask)
|
|
{ /* HACKMEM 169 */
|
|
/* can't add a message here because this should be fast */
|
|
#if defined __has_builtin
|
|
#if __has_builtin(__builtin_popcountl)
|
|
return __builtin_popcountl (mask);
|
|
#endif
|
|
#elif defined __builtin_popcountl
|
|
return __builtin_popcountl (mask);
|
|
#else
|
|
unsigned long y;
|
|
|
|
y = (mask >> 1) & 033333333333;
|
|
y = mask - y - ((y >> 1) & 033333333333);
|
|
return (((y + (y >> 3)) & 030707070707) % 077);
|
|
#endif
|
|
}
|