Created
November 22, 2014 13:44
-
-
Save Youka/4153f12cf2e17a77314c to your computer and use it in GitHub Desktop.
Revisions
-
Youka created this gist
Nov 22, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ #include <windows.h> /* WinAPI */ /* Windows sleep in 100ns units */ BOOLEAN nanosleep(LONGLONG ns){ /* Declarations */ HANDLE timer; /* Timer handle */ LARGE_INTEGER li; /* Time defintion */ /* Create timer */ if(!(timer = CreateWaitableTimer(NULL, TRUE, NULL))) return FALSE; /* Set timer properties */ li.QuadPart = -ns; if(!SetWaitableTimer(timer, &li, 0, NULL, NULL, FALSE)){ CloseHandle(timer); return FALSE; } /* Start & wait for timer */ WaitForSingleObject(timer, INFINITE); /* Clean resources */ CloseHandle(timer); /* Slept without problems */ return TRUE; }