-// semaphores are too fundamental to use the dispatch_assume*() macros
-#if USE_MACH_SEM
-#define DISPATCH_SEMAPHORE_VERIFY_KR(x) do { \
- if (slowpath(x)) { \
- DISPATCH_CRASH("flawed group/semaphore logic"); \
- } \
- } while (0)
-#elif USE_POSIX_SEM
-#define DISPATCH_SEMAPHORE_VERIFY_RET(x) do { \
- if (slowpath((x) == -1)) { \
- DISPATCH_CRASH("flawed group/semaphore logic"); \
- } \
- } while (0)
-#endif
-
-#if USE_WIN32_SEM
-// rdar://problem/8428132
-static DWORD best_resolution = 1; // 1ms
-
-DWORD
-_push_timer_resolution(DWORD ms)
-{
- MMRESULT res;
- static dispatch_once_t once;
-
- if (ms > 16) {
- // only update timer resolution if smaller than default 15.6ms
- // zero means not updated
- return 0;
- }
-
- // aim for the best resolution we can accomplish
- dispatch_once(&once, ^{
- TIMECAPS tc;
- MMRESULT res;
- res = timeGetDevCaps(&tc, sizeof(tc));
- if (res == MMSYSERR_NOERROR) {
- best_resolution = min(max(tc.wPeriodMin, best_resolution),
- tc.wPeriodMax);
- }
- });
-
- res = timeBeginPeriod(best_resolution);
- if (res == TIMERR_NOERROR) {
- return best_resolution;
- }
- // zero means not updated
- return 0;
-}
-
-// match ms parameter to result from _push_timer_resolution
-void
-_pop_timer_resolution(DWORD ms)
-{
- if (ms) {
- timeEndPeriod(ms);
- }
-}
-#endif /* USE_WIN32_SEM */
-
-