Skip to content

Commit 204c38a

Browse files
committed
DNM/hacks to make 1121 build on Windows
1 parent 720e08f commit 204c38a

File tree

10 files changed

+68
-12
lines changed

10 files changed

+68
-12
lines changed

src/event/event_windows.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ _dispatch_unote_unregister(dispatch_unote_t du DISPATCH_UNUSED,
4949
#pragma mark timers
5050

5151
void
52-
_dispatch_event_loop_timer_arm(uint32_t tidx DISPATCH_UNUSED,
52+
_dispatch_event_loop_timer_arm(dispatch_timer_heap_t dth DISPATCH_UNUSED,
53+
uint32_t tidx DISPATCH_UNUSED,
5354
dispatch_timer_delay_s range DISPATCH_UNUSED,
5455
dispatch_clock_now_cache_t nows DISPATCH_UNUSED)
5556
{
5657
WIN_PORT_ERROR();
5758
}
5859

5960
void
60-
_dispatch_event_loop_timer_delete(uint32_t tidx DISPATCH_UNUSED)
61+
_dispatch_event_loop_timer_delete(dispatch_timer_heap_t dth DISPATCH_UNUSED,
62+
uint32_t tidx DISPATCH_UNUSED)
6163
{
6264
WIN_PORT_ERROR();
6365
}
@@ -109,9 +111,9 @@ _dispatch_event_loop_assert_not_owned(dispatch_wlh_t wlh)
109111
#endif
110112

111113
void
112-
_dispatch_event_loop_leave_immediate(dispatch_wlh_t wlh, uint64_t dq_state)
114+
_dispatch_event_loop_leave_immediate(uint64_t dq_state)
113115
{
114-
(void)wlh; (void)dq_state;
116+
(void)dq_state;
115117
}
116118

117119
#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/queue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ dispatch_block_testcancel(dispatch_block_t db)
571571
return (bool)(dbpd->dbpd_atomic_flags & DBF_CANCELED);
572572
}
573573

574-
long
574+
intptr_t
575575
dispatch_block_wait(dispatch_block_t db, dispatch_time_t timeout)
576576
{
577577
dispatch_block_private_data_t dbpd = _dispatch_block_get_data(db);

src/queue_internal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ typedef struct dispatch_workloop_attr_s *dispatch_workloop_attr_t;
470470
typedef struct dispatch_workloop_attr_s {
471471
uint32_t dwla_flags;
472472
dispatch_priority_t dwla_pri;
473+
#if defined(_POSIX_THREADS)
473474
struct sched_param dwla_sched;
475+
#endif
474476
int dwla_policy;
475477
struct {
476478
uint8_t percent;
@@ -1045,7 +1047,9 @@ typedef struct dispatch_continuation_s {
10451047
DISPATCH_CONTINUATION_HEADER(continuation);
10461048
} *dispatch_continuation_t;
10471049

1050+
#if 0
10481051
dispatch_assert_aliases(dispatch_continuation_s, dispatch_object_s, do_next);
1052+
#endif
10491053
dispatch_assert_aliases(dispatch_continuation_s, dispatch_object_s, do_vtable);
10501054

10511055
typedef struct dispatch_sync_context_s {

src/shims/generic_sys_queue.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,54 @@
8989
} \
9090
} while(0)
9191

92+
#define TAILQ_HEAD_INITIALIZER(head) \
93+
{ NULL, (head).tq_first }
94+
95+
#define TAILQ_CONCAT(head1, head2, field) \
96+
do { \
97+
if (!TAILQ_EMPTY(head2)) { \
98+
(head1)->tq_last = (head2)->tq_first; \
99+
(head2)->tq_first->field.te_prev = (head1)->tq_last; \
100+
(head1)->tq_last = (head2)->tq_last; \
101+
TAILQ_INIT((head2)); \
102+
} \
103+
} while (0)
104+
105+
106+
#define LIST_HEAD(name, type) \
107+
struct name { \
108+
struct type *lh_first; \
109+
}
110+
111+
#define LIST_ENTRY(type) \
112+
struct { \
113+
struct type *le_next; \
114+
struct type**le_prev; \
115+
}
116+
117+
#define LIST_FIRST(head) ((head)->lh_first)
118+
119+
#define LIST_FOREACH(var, head, field) \
120+
for ((var) = LIST_FIRST((head)); \
121+
(var); \
122+
(var) = LIST_NEXT((var), field))
123+
124+
#define LIST_NEXT(elm, field) ((elm)->field.le_next)
125+
126+
#define LIST_REMOVE(elm, field) \
127+
do { \
128+
if (LIST_NEXT((elm), field) != NULL) \
129+
LIST_NEXT((elm), field)->field.le_prev = (elm)->field.le_prev; \
130+
TRASHIT(*oldnext); \
131+
TRASHIT(*oldprev); \
132+
} while (0)
133+
134+
#define LIST_INSERT_HEAD(head, elm, field) \
135+
do { \
136+
if ((LIST_NEXT((elm), field) = LIST_FIRST((head))) != NULL) \
137+
LIST_FIRST((head))->field.le_prev = &LIST_NEXT((elm), field); \
138+
LIST_FIRST((head)) = (elm); \
139+
(elm)->field.le_prev = &LIST_FIRST((head)); \
140+
} while (0)
141+
92142
#endif // __DISPATCH_SHIMS_SYS_QUEUE__

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ _dispatch_wait_on_address(uint32_t volatile *_address, uint32_t value,
509509
}
510510
return _dispatch_futex_wait(address, value, NULL, FUTEX_PRIVATE_FLAG);
511511
#elif defined(_WIN32)
512-
WaitOnAddress(address, (PVOID)(uintptr_t)value, sizeof(value), INFINITE);
512+
return WaitOnAddress(address, (PVOID)(uintptr_t)value, sizeof(value), INFINITE) == TRUE;
513513
#else
514514
#error _dispatch_wait_on_address unimplemented for this platform
515515
#endif

src/shims/time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ _dispatch_uptime(void)
148148
struct timespec ts;
149149
dispatch_assume_zero(clock_gettime(CLOCK_UPTIME, &ts));
150150
return _dispatch_timespec_to_nano(ts);
151-
#elif TARGET_OS_WIN32
151+
#elif defined(_WIN32)
152152
LARGE_INTEGER now;
153153
return QueryPerformanceCounter(&now) ? now.QuadPart : 0;
154154
#else

src/shims/yield.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ void *_dispatch_wait_for_enqueuer(void **ptr);
149149
#define _dispatch_preemption_yield(n) { (void)n; pthread_yield_np(); }
150150
#define _dispatch_preemption_yield_to(th, n) { (void)n; pthread_yield_np(); }
151151
#elif defined(_WIN32)
152-
#define _dispatch_preemption_yield(n) { (void)n; sched_yield(); }
153-
#define _dispatch_preemption_yield_to(th, n) { (void)n; sched_yield(); }
152+
#define _dispatch_preemption_yield(n) { (void)n; Sleep(0); }
153+
#define _dispatch_preemption_yield_to(th, n) { (void)n; Sleep(0); }
154154
#else
155155
#define _dispatch_preemption_yield(n) { (void)n; pthread_yield(); }
156156
#define _dispatch_preemption_yield_to(th, n) { (void)n; pthread_yield(); }

src/source.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ dispatch_source_get_extended_data(dispatch_source_t ds,
197197
}
198198

199199
void
200-
dispatch_source_merge_data(dispatch_source_t ds, unsigned long val)
200+
dispatch_source_merge_data(dispatch_source_t ds, uintptr_t val)
201201
{
202202
dispatch_queue_flags_t dqf = _dispatch_queue_atomic_flags(ds);
203203
dispatch_source_refs_t dr = ds->ds_refs;

0 commit comments

Comments
 (0)