| 1 | /* $Id: async.cpp,v 1.7 2000-02-16 14:25:30 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 Asynchronous I/O Subsystem for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * 1998/04/10 PH Patrick Haller (haller@zebra.fh-weingarten.de)
|
|---|
| 7 | *
|
|---|
| 8 | * @(#) Async.Cpp 1.0.0 1998/04/10 PH start
|
|---|
| 9 | *
|
|---|
| 10 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 11 | *
|
|---|
| 12 | */
|
|---|
| 13 |
|
|---|
| 14 | #ifndef _ASYNCIOSUBSYSTEM_H_
|
|---|
| 15 | #define _ASYNCIOSUBSYSTEM_H_
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 | /*****************************************************************************
|
|---|
| 19 | * Remark *
|
|---|
| 20 | *****************************************************************************
|
|---|
| 21 |
|
|---|
| 22 | ReadFileEx
|
|---|
| 23 |
|
|---|
| 24 | */
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 | /*****************************************************************************
|
|---|
| 29 | * Includes *
|
|---|
| 30 | *****************************************************************************/
|
|---|
| 31 |
|
|---|
| 32 | #define INCL_WIN
|
|---|
| 33 | #define INCL_DOSMEMMGR
|
|---|
| 34 | #define INCL_DOSSEMAPHORES
|
|---|
| 35 | #define INCL_DOSERRORS
|
|---|
| 36 | #define INCL_DOSPROCESS
|
|---|
| 37 | #define INCL_DOSMODULEMGR
|
|---|
| 38 | #define INCL_VIO
|
|---|
| 39 | #define INCL_AVIO
|
|---|
| 40 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
|---|
| 41 | #include <builtin.h>
|
|---|
| 42 |
|
|---|
| 43 | #include <stdlib.h>
|
|---|
| 44 | #include <string.h>
|
|---|
| 45 | #include "win32type.h"
|
|---|
| 46 | #include "misc.h"
|
|---|
| 47 | #include "unicode.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "conwin.h" // Windows Header for console only
|
|---|
| 50 | #include "handlemanager.h"
|
|---|
| 51 |
|
|---|
| 52 | #define DBG_LOCALLOG DBG_async
|
|---|
| 53 | #include "dbglocal.h"
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | /*****************************************************************************
|
|---|
| 57 | * Defines & Macros *
|
|---|
| 58 | *****************************************************************************/
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 | /*****************************************************************************
|
|---|
| 62 | * Structures *
|
|---|
| 63 | *****************************************************************************/
|
|---|
| 64 |
|
|---|
| 65 | typedef struct _IORequest
|
|---|
| 66 | {
|
|---|
| 67 | struct _IORequest *pNext; /* pointer to next I/O request */
|
|---|
| 68 |
|
|---|
| 69 | APIRET rc; /* result code of I/O request */
|
|---|
| 70 |
|
|---|
| 71 | } IOREQUEST, *PIOREQUEST;
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | typedef struct _Globals
|
|---|
| 75 | {
|
|---|
| 76 | HEV hevIOEvent; /* asynchronous I/O event completed ! */
|
|---|
| 77 | TID tidIO; /* I/O thread */
|
|---|
| 78 | } GLOBALS, *PGLOBALS;
|
|---|
| 79 |
|
|---|
| 80 | static GLOBALS Globals;
|
|---|
| 81 |
|
|---|
| 82 |
|
|---|
| 83 | /*****************************************************************************
|
|---|
| 84 | * Name :
|
|---|
| 85 | * Purpose :
|
|---|
| 86 | * Parameters:
|
|---|
| 87 | * Variables :
|
|---|
| 88 | * Result :
|
|---|
| 89 | * Remark :
|
|---|
| 90 | * Status :
|
|---|
| 91 | *
|
|---|
| 92 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
|---|
| 93 | *****************************************************************************/
|
|---|
| 94 |
|
|---|
| 95 | DWORD WIN32API SleepEx(DWORD dwTimeout,
|
|---|
| 96 | BOOL fAlertable)
|
|---|
| 97 | {
|
|---|
| 98 |
|
|---|
| 99 | dprintf(("KERNEL32: SleepEx(%u,%u)\n",
|
|---|
| 100 | dwTimeout,
|
|---|
| 101 | fAlertable));
|
|---|
| 102 |
|
|---|
| 103 | /* @@@PH could be implemented as a timed wait on a event semaphore */
|
|---|
| 104 | /* for the WAIT_IO_COMPLETION flag */
|
|---|
| 105 |
|
|---|
| 106 | if (fAlertable == FALSE)
|
|---|
| 107 | DosSleep(dwTimeout);
|
|---|
| 108 | else {
|
|---|
| 109 | dprintf(("SleepEx: Wait for io completion not supported!"));
|
|---|
| 110 | DosSleep(1);
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | return (0);
|
|---|
| 114 | }
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 | /*****************************************************************************
|
|---|
| 118 | * Name : BOOL ReadFileEx
|
|---|
| 119 | * Purpose : The ReadFileEx function reads data from a file asynchronously.
|
|---|
| 120 | * It is designed solely for asynchronous operation, unlike the
|
|---|
| 121 | * ReadFile function, which is designed for both synchronous and
|
|---|
| 122 | * asynchronous operation. ReadFileEx lets an application perform
|
|---|
| 123 | * other processing during a file read operation.
|
|---|
| 124 | * The ReadFileEx function reports its completion status asynchronously,
|
|---|
| 125 | * calling a specified completion routine when reading is completed
|
|---|
| 126 | * and the calling thread is in an alertable wait state.
|
|---|
| 127 | * Parameters: HANDLE hFile handle of file to read
|
|---|
| 128 | * LPVOID lpBuffer address of buffer
|
|---|
| 129 | * DWORD nNumberOfBytesToRead number of bytes to read
|
|---|
| 130 | * LPOVERLAPPED lpOverlapped address of offset
|
|---|
| 131 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
|---|
| 132 | * Variables :
|
|---|
| 133 | * Result : TRUE / FALSE
|
|---|
| 134 | * Remark :
|
|---|
| 135 | * Status : UNTESTED STUB
|
|---|
| 136 | *
|
|---|
| 137 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 138 | *****************************************************************************/
|
|---|
| 139 |
|
|---|
| 140 | #define LPOVERLAPPED_COMPLETION_ROUTINE LPVOID
|
|---|
| 141 |
|
|---|
| 142 | DWORD WIN32API ReadFileEx(HANDLE hFile,
|
|---|
| 143 | LPVOID lpBuffer,
|
|---|
| 144 | DWORD nNumberOfBytesToRead,
|
|---|
| 145 | LPOVERLAPPED lpOverlapped,
|
|---|
| 146 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
|---|
| 147 | {
|
|---|
| 148 | dprintf(("Kernel32: ReadFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 149 | hFile,
|
|---|
| 150 | lpBuffer,
|
|---|
| 151 | nNumberOfBytesToRead,
|
|---|
| 152 | lpOverlapped,
|
|---|
| 153 | lpCompletionRoutine));
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | return (FALSE);
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | /*****************************************************************************
|
|---|
| 161 | * Name : BOOL WriteFileEx
|
|---|
| 162 | * Purpose : The WriteFileEx function writes data to a file. It is designed
|
|---|
| 163 | * solely for asynchronous operation, unlike WriteFile, which is
|
|---|
| 164 | * designed for both synchronous and asynchronous operation.
|
|---|
| 165 | * WriteFileEx reports its completion status asynchronously,
|
|---|
| 166 | * calling a specified completion routine when writing is completed
|
|---|
| 167 | * and the calling thread is in an alertable wait state.
|
|---|
| 168 | * Parameters: HANDLE hFile handle of file to write
|
|---|
| 169 | * LPVOID lpBuffer address of buffer
|
|---|
| 170 | * DWORD nNumberOfBytesToRead number of bytes to write
|
|---|
| 171 | * LPOVERLAPPED lpOverlapped address of offset
|
|---|
| 172 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
|---|
| 173 | * Variables :
|
|---|
| 174 | * Result : TRUE / FALSE
|
|---|
| 175 | * Remark :
|
|---|
| 176 | * Status : UNTESTED STUB
|
|---|
| 177 | *
|
|---|
| 178 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
|---|
| 179 | *****************************************************************************/
|
|---|
| 180 |
|
|---|
| 181 | DWORD WIN32API WriteFileEx(HANDLE hFile,
|
|---|
| 182 | LPVOID lpBuffer,
|
|---|
| 183 | DWORD nNumberOfBytesToWrite,
|
|---|
| 184 | LPOVERLAPPED lpOverlapped,
|
|---|
| 185 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
|---|
| 186 | {
|
|---|
| 187 | dprintf(("Kernel32: WriteFileEx(%08xh,%08xh,%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 188 | hFile,
|
|---|
| 189 | lpBuffer,
|
|---|
| 190 | nNumberOfBytesToWrite,
|
|---|
| 191 | lpOverlapped,
|
|---|
| 192 | lpCompletionRoutine));
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 | return (FALSE);
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 | #endif /* _ASYNCIOSUBSYSTEM_H_ */
|
|---|