File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,42 @@ Uint64 SDL_GetPerformanceFrequency(void)
103103 return (Uint64 )frequency .QuadPart ;
104104}
105105
106+ #ifdef SDL_TIMER_WINDOWS_USE_NTDELAYEXECUTION
107+
108+ typedef LONG (NTAPI * NtDelayExecution_t )(BOOLEAN Alertable , PLARGE_INTEGER DelayInterval );
109+ static NtDelayExecution_t pNtDelayExecution ;
110+
111+ static void SDL_NtDelayExecution (BOOLEAN Alertable , PLARGE_INTEGER DelayInterval )
112+ {
113+ if (!pNtDelayExecution ) {
114+ static bool initialized ;
115+
116+ if (!initialized ) {
117+ HMODULE module = GetModuleHandle (TEXT ("ntdll.dll" ));
118+ if (module ) {
119+ pNtDelayExecution = (NtDelayExecution_t )GetProcAddress (module , "NtDelayExecution" );
120+ }
121+ initialized = true;
122+ }
123+
124+ if (!pNtDelayExecution ) {
125+ return ;
126+ }
127+ }
128+
129+ pNtDelayExecution (Alertable , DelayInterval );
130+ }
131+
132+ void SDL_SYS_DelayNS (Uint64 ns )
133+ {
134+ Sint64 tick = ns ;
135+ tick /= 100 ;
136+ tick *= -1 ;
137+ SDL_NtDelayExecution (0 , (PLARGE_INTEGER )& tick );
138+ }
139+
140+ #else
141+
106142void SDL_SYS_DelayNS (Uint64 ns )
107143{
108144 HANDLE timer = SDL_GetWaitableTimer ();
@@ -130,4 +166,6 @@ void SDL_SYS_DelayNS(Uint64 ns)
130166 Sleep (delay );
131167}
132168
169+ #endif // SDL_TIMER_WINDOWS_USE_NTDELAYEXECUTION
170+
133171#endif // SDL_TIMER_WINDOWS
You can’t perform that action at this time.
0 commit comments