|
1 | 1 | #include "internal.h" |
2 | 2 |
|
3 | | -/* |
4 | | - * This file contains stubbed out functions we are using during |
5 | | - * the initial Windows port. When the port is complete, this file |
6 | | - * should be empty (and thus removed). |
7 | | - */ |
| 3 | +typedef void (WINAPI *_precise_time_fn_t)(PULONGLONG); |
8 | 4 |
|
9 | | -void |
10 | | -_dispatch_runloop_queue_dispose(dispatch_queue_t dq DISPATCH_UNUSED, |
11 | | - bool *allow_free DISPATCH_UNUSED) |
| 5 | +DISPATCH_STATIC_GLOBAL(dispatch_once_t _dispatch_precise_time_pred); |
| 6 | +DISPATCH_STATIC_GLOBAL(_precise_time_fn_t _dispatch_QueryInterruptTimePrecise_ptr); |
| 7 | +DISPATCH_STATIC_GLOBAL(_precise_time_fn_t _dispatch_QueryUnbiasedInterruptTimePrecise_ptr); |
| 8 | + |
| 9 | +static void |
| 10 | +_dispatch_init_precise_time(void *context DISPATCH_UNUSED) |
12 | 11 | { |
13 | | - WIN_PORT_ERROR(); |
| 12 | + HMODULE kernelbase = LoadLibraryW(L"KernelBase.dll"); |
| 13 | + if (!kernelbase) { |
| 14 | + DISPATCH_INTERNAL_CRASH(0, "failed to load KernelBase.dll"); |
| 15 | + } |
| 16 | + _dispatch_QueryInterruptTimePrecise_ptr = (_precise_time_fn_t) |
| 17 | + GetProcAddress(kernelbase, "QueryInterruptTimePrecise"); |
| 18 | + _dispatch_QueryUnbiasedInterruptTimePrecise_ptr = (_precise_time_fn_t) |
| 19 | + GetProcAddress(kernelbase, "QueryUnbiasedInterruptTimePrecise"); |
| 20 | + if (!_dispatch_QueryInterruptTimePrecise_ptr) { |
| 21 | + DISPATCH_INTERNAL_CRASH(0, "could not locate QueryInterruptTimePrecise"); |
| 22 | + } |
| 23 | + if (!_dispatch_QueryUnbiasedInterruptTimePrecise_ptr) { |
| 24 | + DISPATCH_INTERNAL_CRASH(0, "could not locate QueryUnbiasedInterruptTimePrecise"); |
| 25 | + } |
14 | 26 | } |
15 | 27 |
|
16 | 28 | void |
17 | | -_dispatch_runloop_queue_xref_dispose(dispatch_queue_t dq DISPATCH_UNUSED) |
| 29 | +_dispatch_QueryInterruptTimePrecise(PULONGLONG lpInterruptTimePrecise) |
18 | 30 | { |
19 | | - WIN_PORT_ERROR(); |
| 31 | + dispatch_once_f(&_dispatch_precise_time_pred, NULL, _dispatch_init_precise_time); |
| 32 | + return _dispatch_QueryInterruptTimePrecise_ptr(lpInterruptTimePrecise); |
20 | 33 | } |
21 | 34 |
|
22 | | -/* |
23 | | - * Stubbed out static data |
24 | | - */ |
| 35 | +void |
| 36 | +_dispatch_QueryUnbiasedInterruptTimePrecise(PULONGLONG lpUnbiasedInterruptTimePrecise) |
| 37 | +{ |
| 38 | + dispatch_once_f(&_dispatch_precise_time_pred, NULL, _dispatch_init_precise_time); |
| 39 | + return _dispatch_QueryUnbiasedInterruptTimePrecise_ptr(lpUnbiasedInterruptTimePrecise); |
| 40 | +} |
0 commit comments