Changeset 7550 for trunk/src/kernel32
- Timestamp:
- Dec 5, 2001, 7:06:02 PM (24 years ago)
- Location:
- trunk/src/kernel32
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/Fileio.cpp
r7549 r7550 1 /* $Id: Fileio.cpp,v 1.5 8 2001-12-05 14:15:55sandervl Exp $ */1 /* $Id: Fileio.cpp,v 1.59 2001-12-05 18:05:58 sandervl Exp $ */ 2 2 3 3 /* … … 679 679 return TRUE; 680 680 } 681 if(!lpOverlapped || !lpCompletionRoutine) { 682 dprintf(("!WARNING!: !lpOverlapped || !lpCompletionRoutine")); 683 SetLastError(ERROR_INVALID_PARAMETER); 684 return FALSE; 685 } 686 //SDK docs say ReadFileEx will fail if this condition is true 687 if(GetFileType(hFile) == FILE_TYPE_PIPE && (lpOverlapped->Offset || lpOverlapped->OffsetHigh)) { 688 dprintf(("!WARNING!: lpOverlapped->Offset & lpOverlapped->OffsetHigh must be ZERO for named pipes")); 689 SetLastError(ERROR_INVALID_PARAMETER); 690 return FALSE; 691 } 681 692 return (HMReadFile(hFile, 682 693 lpBuffer, … … 739 750 return TRUE; 740 751 } 741 752 if(!lpOverlapped || !lpCompletionRoutine) { 753 dprintf(("!WARNING!: !lpOverlapped || !lpCompletionRoutine")); 754 SetLastError(ERROR_INVALID_PARAMETER); 755 return FALSE; 756 } 757 //SDK docs say WriteFileEx will fail if this condition is true 758 if(GetFileType(hFile) == FILE_TYPE_PIPE && (lpOverlapped->Offset || lpOverlapped->OffsetHigh)) { 759 dprintf(("!WARNING!: lpOverlapped->Offset & lpOverlapped->OffsetHigh must be ZERO for named pipes")); 760 SetLastError(ERROR_INVALID_PARAMETER); 761 return FALSE; 762 } 742 763 return (HMWriteFile(hFile, 743 764 (LPVOID)lpBuffer, -
trunk/src/kernel32/conbuffer.cpp
r7549 r7550 1 /* $Id: conbuffer.cpp,v 1.1 6 2001-12-05 14:15:56sandervl Exp $ */1 /* $Id: conbuffer.cpp,v 1.17 2001-12-05 18:05:59 sandervl Exp $ */ 2 2 3 3 /* … … 276 276 #endif 277 277 278 /* check if we're called with non-existing line buffer */ 278 if(lpCompletionRoutine) { 279 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 280 } 281 282 /* check if we're called with non-existing line buffer */ 279 283 if (pConsoleBuffer->ppszLine == NULL) { 280 284 SetLastError(ERROR_OUTOFMEMORY_W); -
trunk/src/kernel32/conbuffervio.cpp
r7549 r7550 1 /* $Id: conbuffervio.cpp,v 1. 5 2001-12-05 14:15:57sandervl Exp $ */1 /* $Id: conbuffervio.cpp,v 1.6 2001-12-05 18:05:59 sandervl Exp $ */ 2 2 3 3 /* … … 120 120 #endif 121 121 122 if(lpCompletionRoutine) { 123 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 124 } 125 122 126 /* check if we're called with non-existing line buffer */ 123 127 if (pConsoleBuffer->ppszLine == NULL) { -
trunk/src/kernel32/conin.cpp
r7549 r7550 1 /* $Id: conin.cpp,v 1.1 6 2001-12-05 14:15:58sandervl Exp $ */1 /* $Id: conin.cpp,v 1.17 2001-12-05 18:05:59 sandervl Exp $ */ 2 2 3 3 /* … … 141 141 lpOverlapped); 142 142 #endif 143 144 if(lpCompletionRoutine) { 145 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 146 } 143 147 144 148 ulCounter = 0; /* read ascii chars from queue */ -
trunk/src/kernel32/conout.cpp
r7549 r7550 1 /* $Id: conout.cpp,v 1.1 3 2001-12-05 14:15:58sandervl Exp $ */1 /* $Id: conout.cpp,v 1.14 2001-12-05 18:06:00 sandervl Exp $ */ 2 2 3 3 /* … … 249 249 #endif 250 250 251 /* just prevent an endless loop, although this condition might never */ 252 /* be true ! */ 251 if(lpCompletionRoutine) { 252 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 253 } 254 255 /* just prevent an endless loop, although this condition might never */ 256 /* be true ! */ 253 257 if (pHMHandleData->hHMHandle != pConsoleGlobals->hConsoleBuffer) 254 258 { -
trunk/src/kernel32/hmcomm.cpp
r7549 r7550 1 /* $Id: hmcomm.cpp,v 1.2 6 2001-12-05 14:15:59sandervl Exp $ */1 /* $Id: hmcomm.cpp,v 1.27 2001-12-05 18:06:00 sandervl Exp $ */ 2 2 3 3 /* … … 323 323 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 324 324 } 325 if(lpCompletionRoutine) { 326 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 327 } 328 325 329 //testestestest 326 330 dprintf2(("Bytes to write:")); … … 384 388 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 385 389 dprintf(("!WARNING!: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 390 } 391 392 if(lpCompletionRoutine) { 393 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 386 394 } 387 395 -
trunk/src/kernel32/hmdisk.cpp
r7549 r7550 1 /* $Id: hmdisk.cpp,v 1.3 4 2001-12-05 14:16:00 sandervl Exp $ */1 /* $Id: hmdisk.cpp,v 1.35 2001-12-05 18:06:00 sandervl Exp $ */ 2 2 3 3 /* … … 1211 1211 } 1212 1212 1213 if(lpCompletionRoutine) { 1214 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1215 } 1216 1213 1217 //If we didn't get an OS/2 handle for the disk before, get one now 1214 1218 if(!pHMHandleData->hHMHandle) { … … 1368 1372 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 1369 1373 } 1374 if(lpCompletionRoutine) { 1375 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 1376 } 1370 1377 1371 1378 //If we didn't get an OS/2 handle for the disk before, get one now -
trunk/src/kernel32/hmfile.cpp
r7549 r7550 1 /* $Id: hmfile.cpp,v 1.3 2 2001-12-05 14:16:01 sandervl Exp $ */1 /* $Id: hmfile.cpp,v 1.33 2001-12-05 18:06:01 sandervl Exp $ */ 2 2 3 3 /* … … 464 464 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 465 465 } 466 if(lpCompletionRoutine) { 467 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 468 } 466 469 467 470 //SvL: DosRead doesn't like writing to memory addresses returned by -
trunk/src/kernel32/hmmailslot.cpp
r7549 r7550 1 /* $Id: hmmailslot.cpp,v 1. 6 2001-12-05 14:16:01 sandervl Exp $1 /* $Id: hmmailslot.cpp,v 1.7 2001-12-05 18:06:01 sandervl Exp $ 2 2 * 3 3 * Win32 mailslot APIs … … 368 368 lpNumberOfBytesRead, lpOverlapped)); 369 369 370 if(lpCompletionRoutine) { 371 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 372 } 373 370 374 if(lpNumberOfBytesRead) 371 375 *lpNumberOfBytesRead = 0; … … 417 421 lpNumberOfBytesWritten, lpOverlapped)); 418 422 423 if(lpCompletionRoutine) { 424 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 425 } 426 419 427 if(lpNumberOfBytesWritten) 420 428 *lpNumberOfBytesWritten = 0; -
trunk/src/kernel32/hmnul.cpp
r7549 r7550 1 /* $Id: hmnul.cpp,v 1. 2 2001-12-05 14:16:02sandervl Exp $ */1 /* $Id: hmnul.cpp,v 1.3 2001-12-05 18:06:01 sandervl Exp $ */ 2 2 3 3 /* … … 131 131 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 132 132 } 133 134 if(lpCompletionRoutine) { 135 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 136 } 133 137 134 138 // this is real NUL I/O … … 189 193 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 190 194 } 195 196 if(lpCompletionRoutine) { 197 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 198 } 191 199 192 200 // this is real NUL I/O -
trunk/src/kernel32/hmparport.cpp
r7549 r7550 1 /* $Id: hmparport.cpp,v 1.1 6 2001-12-05 14:16:04sandervl Exp $ */1 /* $Id: hmparport.cpp,v 1.17 2001-12-05 18:06:02 sandervl Exp $ */ 2 2 3 3 /* … … 352 352 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 353 353 } 354 if(lpCompletionRoutine) { 355 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 356 } 354 357 355 358 ret = OSLibDosWrite(pHMHandleData->hHMHandle, (LPVOID)lpBuffer, nNumberOfBytesToWrite, … … 407 410 if(!(pHMHandleData->dwFlags & FILE_FLAG_OVERLAPPED) && lpOverlapped) { 408 411 dprintf(("Warning: lpOverlapped != NULL & !FILE_FLAG_OVERLAPPED; sync operation")); 412 } 413 if(lpCompletionRoutine) { 414 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 409 415 } 410 416 -
trunk/src/kernel32/hmstd.cpp
r7549 r7550 1 /* $Id: hmstd.cpp,v 1. 6 2001-12-05 14:16:05sandervl Exp $ */1 /* $Id: hmstd.cpp,v 1.7 2001-12-05 18:06:02 sandervl Exp $ */ 2 2 3 3 /* … … 82 82 lpOverlapped)); 83 83 84 if(lpCompletionRoutine) { 85 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 86 } 84 87 85 88 if(lpNumberOfBytesRead == NULL) { … … 130 133 lpNumberOfBytesWritten = &byteswritten; 131 134 } 135 if(lpCompletionRoutine) { 136 dprintf(("!WARNING!: lpCompletionRoutine not supported -> fall back to sync IO")); 137 } 138 132 139 if(pHMHandleData->dwUserData == STD_INPUT_HANDLE) { 133 140 return FALSE; -
trunk/src/kernel32/kernel32.mak
r7480 r7550 1 # $Id: kernel32.mak,v 1. 19 2001-11-29 10:31:07 phallerExp $1 # $Id: kernel32.mak,v 1.20 2001-12-05 18:06:02 sandervl Exp $ 2 2 3 3 # … … 17 17 WRC_PREFIX_RESOURCE=1 18 18 !include ../../makefile.inc 19 20 19 21 20 # … … 71 70 $(OBJDIR)\hmopen32.obj \ 72 71 $(OBJDIR)\hmobjects.obj \ 72 $(OBJDIR)\overlappedio.obj \ 73 73 $(OBJDIR)\hmevent.obj \ 74 74 $(OBJDIR)\hmfile.obj \ -
trunk/src/kernel32/mmap.h
r5011 r7550 1 /* $Id: mmap.h,v 1. 19 2001-01-22 18:26:51sandervl Exp $ */1 /* $Id: mmap.h,v 1.20 2001-12-05 18:06:02 sandervl Exp $ */ 2 2 3 3 /* … … 107 107 private: 108 108 static Win32MemMap *memmaps; 109 Win32MemMap *next;109 Win32MemMap *next; 110 110 }; 111 111 //****************************************************************************** -
trunk/src/kernel32/overlappedio.cpp
r7549 r7550 1 /* $Id: overlappedio.cpp,v 1. 1 2001-12-05 14:16:38sandervl Exp $ */1 /* $Id: overlappedio.cpp,v 1.2 2001-12-05 18:06:02 sandervl Exp $ */ 2 2 3 3 /* 4 * Win32 overlapped IO class 5 * 6 * Copyright 2001 Sander van Leeuwen <sandervl@xs4all.nl> 7 * 4 8 * Project Odin Software License can be found in LICENSE.TXT 5 *6 * Win32 COM device access class7 *8 * 1999 Achim Hasenmueller <achimha@innotek.de>9 * 2001 Sander van Leeuwen <sandervl@xs4all.nl>10 *11 * TODO: Overlapped IO only supports one request at a time12 * TODO: Overlapped IO not thread safe13 9 * 14 10 */ … … 19 15 #include <string.h> 20 16 #include <handlemanager.h> 21 #include "handlenames.h"22 17 #include <heapstring.h> 23 #include "hmdevice.h" 24 #include "hmcomm.h" 18 #include "overlappedio.h" 25 19 #include "oslibdos.h" 26 20 … … 29 23 30 24 31 DWORD CALLBACK OverlappedIOEventThread(LPVOID lpThreadParam); 32 DWORD CALLBACK OverlappedIOReadWriteThread(LPVOID lpThreadParam); 33 34 //****************************************************************************** 35 //****************************************************************************** 36 37 38 //****************************************************************************** 39 //****************************************************************************** 25 //****************************************************************************** 26 //****************************************************************************** 27 OverlappedIOHandler::OverlappedIOHandler(LPOVERLAPPED_HANDLER lpReadHandler, 28 LPOVERLAPPED_HANDLER lpWriteHandler, 29 LPOVERLAPPED_HANDLER lpPollHandler) : 30 hThreadRead(0), hThreadWrite(0), hThreadPoll(0) 31 { 32 OverlappedIOError errcode = OutOfMemory; 33 34 pending = NULL; 35 this->lpReadHandler = lpReadHandler; 36 this->lpWriteHandler = lpWriteHandler; 37 this->lpPollHandler = lpPollHandler; 38 39 ::InitializeCriticalSection(&critsect); 40 hEventPoll = ::CreateEventA(NULL, TRUE, FALSE, NULL); 41 hEventRead = ::CreateEventA(NULL, TRUE, FALSE, NULL); 42 hEventWrite = ::CreateEventA(NULL, TRUE, FALSE, NULL); 43 hEventExit = ::CreateEventA(NULL, TRUE, FALSE, NULL); 44 if(!hEventPoll || !hEventRead || !hEventWrite || !hEventExit) 45 { 46 DebugInt3(); 47 errcode = EventCreationFailed; 48 goto failed; 49 } 50 51 DWORD dwThreadId; 52 LPOVERLAPPED_THREAD_PARAM threadparam; 53 54 threadparam = (LPOVERLAPPED_THREAD_PARAM)malloc(sizeof(OVERLAPPED_THREAD_PARAM)); 55 if(!threadparam) goto outofmem; 56 57 threadparam->fEvent = (lpWriteHandler) ? EVENT_READ : EVENT_READWRITE; 58 threadparam->lpOverlappedObj = this; 59 hThreadRead = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 60 if(lpWriteHandler) { 61 threadparam = (LPOVERLAPPED_THREAD_PARAM)malloc(sizeof(OVERLAPPED_THREAD_PARAM)); 62 if(!threadparam) goto outofmem; 63 threadparam->fEvent = EVENT_WRITE; 64 threadparam->lpOverlappedObj = this; 65 hThreadWrite = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 66 } 67 68 if(lpPollHandler) { 69 threadparam = (LPOVERLAPPED_THREAD_PARAM)malloc(sizeof(OVERLAPPED_THREAD_PARAM)); 70 if(!threadparam) goto outofmem; 71 threadparam->fEvent = EVENT_POLL; 72 threadparam->lpOverlappedObj = this; 73 hThreadPoll = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 74 } 75 76 if((lpPollHandler && !hThreadPoll) || !hThreadRead || (lpWriteHandler && !hThreadWrite)) 77 { 78 DebugInt3(); 79 errcode = ThreadCreationFailed; 80 goto failed; 81 } 82 return; 83 84 outofmem: 85 errcode = OutOfMemory; 86 //fall through 87 failed: 88 //SvL: NOTE: We might not failed gracefully when threads have already been 89 // created. (thread accessing memory that has been freed) 90 // Don't feel like wasting time to fix this as this should never 91 // happen anyway. 92 if(hEventExit) { 93 ::SetEvent(hEventExit); 94 ::CloseHandle(hEventExit); 95 } 96 97 if(hEventRead) ::CloseHandle(hEventRead); 98 if(hEventWrite) ::CloseHandle(hEventWrite); 99 if(hEventPoll) ::CloseHandle(hEventPoll); 100 101 if(hThreadRead) ::CloseHandle(hThreadRead); 102 if(hThreadPoll) ::CloseHandle(hThreadPoll); 103 if(hThreadWrite) ::CloseHandle(hThreadWrite); 104 ::DeleteCriticalSection(&critsect); 105 106 throw(errcode); 107 } 108 //****************************************************************************** 109 //****************************************************************************** 110 OverlappedIOHandler::~OverlappedIOHandler() 111 { 112 dprintf(("~OverlappedIOHandler: signalling overlapped serial threads")); 113 ::SetEvent(hEventExit); 114 115 ::CloseHandle(hEventExit); 116 ::CloseHandle(hEventRead); 117 ::CloseHandle(hEventWrite); 118 ::CloseHandle(hEventPoll); 119 120 ::CloseHandle(hThreadRead); 121 if(hThreadPoll) ::CloseHandle(hThreadPoll); 122 if(hThreadWrite) ::CloseHandle(hThreadWrite); 123 124 DeleteCriticalSection(&critsect); 125 } 126 //****************************************************************************** 127 //****************************************************************************** 128 DWORD CALLBACK OverlappedIOThread(LPVOID lpThreadParam) 129 { 130 LPOVERLAPPED_THREAD_PARAM threadparam = (LPOVERLAPPED_THREAD_PARAM)lpThreadParam; 131 DWORD fEvent; 132 OverlappedIOHandler *lpOverlappedObj; 133 134 if(threadparam == NULL) { 135 DebugInt3(); 136 return 0; 137 } 138 lpOverlappedObj = threadparam->lpOverlappedObj; 139 fEvent = threadparam->fEvent; 140 //free thread parameter first 141 free(threadparam); 142 143 return lpOverlappedObj->threadHandler(fEvent); 144 } 145 //****************************************************************************** 146 //****************************************************************************** 147 DWORD OverlappedIOHandler::threadHandler(DWORD fEvent) 148 { 149 HANDLE hEvents[2]; 150 DWORD ret; 151 152 dprintf(("OverlappedIOThread: started for event %d", fEvent)); 153 switch(fEvent) { 154 case EVENT_READ: 155 case EVENT_READWRITE: 156 hEvents[0] = hEventRead; 157 break; 158 159 case EVENT_WRITE: 160 hEvents[0] = hEventWrite; 161 break; 162 163 case EVENT_POLL: 164 hEvents[0] = hEventPoll; 165 break; 166 default: 167 DebugInt3(); 168 } 169 hEvents[1] = hEventExit; 170 171 while(TRUE) { 172 ret = WaitForMultipleObjects(2, hEvents, FALSE, INFINITE); 173 if(ret == WAIT_FAILED) { 174 dprintf(("!WARNING!: WaitForMultipleObjects -> WAIT_FAILED!")); 175 break; 176 } 177 if(ret == WAIT_FAILED) { 178 dprintf(("!WARNING!: WaitForMultipleObjects -> WAIT_FAILED!")); 179 break; 180 } 181 //if hEventExit has been signalled, then we are told to exit 182 if(ret == (WAIT_OBJECT_0+1)) { 183 dprintf(("end of threadHandler signalled")); 184 break; 185 } 186 } 187 return 0; 188 } 189 //****************************************************************************** 190 //****************************************************************************** 191 BOOL OverlappedIOHandler::WriteFile(HANDLE hOS2Handle, 192 LPCVOID lpBuffer, 193 DWORD nNumberOfBytesToWrite, 194 LPDWORD lpNumberOfBytesWritten, 195 LPOVERLAPPED lpOverlapped, 196 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 197 { 198 return FALSE; 199 } 200 //****************************************************************************** 201 //****************************************************************************** 202 BOOL OverlappedIOHandler::ReadFile(HANDLE hOS2Handle, 203 LPCVOID lpBuffer, 204 DWORD nNumberOfBytesToRead, 205 LPDWORD lpNumberOfBytesRead, 206 LPOVERLAPPED lpOverlapped, 207 LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine) 208 { 209 return FALSE; 210 } 211 //****************************************************************************** 212 //****************************************************************************** 213 BOOL OverlappedIOHandler::CancelIo(HANDLE hOS2Handle) 214 { 215 return FALSE; 216 } 217 //****************************************************************************** 218 //****************************************************************************** 219 BOOL OverlappedIOHandler::GetOverlappedResult(HANDLE hOS2Handle, 220 LPOVERLAPPED lpoOverlapped, 221 LPDWORD lpcbTransfer, 222 DWORD dwTimeout) 223 { 224 return FALSE; 225 } 226 //****************************************************************************** 227 //******************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.