Skip to content

Instantly share code, notes, and snippets.

@jpcima
Created May 21, 2018 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpcima/8be825fcbdf55732e349ba5a81caec24 to your computer and use it in GitHub Desktop.
Save jpcima/8be825fcbdf55732e349ba5a81caec24 to your computer and use it in GitHub Desktop.
#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