Skip to content

Commit b863538

Browse files
authored
Merge pull request #374 from adierking/stubs
Stub out unimplemented Windows functions
2 parents ff1daf8 + 977a769 commit b863538

File tree

6 files changed

+148
-1
lines changed

6 files changed

+148
-1
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ add_library(dispatch
4141
event/event_epoll.c
4242
event/event_internal.h
4343
event/event_kevent.c
44+
event/event_windows.c
4445
firehose/firehose_internal.h
4546
shims/android_stubs.h
4647
shims/atomic.h

src/event/event_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
# include <sys/eventfd.h>
2626
# define DISPATCH_EVENT_BACKEND_EPOLL 1
2727
# define DISPATCH_EVENT_BACKEND_KEVENT 0
28+
# define DISPATCH_EVENT_BACKEND_WINDOWS 0
2829
#elif __has_include(<sys/event.h>)
2930
# include <sys/event.h>
3031
# define DISPATCH_EVENT_BACKEND_EPOLL 0
3132
# define DISPATCH_EVENT_BACKEND_KEVENT 1
33+
# define DISPATCH_EVENT_BACKEND_WINDOWS 0
3234
#elif defined(_WIN32)
3335
# define DISPATCH_EVENT_BACKEND_EPOLL 0
3436
# define DISPATCH_EVENT_BACKEND_KEVENT 0
37+
# define DISPATCH_EVENT_BACKEND_WINDOWS 1
3538
#else
3639
# error unsupported event loop
3740
#endif

src/event/event_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,9 @@ void _dispatch_unote_resume(dispatch_unote_t du);
418418
bool _dispatch_unote_unregister(dispatch_unote_t du, uint32_t flags);
419419
void _dispatch_unote_dispose(dispatch_unote_t du);
420420

421+
#if !DISPATCH_EVENT_BACKEND_WINDOWS
421422
void _dispatch_event_loop_atfork_child(void);
423+
#endif
422424
#define DISPATCH_EVENT_LOOP_CONSUME_2 DISPATCH_WAKEUP_CONSUME_2
423425
#define DISPATCH_EVENT_LOOP_OVERRIDE 0x80000000
424426
void _dispatch_event_loop_poke(dispatch_wlh_t wlh, uint64_t dq_state,

src/event/event_windows.c

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* Copyright (c) 2018 Apple Inc. All rights reserved.
3+
*
4+
* @APPLE_APACHE_LICENSE_HEADER_START@
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
* @APPLE_APACHE_LICENSE_HEADER_END@
19+
*/
20+
21+
#include "internal.h"
22+
#if DISPATCH_EVENT_BACKEND_WINDOWS
23+
24+
#pragma mark dispatch_unote_t
25+
26+
bool
27+
_dispatch_unote_register(dispatch_unote_t du DISPATCH_UNUSED,
28+
dispatch_wlh_t wlh DISPATCH_UNUSED,
29+
dispatch_priority_t pri DISPATCH_UNUSED)
30+
{
31+
WIN_PORT_ERROR();
32+
return false;
33+
}
34+
35+
void
36+
_dispatch_unote_resume(dispatch_unote_t du DISPATCH_UNUSED)
37+
{
38+
WIN_PORT_ERROR();
39+
}
40+
41+
bool
42+
_dispatch_unote_unregister(dispatch_unote_t du DISPATCH_UNUSED,
43+
uint32_t flags DISPATCH_UNUSED)
44+
{
45+
WIN_PORT_ERROR();
46+
return false;
47+
}
48+
49+
#pragma mark timers
50+
51+
void
52+
_dispatch_event_loop_timer_arm(uint32_t tidx DISPATCH_UNUSED,
53+
dispatch_timer_delay_s range DISPATCH_UNUSED,
54+
dispatch_clock_now_cache_t nows DISPATCH_UNUSED)
55+
{
56+
WIN_PORT_ERROR();
57+
}
58+
59+
void
60+
_dispatch_event_loop_timer_delete(uint32_t tidx DISPATCH_UNUSED)
61+
{
62+
WIN_PORT_ERROR();
63+
}
64+
65+
#pragma mark dispatch_loop
66+
67+
void
68+
_dispatch_event_loop_poke(dispatch_wlh_t wlh DISPATCH_UNUSED,
69+
uint64_t dq_state DISPATCH_UNUSED, uint32_t flags DISPATCH_UNUSED)
70+
{
71+
WIN_PORT_ERROR();
72+
}
73+
74+
DISPATCH_NOINLINE
75+
void
76+
_dispatch_event_loop_drain(uint32_t flags DISPATCH_UNUSED)
77+
{
78+
WIN_PORT_ERROR();
79+
}
80+
81+
void
82+
_dispatch_event_loop_wake_owner(dispatch_sync_context_t dsc,
83+
dispatch_wlh_t wlh, uint64_t old_state, uint64_t new_state)
84+
{
85+
(void)dsc; (void)wlh; (void)old_state; (void)new_state;
86+
}
87+
88+
void
89+
_dispatch_event_loop_wait_for_ownership(dispatch_sync_context_t dsc)
90+
{
91+
if (dsc->dsc_release_storage) {
92+
_dispatch_queue_release_storage(dsc->dc_data);
93+
}
94+
}
95+
96+
void
97+
_dispatch_event_loop_end_ownership(dispatch_wlh_t wlh, uint64_t old_state,
98+
uint64_t new_state, uint32_t flags)
99+
{
100+
(void)wlh; (void)old_state; (void)new_state; (void)flags;
101+
}
102+
103+
#if DISPATCH_WLH_DEBUG
104+
void
105+
_dispatch_event_loop_assert_not_owned(dispatch_wlh_t wlh)
106+
{
107+
(void)wlh;
108+
}
109+
#endif
110+
111+
void
112+
_dispatch_event_loop_leave_immediate(dispatch_wlh_t wlh, uint64_t dq_state)
113+
{
114+
(void)wlh; (void)dq_state;
115+
}
116+
117+
#endif // DISPATCH_EVENT_BACKEND_WINDOWS

src/shims/generic_win_stubs.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
#include "internal.h"
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+
*/
8+
9+
void
10+
_dispatch_runloop_queue_dispose(dispatch_queue_t dq DISPATCH_UNUSED,
11+
bool *allow_free DISPATCH_UNUSED)
12+
{
13+
WIN_PORT_ERROR();
14+
}
15+
16+
void
17+
_dispatch_runloop_queue_xref_dispose(dispatch_queue_t dq DISPATCH_UNUSED)
18+
{
19+
WIN_PORT_ERROR();
20+
}
121

222
/*
323
* Stubbed out static data

src/shims/generic_win_stubs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <stdint.h>
66

77
#include <Windows.h>
8+
#include <crtdbg.h>
89

910
#include <io.h>
1011
#include <process.h>
@@ -45,5 +46,8 @@ typedef __typeof__(_Generic((__SIZE_TYPE__)0, \
4546

4647
#define bzero(ptr,len) memset((ptr), 0, (len))
4748

48-
#endif
49+
// Report when an unported code path executes.
50+
#define WIN_PORT_ERROR() \
51+
_RPTF1(_CRT_ASSERT, "WIN_PORT_ERROR in %s", __FUNCTION__)
4952

53+
#endif

0 commit comments

Comments
 (0)