Skip to content

Commit 08d7d21

Browse files
committed
Falling back to select_io_watcher when target OS(NT < 6.0) not support it
1 parent 0cbe0dc commit 08d7d21

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

yasio/compiler/feature_test.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ SOFTWARE.
121121

122122
/// Tests multiplex io model of current OS
123123

124+
// poll
125+
#if !defined(_WIN32) || NTDDI_VERSION >= NTDDI_VISTA
126+
# define YASIO__HAS_POLL 1
127+
#else
128+
# define YASIO__HAS_POLL 0
129+
#endif
130+
124131
// ppoll
125132
#if defined(__linux__) && !defined(__ANDROID__) || (defined(__ANDROID_API__) && __ANDROID_API__ >= 21)
126133
# define YASIO__HAS_PPOLL 1

yasio/io_watcher.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
#elif YASIO__HAS_EVPORT && defined(YASIO_ENABLE_HPERF_IO)
1818
# include "yasio/impl/evport_io_watcher.hpp"
1919
#elif !defined(YASIO_DISABLE_POLL)
20-
# include "yasio/impl/poll_io_watcher.hpp"
20+
# if YASIO__HAS_POLL
21+
# include "yasio/impl/poll_io_watcher.hpp"
22+
# else
23+
# pragma message("Falling back to select_io_watcher due to target OS(NT < 6.0) not support it")
24+
# include "yasio/impl/select_io_watcher.hpp"
25+
# endif
2126
#else
2227
# include "yasio/impl/select_io_watcher.hpp"
2328
#endif
@@ -33,7 +38,7 @@ using io_watcher = kqueue_io_watcher;
3338
using io_watcher = epoll_io_watcher;
3439
#elif defined(YASIO__EVPORT_IO_WATCHER_HPP)
3540
using io_watcher = evport_io_watcher;
36-
#elif !defined(YASIO_DISABLE_POLL)
41+
#elif !defined(YASIO_DISABLE_POLL) && YASIO__HAS_POLL
3742
using io_watcher = poll_io_watcher;
3843
#else
3944
using io_watcher = select_io_watcher;

0 commit comments

Comments
 (0)