Created
May 21, 2018 15:53
-
-
Save jpcima/8be825fcbdf55732e349ba5a81caec24 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
int main() | |
{ | |
for (unsigned count = 0; count < 100; count += 10) { | |
CRITICAL_SECTION cs = {}; | |
SetLastError(0); | |
BOOL b = InitializeCriticalSectionAndSpinCount(&cs, count); | |
DWORD e = GetLastError(); | |
printf("InitializeCriticalSectionWithSpinCount %u -> (%s,error=%u)\n", | |
count, b ? "TRUE" : "FALSE", e); | |
printf(" * data:"); | |
for (size_t i = 0; i < sizeof(cs); ++i) | |
printf(" %02x", ((unsigned char *)&cs)[i]); | |
printf("\n"); | |
if (b) | |
DeleteCriticalSection(&cs); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment