diff options
author | Tamar Christina <tamar@zhox.com> | 2019-06-16 21:31:22 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-07-15 16:41:02 -0400 |
commit | 4489af6bad11a198e9e6c192f41e17020f28d0c1 (patch) | |
tree | a7046d2982400ef86d1e026947618c29b908cd62 /libraries/base/include | |
parent | 4bf542bf1cdf2fa468457fc0af21333478293476 (diff) | |
download | haskell-4489af6bad11a198e9e6c192f41e17020f28d0c1.tar.gz |
winio: core threaded I/O manager
Diffstat (limited to 'libraries/base/include')
-rw-r--r-- | libraries/base/include/winio_structs.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/libraries/base/include/winio_structs.h b/libraries/base/include/winio_structs.h new file mode 100644 index 0000000000..da9dab05b7 --- /dev/null +++ b/libraries/base/include/winio_structs.h @@ -0,0 +1,40 @@ +/* + * (c) Tamar Christina, 2019. + * + * Structures supporting the IOCP based I/O Manager or Windows. + */ + +#include <Windows.h> +#include <stdint.h> + +#if defined(_WIN64) +# define ALIGNMENT __attribute__ ((aligned (8))) +#elif defined(_WIN32) +# define ALIGNMENT __attribute__ ((aligned (8))) +#else +# error "unknown environment, can't determine alignment" +#endif + +/* Completion data structure. Must be kept in sync with that in + GHC.Event.Windows or horrible things happen. */ +typedef struct _CompletionData { + /* The Handle to the object for which the I/O operation is in progress. */ + HWND cdHandle; + /* Handle to the callback routine to call to notify that an operation has + finished. This value is opaque as it shouldn't be accessible + outside the Haskell world. */ + uintptr_t cdCallback; +} CompletionData, *LPCompletionData; + +/* The Windows API Requires an OVERLAPPED struct for asynchronous access, + however if we pad the structure we can give extra book keeping information + without needing to look these up later. Do not modify this struct unless + you know what you're doing. */ +typedef struct _HASKELL_OVERLAPPED { + /* Windows OVERLAPPED structure. NOTE: MUST BE FIRST element. */ + OVERLAPPED hoOverlapped; + /* Pointer to additional payload in Haskell land. This will contain a + foreign pointer. We only use atomic operations to access this field in + order to correctly handle multiple threads using it. */ + LPCompletionData hoData ALIGNMENT; +} HASKELL_OVERLAPPED; |