mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Reformatted to new style
This commit is contained in:
@@ -10,16 +10,38 @@ static INLINE UINT32 lzcnt_s(UINT32 x)
|
||||
{
|
||||
if (!x)
|
||||
return 32;
|
||||
|
||||
|
||||
if (!g_LZCNT)
|
||||
{
|
||||
UINT32 y;
|
||||
int n = 32;
|
||||
y = x >> 16; if (y != 0) { n = n - 16; x = y; }
|
||||
y = x >> 8; if (y != 0) { n = n - 8; x = y; }
|
||||
y = x >> 4; if (y != 0) { n = n - 4; x = y; }
|
||||
y = x >> 2; if (y != 0) { n = n - 2; x = y; }
|
||||
y = x >> 1; if (y != 0) return n - 2;
|
||||
y = x >> 16;
|
||||
if (y != 0)
|
||||
{
|
||||
n = n - 16;
|
||||
x = y;
|
||||
}
|
||||
y = x >> 8;
|
||||
if (y != 0)
|
||||
{
|
||||
n = n - 8;
|
||||
x = y;
|
||||
}
|
||||
y = x >> 4;
|
||||
if (y != 0)
|
||||
{
|
||||
n = n - 4;
|
||||
x = y;
|
||||
}
|
||||
y = x >> 2;
|
||||
if (y != 0)
|
||||
{
|
||||
n = n - 2;
|
||||
x = y;
|
||||
}
|
||||
y = x >> 1;
|
||||
if (y != 0)
|
||||
return n - 2;
|
||||
return n - x;
|
||||
}
|
||||
|
||||
@@ -28,27 +50,32 @@ static INLINE UINT32 lzcnt_s(UINT32 x)
|
||||
|
||||
int test_lzcnt()
|
||||
{
|
||||
if (lzcnt_s(0x1) != 31) {
|
||||
fprintf(stderr, "__lzcnt(0x1) != 31: %"PRIu32"\n", __lzcnt(0x1));
|
||||
if (lzcnt_s(0x1) != 31)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt(0x1) != 31: %" PRIu32 "\n", __lzcnt(0x1));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lzcnt_s(0xFF) != 24) {
|
||||
if (lzcnt_s(0xFF) != 24)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt(0xFF) != 24\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lzcnt_s(0xFFFF) != 16) {
|
||||
if (lzcnt_s(0xFFFF) != 16)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt(0xFFFF) != 16\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lzcnt_s(0xFFFFFF) != 8) {
|
||||
if (lzcnt_s(0xFFFFFF) != 8)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt(0xFFFFFF) != 8\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lzcnt_s(0xFFFFFFFF) != 0) {
|
||||
if (lzcnt_s(0xFFFFFFFF) != 0)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt(0xFFFFFFFF) != 0\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -58,17 +85,20 @@ int test_lzcnt()
|
||||
|
||||
int test_lzcnt16()
|
||||
{
|
||||
if (__lzcnt16(0x1) != 15) {
|
||||
if (__lzcnt16(0x1) != 15)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt16(0x1) != 15\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__lzcnt16(0xFF) != 8) {
|
||||
if (__lzcnt16(0xFF) != 8)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt16(0xFF) != 8\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (__lzcnt16(0xFFFF) != 0) {
|
||||
if (__lzcnt16(0xFFFF) != 0)
|
||||
{
|
||||
fprintf(stderr, "__lzcnt16(0xFFFF) != 0\n");
|
||||
return -1;
|
||||
}
|
||||
@@ -80,8 +110,8 @@ int TestIntrinsics(int argc, char* argv[])
|
||||
{
|
||||
g_LZCNT = IsProcessorFeaturePresentEx(PF_EX_LZCNT);
|
||||
|
||||
printf("LZCNT available: %"PRId32"\n", g_LZCNT);
|
||||
printf("LZCNT available: %" PRId32 "\n", g_LZCNT);
|
||||
|
||||
//test_lzcnt16();
|
||||
// test_lzcnt16();
|
||||
return test_lzcnt();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <winpr/crt.h>
|
||||
#include <winpr/error.h>
|
||||
|
||||
BOOL TestSucceededFailedMacros(HRESULT hr, char *sym, BOOL isSuccess)
|
||||
BOOL TestSucceededFailedMacros(HRESULT hr, char* sym, BOOL isSuccess)
|
||||
{
|
||||
BOOL rv = TRUE;
|
||||
|
||||
@@ -106,7 +106,8 @@ int TestTypes(int argc, char* argv[])
|
||||
hr = HRESULT_FROM_WIN32(WSAECANCELLED);
|
||||
ok &= TestSucceededFailedMacros(hr, "HRESULT_FROM_WIN32(WSAECANCELLED)", FALSE);
|
||||
|
||||
if (ok) {
|
||||
if (ok)
|
||||
{
|
||||
printf("Test completed successfully\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user