From a5bad3d2e65c95a24676fb44d71d84bb8ca33852 Mon Sep 17 00:00:00 2001 From: Duncan Coutts <duncan@well-typed.com> Date: Wed, 16 Nov 2022 22:08:03 +0000 Subject: [PATCH] Split up the CapIOManager content by I/O manager Using the new IOMGR_ENABLED_<name> CPP defines. --- rts/IOManager.c | 50 ++++++++++++++++++++++++++++++++++++++----------- rts/IOManager.h | 30 ++++++++++++++--------------- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/rts/IOManager.c b/rts/IOManager.c index 43474d70fb17..072aa8abd754 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 1e34d6b16650..fb25d1f7e40a 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; -- GitLab