Ticket #5980: MythTV-compat.h.patch

File MythTV-compat.h.patch, 1.5 KB (added by Jonathan Martens <jonathan@…>, 13 years ago)
  • libs/libmythdb/compat.h

     
    8888#endif
    8989
    9090#if defined(__cplusplus) && defined(USING_MINGW)
    91 /* TODO: most small usleep's in MythTV are just a quick way to perform
    92  * a yield() call, those should just be replaced with an actual yield().
    93  * There is a known bug with Win32 yield(), it basically functions as
    94  * a no-op. Sleep(0) yields, but only to higher priority threads, while
    95  * Sleep(1), performs an actual yield() to any other thread.
    96  * See: http://lists.boost.org/Archives/boost/2003/02/44937.php
    97  */
    98 inline int usleep(unsigned int timeout)
    99 {
    100     /*
    101     // windows seems to have 1us-resolution timers,
    102     // however this produces the same results as Sleep
    103     HANDLE hTimer = ::CreateWaitableTimer(NULL, TRUE, NULL);
    104     if (hTimer) {
    105         LARGE_INTEGER li;
    106         li.QuadPart = -((int)timeout * 10);
    107         if (SetWaitableTimer(hTimer, &li, 0, NULL, 0, FALSE)) {
    108             DWORD res = WaitForSingleObject(hTimer, (timeout / 1000 + 1));
    109             if (res == WAIT_TIMEOUT || res == WAIT_OBJECT_0)
    110                 return 0;
    111         }
    112         CloseHandle(hTimer);
    113     }
    114     */
    115     //fallback
    116     Sleep(timeout < 1000 ? 1 : (timeout + 500) / 1000);
    117     return 0;
    118 }
    119 #endif // defined(__cplusplus) && defined(USING_MINGW)
    120 
    121 #if defined(__cplusplus) && defined(USING_MINGW)
    12291inline unsigned sleep(unsigned int x)
    12392{
    12493    Sleep(x * 1000);