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