2 #include <winpr/sysinfo.h>
3 #include <winpr/windows.h>
5 #include <winpr/intrin.h>
7 static BOOL g_LZCNT = FALSE;
9 static INLINE UINT32 lzcnt_s(UINT32 x)
51 static int test_lzcnt(
void)
53 if (lzcnt_s(0x1) != 31)
55 (void)fprintf(stderr,
"__lzcnt(0x1) != 31: %" PRIu32
"\n", __lzcnt(0x1));
59 if (lzcnt_s(0xFF) != 24)
61 (void)fprintf(stderr,
"__lzcnt(0xFF) != 24\n");
65 if (lzcnt_s(0xFFFF) != 16)
67 (void)fprintf(stderr,
"__lzcnt(0xFFFF) != 16\n");
71 if (lzcnt_s(0xFFFFFF) != 8)
73 (void)fprintf(stderr,
"__lzcnt(0xFFFFFF) != 8\n");
77 if (lzcnt_s(0xFFFFFFFF) != 0)
79 (void)fprintf(stderr,
"__lzcnt(0xFFFFFFFF) != 0\n");
86 static int test_lzcnt16(
void)
88 if (__lzcnt16(0x1) != 15)
90 (void)fprintf(stderr,
"__lzcnt16(0x1) != 15\n");
94 if (__lzcnt16(0xFF) != 8)
96 (void)fprintf(stderr,
"__lzcnt16(0xFF) != 8\n");
100 if (__lzcnt16(0xFFFF) != 0)
102 (void)fprintf(stderr,
"__lzcnt16(0xFFFF) != 0\n");
109 int TestIntrinsics(
int argc,
char* argv[])
115 g_LZCNT = IsProcessorFeaturePresentEx(PF_EX_LZCNT);
117 printf(
"LZCNT available: %" PRId32
"\n", g_LZCNT);