diff --git a/rts/IOManager.c b/rts/IOManager.c index 43474d70fb17d2116f8c71c5525913df996287a9..072aa8abd754a344d977860d254c9c461977df87 100644 --- a/rts/IOManager.c +++ b/rts/IOManager.c @@ -211,15 +211,30 @@ void initCapabilityIOManager(CapIOManager **piomgr) (CapIOManager *) stgMallocBytes(sizeof(CapIOManager), "initCapabilityIOManager"); -#if defined(THREADED_RTS) -#if !defined(mingw32_HOST_OS) - iomgr->control_fd = -1; + switch (iomgr_type) { +#if defined(IOMGR_ENABLED_SELECT) + case IO_MANAGER_SELECT: + iomgr->blocked_queue_hd = END_TSO_QUEUE; + iomgr->blocked_queue_tl = END_TSO_QUEUE; + iomgr->sleeping_queue = END_TSO_QUEUE; + break; #endif -#else // !defined(THREADED_RTS) - iomgr->blocked_queue_hd = END_TSO_QUEUE; - iomgr->blocked_queue_tl = END_TSO_QUEUE; - iomgr->sleeping_queue = END_TSO_QUEUE; + +#if defined(IOMGR_ENABLED_WIN32_LEGACY) + case IO_MANAGER_WIN32_LEGACY: + iomgr->blocked_queue_hd = END_TSO_QUEUE; + iomgr->blocked_queue_tl = END_TSO_QUEUE; + break; +#endif + +#if defined(IOMGR_ENABLED_MIO_POSIX) + case IO_MANAGER_MIO_POSIX: + iomgr->control_fd = -1; + break; #endif + default: + break; + } *piomgr = iomgr; } @@ -376,12 +391,25 @@ void markCapabilityIOManager(evac_fn evac USED_IF_NOT_THREADS, CapIOManager *iomgr USED_IF_NOT_THREADS) { -#if !defined(THREADED_RTS) - evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_hd); - evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_tl); - evac(user, (StgClosure **)(void *)&iomgr->sleeping_queue); + switch (iomgr_type) { +#if defined(IOMGR_ENABLED_SELECT) + case IO_MANAGER_SELECT: + evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_hd); + evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_tl); + evac(user, (StgClosure **)(void *)&iomgr->sleeping_queue); + break; #endif +#if defined(IOMGR_ENABLED_WIN32_LEGACY) + case IO_MANAGER_WIN32_LEGACY: + evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_hd); + evac(user, (StgClosure **)(void *)&iomgr->blocked_queue_tl); + break; +#endif + default: + break; + } + } diff --git a/rts/IOManager.h b/rts/IOManager.h index 1e34d6b16650391229216529794aa425ce7e00e0..fb25d1f7e40a2572ece294f9b88d735cee6f8f5f 100644 --- a/rts/IOManager.h +++ b/rts/IOManager.h @@ -190,27 +190,25 @@ bool is_io_mng_native_p (void); */ typedef struct { -#if defined(THREADED_RTS) -#if !defined(mingw32_HOST_OS) - /* Control FD for the MIO manager for this capability */ - int control_fd; +#if defined(IOMGR_ENABLED_SELECT) + /* Thread queue for threads blocked on I/O completion. */ + StgTSO *blocked_queue_hd; + StgTSO *blocked_queue_tl; + + /* Thread queue for threads blocked on timeouts. */ + StgTSO *sleeping_queue; #endif -#else // !defined(THREADED_RTS) - /* Thread queue for threads blocked on I/O completion. - * Used by the select() and Win32 MIO I/O managers. It is not used by - * the WinIO I/O manager, though it remains defined in this case. - */ + +#if defined(IOMGR_ENABLED_WIN32_LEGACY) + /* Thread queue for threads blocked on I/O completion. */ StgTSO *blocked_queue_hd; StgTSO *blocked_queue_tl; +#endif - /* Thread queue for threads blocked on timeouts. - * Used by the select() I/O manager only. It is grossly inefficient, like - * everything else to do with the select() I/O manager. - * - * TODO: It is not used by any of the Windows I/O managers, though it - * remains defined for them. This is an oddity that should be resolved. +#if defined(IOMGR_ENABLED_MIO_POSIX) + /* Control FD for the (posix) MIO manager for this capability, */ - StgTSO *sleeping_queue; + int control_fd; #endif } CapIOManager;