| 1 | /* $Id: async.cpp,v 1.9 2000-09-15 13:24:29 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 |  | 
|---|
| 15 | /***************************************************************************** | 
|---|
| 16 | * Remark                                                                    * | 
|---|
| 17 | ***************************************************************************** | 
|---|
| 18 |  | 
|---|
| 19 | ReadFileEx | 
|---|
| 20 |  | 
|---|
| 21 | */ | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 |  | 
|---|
| 25 | /***************************************************************************** | 
|---|
| 26 | * Includes                                                                  * | 
|---|
| 27 | *****************************************************************************/ | 
|---|
| 28 |  | 
|---|
| 29 | #define  INCL_WIN | 
|---|
| 30 | #define  INCL_DOSMEMMGR | 
|---|
| 31 | #define  INCL_DOSSEMAPHORES | 
|---|
| 32 | #define  INCL_DOSERRORS | 
|---|
| 33 | #define  INCL_DOSPROCESS | 
|---|
| 34 | #define  INCL_DOSMODULEMGR | 
|---|
| 35 | #define  INCL_VIO | 
|---|
| 36 | #define  INCL_AVIO | 
|---|
| 37 | #include <os2wrap.h>    //Odin32 OS/2 api wrappers | 
|---|
| 38 | #include <builtin.h> | 
|---|
| 39 |  | 
|---|
| 40 | #include <stdlib.h> | 
|---|
| 41 | #include <string.h> | 
|---|
| 42 | #include "win32type.h" | 
|---|
| 43 | #include "misc.h" | 
|---|
| 44 | #include "unicode.h" | 
|---|
| 45 |  | 
|---|
| 46 | #include "conwin.h"          // Windows Header for console only | 
|---|
| 47 | #include "handlemanager.h" | 
|---|
| 48 |  | 
|---|
| 49 | #define DBG_LOCALLOG    DBG_async | 
|---|
| 50 | #include "dbglocal.h" | 
|---|
| 51 |  | 
|---|
| 52 |  | 
|---|
| 53 | /***************************************************************************** | 
|---|
| 54 | * Defines & Macros                                                          * | 
|---|
| 55 | *****************************************************************************/ | 
|---|
| 56 |  | 
|---|
| 57 |  | 
|---|
| 58 | /***************************************************************************** | 
|---|
| 59 | * Structures                                                                * | 
|---|
| 60 | *****************************************************************************/ | 
|---|
| 61 |  | 
|---|
| 62 | typedef struct _IORequest | 
|---|
| 63 | { | 
|---|
| 64 | struct _IORequest *pNext;                   /* pointer to next I/O request */ | 
|---|
| 65 |  | 
|---|
| 66 | APIRET rc;                                   /* result code of I/O request */ | 
|---|
| 67 |  | 
|---|
| 68 | } IOREQUEST, *PIOREQUEST; | 
|---|
| 69 |  | 
|---|
| 70 |  | 
|---|
| 71 | typedef struct _Globals | 
|---|
| 72 | { | 
|---|
| 73 | HEV hevIOEvent;                      /* asynchronous I/O event completed ! */ | 
|---|
| 74 | TID tidIO;                           /* I/O thread                         */ | 
|---|
| 75 | } GLOBALS, *PGLOBALS; | 
|---|
| 76 |  | 
|---|
| 77 | static GLOBALS Globals; | 
|---|
| 78 |  | 
|---|
| 79 |  | 
|---|
| 80 | /***************************************************************************** | 
|---|
| 81 | * Name      : | 
|---|
| 82 | * Purpose   : | 
|---|
| 83 | * Parameters: | 
|---|
| 84 | * Variables : | 
|---|
| 85 | * Result    : | 
|---|
| 86 | * Remark    : | 
|---|
| 87 | * Status    : | 
|---|
| 88 | * | 
|---|
| 89 | * Author    : Patrick Haller [Tue, 1998/02/10 01:55] | 
|---|
| 90 | *****************************************************************************/ | 
|---|
| 91 |  | 
|---|
| 92 | DWORD WIN32API SleepEx(DWORD dwTimeout, | 
|---|
| 93 | BOOL  fAlertable) | 
|---|
| 94 | { | 
|---|
| 95 |  | 
|---|
| 96 | dprintf(("KERNEL32:  SleepEx(%u,%u)\n", | 
|---|
| 97 | dwTimeout, | 
|---|
| 98 | fAlertable)); | 
|---|
| 99 |  | 
|---|
| 100 | /* @@@PH could be implemented as a timed wait on a event semaphore */ | 
|---|
| 101 | /*       for the WAIT_IO_COMPLETION flag                           */ | 
|---|
| 102 |  | 
|---|
| 103 | if (fAlertable == FALSE) | 
|---|
| 104 | DosSleep(dwTimeout); | 
|---|
| 105 | else { | 
|---|
| 106 | dprintf(("SleepEx: Wait for io completion not supported!")); | 
|---|
| 107 | DosSleep(1); | 
|---|
| 108 | } | 
|---|
| 109 |  | 
|---|
| 110 | return (0); | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|