Skip to content

Commit eb989df

Browse files
compnerdrokhinip
authored andcommitted
resolve 1121 merge conflicts
This addresses the updates that were not applied to the Windows port but were applied to the Linux port and the macOS port. Signed-off-by: Kim Topley <ktopley@apple.com>
1 parent e2d01f8 commit eb989df

File tree

8 files changed

+39
-22
lines changed

8 files changed

+39
-22
lines changed

src/event/event_windows.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,20 @@ enum _dispatch_windows_port {
3232
#pragma mark dispatch_unote_t
3333

3434
bool
35-
_dispatch_unote_register(dispatch_unote_t du DISPATCH_UNUSED,
36-
dispatch_wlh_t wlh DISPATCH_UNUSED,
37-
dispatch_priority_t pri DISPATCH_UNUSED)
35+
_dispatch_unote_register_muxed(dispatch_unote_t du DISPATCH_UNUSED)
3836
{
3937
WIN_PORT_ERROR();
4038
return false;
4139
}
4240

4341
void
44-
_dispatch_unote_resume(dispatch_unote_t du DISPATCH_UNUSED)
42+
_dispatch_unote_resume_muxed(dispatch_unote_t du DISPATCH_UNUSED)
4543
{
4644
WIN_PORT_ERROR();
4745
}
4846

4947
bool
50-
_dispatch_unote_unregister(dispatch_unote_t du DISPATCH_UNUSED,
51-
uint32_t flags DISPATCH_UNUSED)
48+
_dispatch_unote_unregister_muxed(dispatch_unote_t du DISPATCH_UNUSED)
5249
{
5350
WIN_PORT_ERROR();
5451
return false;
@@ -102,8 +99,8 @@ _dispatch_timer_callback(PTP_CALLBACK_INSTANCE Instance, PVOID Context,
10299
}
103100

104101
void
105-
_dispatch_event_loop_timer_arm(uint32_t tidx,
106-
dispatch_timer_delay_s range,
102+
_dispatch_event_loop_timer_arm(dispatch_timer_heap_t dth DISPATCH_UNUSED,
103+
uint32_t tidx, dispatch_timer_delay_s range,
107104
dispatch_clock_now_cache_t nows)
108105
{
109106
dispatch_windows_timeout_t timer;
@@ -142,7 +139,8 @@ _dispatch_event_loop_timer_arm(uint32_t tidx,
142139
}
143140

144141
void
145-
_dispatch_event_loop_timer_delete(uint32_t tidx)
142+
_dispatch_event_loop_timer_delete(dispatch_timer_heap_t dth DISPATCH_UNUSED,
143+
uint32_t tidx)
146144
{
147145
dispatch_windows_timeout_t timer;
148146

@@ -238,6 +236,12 @@ _dispatch_event_loop_drain(uint32_t flags)
238236
}
239237
}
240238

239+
void
240+
_dispatch_event_loop_cancel_waiter(dispatch_sync_context_t dsc DISPATCH_UNUSED)
241+
{
242+
WIN_PORT_ERROR();
243+
}
244+
241245
void
242246
_dispatch_event_loop_wake_owner(dispatch_sync_context_t dsc,
243247
dispatch_wlh_t wlh, uint64_t old_state, uint64_t new_state)
@@ -269,9 +273,9 @@ _dispatch_event_loop_assert_not_owned(dispatch_wlh_t wlh)
269273
#endif
270274

271275
void
272-
_dispatch_event_loop_leave_immediate(dispatch_wlh_t wlh, uint64_t dq_state)
276+
_dispatch_event_loop_leave_immediate(uint64_t dq_state)
273277
{
274-
(void)wlh; (void)dq_state;
278+
(void)dq_state;
275279
}
276280

277281
#endif // DISPATCH_EVENT_BACKEND_WINDOWS

src/event/workqueue.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ _dispatch_workq_worker_register(dispatch_queue_global_t root_q)
9797
_dispatch_unfair_lock_unlock(&mon->registered_tid_lock);
9898
#else
9999
(void)root_q;
100-
(void)cls;
101100
#endif // HAVE_DISPATCH_WORKQ_MONITORING
102101
}
103102

@@ -124,7 +123,6 @@ _dispatch_workq_worker_unregister(dispatch_queue_global_t root_q)
124123
_dispatch_unfair_lock_unlock(&mon->registered_tid_lock);
125124
#else
126125
(void)root_q;
127-
(void)cls;
128126
#endif // HAVE_DISPATCH_WORKQ_MONITORING
129127
}
130128

src/io.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,11 +1394,11 @@ _dispatch_fd_entry_create_with_fd(dispatch_fd_t fd, uintptr_t hash)
13941394
int result = ioctlsocket((SOCKET)fd, (long)FIONBIO, &value);
13951395
(void)dispatch_assume_zero(result);
13961396
_dispatch_stream_init(fd_entry,
1397-
_dispatch_get_root_queue(DISPATCH_QOS_DEFAULT, false));
1397+
_dispatch_get_default_queue(false));
13981398
} else {
13991399
dispatch_suspend(fd_entry->barrier_queue);
1400-
dispatch_once_f(&_dispatch_io_devs_lockq_pred, NULL,
1401-
_dispatch_io_devs_lockq_init);
1400+
dispatch_once_f(&_dispatch_io_init_pred, NULL,
1401+
_dispatch_io_queues_init);
14021402
dispatch_async(_dispatch_io_devs_lockq, ^{
14031403
_dispatch_disk_init(fd_entry, 0);
14041404
dispatch_resume(fd_entry->barrier_queue);

src/queue.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3574,6 +3574,7 @@ _dispatch_queue_drain_should_narrow_slow(uint64_t now,
35743574
}
35753575
#endif // TARGET_OS_MAC
35763576
pthread_attr_destroy(&attr);
3577+
#endif // defined(_POSIX_THREADS)
35773578
}
35783579

35793580
void
@@ -5569,7 +5570,9 @@ static void
55695570
_dispatch_root_queue_poke_slow(dispatch_queue_global_t dq, int n, int floor)
55705571
{
55715572
int remaining = n;
5573+
#if !defined(_WIN32)
55725574
int r = ENOSYS;
5575+
#endif
55735576

55745577
_dispatch_root_queues_init();
55755578
_dispatch_debug_root_queue(dq, __func__);
@@ -5667,9 +5670,11 @@ _dispatch_root_queue_poke_slow(dispatch_queue_global_t dq, int n, int floor)
56675670
}
56685671
_dispatch_temporary_resource_shortage();
56695672
}
5673+
#if DISPATCH_USE_PTHREAD_ROOT_QUEUES
56705674
if (_dispatch_mgr_sched.prio > _dispatch_mgr_sched.default_prio) {
56715675
(void)dispatch_assume_zero(SetThreadPriority((HANDLE)hThread, _dispatch_mgr_sched.prio) == TRUE);
56725676
}
5677+
#endif
56735678
CloseHandle((HANDLE)hThread);
56745679
} while (--remaining);
56755680
#endif // defined(_WIN32)
@@ -6904,7 +6909,7 @@ _dispatch_sig_thread(void *ctxt DISPATCH_UNUSED)
69046909
// never returns, so burn bridges behind us
69056910
_dispatch_clear_stack(0);
69066911
#if defined(_WIN32)
6907-
for (;;) SuspendThread(GetCurrentThread());
6912+
Sleep(INFINITE);
69086913
#else
69096914
_dispatch_sigsuspend();
69106915
#endif

src/shims/generic_win_stubs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,6 @@ typedef __typeof__(_Generic((__SIZE_TYPE__)0, \
3434
#define WIN_PORT_ERROR() \
3535
_RPTF1(_CRT_ASSERT, "WIN_PORT_ERROR in %s", __FUNCTION__)
3636

37+
#define strcasecmp _stricmp
38+
3739
#endif

src/shims/lock.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ _dispatch_wait_on_address(uint32_t volatile *_address, uint32_t value,
508508
}
509509
return _dispatch_futex_wait(address, value, NULL, FUTEX_PRIVATE_FLAG);
510510
#elif defined(_WIN32)
511-
WaitOnAddress(address, &value, sizeof(value), INFINITE);
511+
return WaitOnAddress(address, &value, sizeof(value), INFINITE) == TRUE;
512512
#else
513513
#error _dispatch_wait_on_address unimplemented for this platform
514514
#endif
@@ -649,7 +649,9 @@ _dispatch_once_wait(dispatch_once_gate_t dgo)
649649
{
650650
dispatch_lock self = _dispatch_lock_value_for_self();
651651
uintptr_t old_v, new_v;
652+
#if HAVE_UL_UNFAIR_LOCK || HAVE_FUTEX
652653
dispatch_lock *lock = &dgo->dgo_gate.dgl_lock;
654+
#endif
653655
uint32_t timeout = 1;
654656

655657
for (;;) {
@@ -678,7 +680,7 @@ _dispatch_once_wait(dispatch_once_gate_t dgo)
678680
_dispatch_futex_wait(lock, (dispatch_lock)new_v, NULL,
679681
FUTEX_PRIVATE_FLAG);
680682
#else
681-
_dispatch_thread_switch(new_v, flags, timeout++);
683+
_dispatch_thread_switch(new_v, 0, timeout++);
682684
#endif
683685
(void)timeout;
684686
}

src/shims/yield.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ void *_dispatch_wait_for_enqueuer(void **ptr);
154154
#define _dispatch_preemption_yield(n) { (void)n; pthread_yield_np(); }
155155
#define _dispatch_preemption_yield_to(th, n) { (void)n; pthread_yield_np(); }
156156
#elif defined(_WIN32)
157-
#define _dispatch_preemption_yield(n) { (void)n; sched_yield(); }
158-
#define _dispatch_preemption_yield_to(th, n) { (void)n; sched_yield(); }
157+
#define _dispatch_preemption_yield(n) { (void)n; Sleep(0); }
158+
#define _dispatch_preemption_yield_to(th, n) { (void)n; Sleep(0); }
159159
#else
160160
#define _dispatch_preemption_yield(n) { (void)n; pthread_yield(); }
161161
#define _dispatch_preemption_yield_to(th, n) { (void)n; pthread_yield(); }

src/unifdef.g2Y5qV renamed to src/unifdef.283QS8

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4136,6 +4136,7 @@ static const struct dispatch_queue_global_s _dispatch_custom_workloop_root_queue
41364136
static void
41374137
_dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
41384138
{
4139+
#if defined(_POSIX_THREADS)
41394140
dispatch_workloop_attr_t dwla = dwl->dwl_attr;
41404141
pthread_attr_t attr;
41414142

@@ -4180,6 +4181,7 @@ _dispatch_workloop_activate_attributes(dispatch_workloop_t dwl)
41804181
}
41814182
#endif // TARGET_OS_MAC
41824183
pthread_attr_destroy(&attr);
4184+
#endif // defined(_POSIX_THREADS)
41834185
}
41844186

41854187
void
@@ -6175,7 +6177,9 @@ static void
61756177
_dispatch_root_queue_poke_slow(dispatch_queue_global_t dq, int n, int floor)
61766178
{
61776179
int remaining = n;
6180+
#if !defined(_WIN32)
61786181
int r = ENOSYS;
6182+
#endif
61796183

61806184
_dispatch_root_queues_init();
61816185
_dispatch_debug_root_queue(dq, __func__);
@@ -6273,9 +6277,11 @@ _dispatch_root_queue_poke_slow(dispatch_queue_global_t dq, int n, int floor)
62736277
}
62746278
_dispatch_temporary_resource_shortage();
62756279
}
6280+
#if DISPATCH_USE_PTHREAD_ROOT_QUEUES
62766281
if (_dispatch_mgr_sched.prio > _dispatch_mgr_sched.default_prio) {
62776282
(void)dispatch_assume_zero(SetThreadPriority((HANDLE)hThread, _dispatch_mgr_sched.prio) == TRUE);
62786283
}
6284+
#endif
62796285
CloseHandle((HANDLE)hThread);
62806286
} while (--remaining);
62816287
#endif // defined(_WIN32)
@@ -7510,7 +7516,7 @@ _dispatch_sig_thread(void *ctxt DISPATCH_UNUSED)
75107516
// never returns, so burn bridges behind us
75117517
_dispatch_clear_stack(0);
75127518
#if defined(_WIN32)
7513-
for (;;) SuspendThread(GetCurrentThread());
7519+
Sleep(INFINITE);
75147520
#else
75157521
_dispatch_sigsuspend();
75167522
#endif

0 commit comments

Comments
 (0)