Changeset 9748 for trunk/src/kernel32/hmevent.cpp
- Timestamp:
- Feb 4, 2003, 12:29:03 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/hmevent.cpp
r6084 r9748 1 /* $Id: hmevent.cpp,v 1. 8 2001-06-23 16:59:27 sandervl Exp $ */1 /* $Id: hmevent.cpp,v 1.9 2003-02-04 11:28:57 sandervl Exp $ */ 2 2 3 3 /* … … 30 30 *****************************************************************************/ 31 31 32 #ifdef USE_OS2SEMAPHORES33 #define INCL_DOSSEMAPHORES34 #define INCL_DOSERRORS35 #include <os2wrap.h>36 #include <win32type.h>37 #include <win32api.h>38 #include <winconst.h>39 #else40 32 #include <os2win.h> 41 #endif42 33 43 34 #include <stdlib.h> … … 53 44 #define DBG_LOCALLOG DBG_hmevent 54 45 #include "dbglocal.h" 55 56 #ifndef DCE_AUTORESET57 #define DCE_AUTORESET 0x1000 /* DosCreateEventSem option to auto-reset */58 /* event semaphore on post. */59 #define DCE_POSTONE 0x0800 /* DosCreateEventSem option to post only */60 /* waiter and auto-reset the semaphore when*/61 /* there are multiple waiters. */62 #endif63 46 64 47 /***************************************************************************** … … 93 76 LPCTSTR lpszEventName) 94 77 { 95 #ifdef USE_OS2SEMAPHORES96 APIRET rc;97 HEV hev;98 char szSemName[CCHMAXPATH];99 100 dprintf(("KERNEL32: HandleManager::Event::CreateEvent(%08xh,%08xh,%08xh,%08xh,%s)\n",101 pHMHandleData,102 lpsa,103 fManualReset,104 fInitialState,105 lpszEventName));106 107 if(lpszEventName) {108 strcpy(szSemName, "\\SEM32\\");109 strcat(szSemName, lpszEventName);110 lpszEventName = szSemName;111 FixSemName((char *)lpszEventName);112 }113 //Manual reset means all threads waiting on the event semaphore will be114 //unblocked and the app must manually reset the event semaphore115 //Automatic reset -> only one waiting thread unblocked & state reset116 rc = DosCreateEventSem(lpszEventName, &hev, (fManualReset) ? 0 : (DCE_POSTONE|DCE_AUTORESET), fInitialState);117 118 if(rc) {119 dprintf(("DosCreateEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));120 pHMHandleData->hHMHandle = 0;121 return error2WinError(rc);122 }123 pHMHandleData->dwAccess = EVENT_ALL_ACCESS_W;124 pHMHandleData->dwFlags = fManualReset;125 pHMHandleData->hHMHandle = hev;126 pHMHandleData->dwInternalType = HMTYPE_EVENTSEM;127 return ERROR_SUCCESS_W;128 #else129 78 HANDLE hOpen32; 130 79 … … 147 96 } 148 97 else 149 return (O32_GetLastError()); 150 #endif 98 return (GetLastError()); 151 99 } 152 100 … … 168 116 LPCTSTR lpszEventName) 169 117 { 170 #ifdef USE_OS2SEMAPHORES171 HEV hev;172 APIRET rc;173 char szSemName[CCHMAXPATH];174 175 dprintf(("KERNEL32: HandleManager::Event::OpenEvent(%08xh,%08xh,%s)\n",176 pHMHandleData,177 fInheritHandle,178 lpszEventName));179 180 if(lpszEventName == NULL) {181 pHMHandleData->hHMHandle = 0;182 return ERROR_INVALID_PARAMETER_W;183 }184 185 strcpy(szSemName, "\\SEM32\\");186 strcat(szSemName, lpszEventName);187 FixSemName(szSemName);188 rc = DosOpenEventSem(szSemName, &hev);189 if(rc) {190 dprintf(("DosOpenEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));191 pHMHandleData->hHMHandle = 0;192 return error2WinError(rc);193 }194 pHMHandleData->dwInternalType = HMTYPE_EVENTSEM;195 pHMHandleData->hHMHandle = hev;196 return ERROR_SUCCESS_W;197 #else198 118 HANDLE hOpen32; 199 119 … … 213 133 } 214 134 else 215 return (O32_GetLastError()); 216 #endif 135 return (GetLastError()); 217 136 } 218 219 /*****************************************************************************220 * Name : HMDeviceEventClass::CloseHandle221 * Purpose : close the handle222 * Parameters: PHMHANDLEDATA pHMHandleData223 * Variables :224 * Result : API returncode225 * Remark :226 * Status :227 *228 * Author :229 *****************************************************************************/230 231 #ifdef USE_OS2SEMAPHORES232 BOOL HMDeviceEventClass::CloseHandle(PHMHANDLEDATA pHMHandleData)233 {234 APIRET rc;235 236 if(pHMHandleData->hHMHandle) {237 rc = DosCloseEventSem((HEV)pHMHandleData->hHMHandle);238 if(rc) {239 dprintf(("DosCloseEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));240 SetLastError(error2WinError(rc));241 return FALSE;242 }243 }244 return TRUE;245 }246 #endif247 248 /*****************************************************************************249 * Name : HMDeviceEventClass::DuplicateHandle250 * Purpose :251 * Parameters:252 * various parameters as required253 * Variables :254 * Result :255 * Remark : the standard behaviour is to return an error code for non-256 * existant request codes257 * Status :258 *259 * Author :260 *****************************************************************************/261 #ifdef USE_OS2SEMAPHORES262 BOOL HMDeviceEventClass::DuplicateHandle(PHMHANDLEDATA pHMHandleData, HANDLE srcprocess,263 PHMHANDLEDATA pHMSrcHandle,264 HANDLE destprocess,265 PHANDLE desthandle,266 DWORD fdwAccess,267 BOOL fInherit,268 DWORD fdwOptions,269 DWORD fdwOdinOptions)270 {271 APIRET rc;272 HEV hev;273 274 dprintf(("KERNEL32:HandleManager::DuplicateHandle %s(%08x,%08x,%08x,%08x,%08x) - NOT IMPLEMENTED!!!!!!!!\n",275 lpHMDeviceName,276 pHMHandleData,277 srcprocess, pHMSrcHandle, destprocess, desthandle));278 279 if(srcprocess != destprocess) {280 DebugInt3();281 SetLastError(ERROR_ACCESS_DENIED_W);282 return FALSE;283 }284 hev = (HEV)pHMSrcHandle->hHMHandle;285 rc = DosOpenEventSem(NULL, &hev);286 if(rc) {287 dprintf(("DosOpenEventSem %x failed with rc %d", pHMSrcHandle->hHMHandle, rc));288 pHMHandleData->hHMHandle = 0;289 SetLastError(error2WinError(rc));290 return FALSE;291 }292 pHMHandleData->dwAccess = fdwAccess;293 pHMHandleData->dwFlags = pHMSrcHandle->dwFlags; //fManualReset294 pHMHandleData->hHMHandle = hev;295 pHMHandleData->dwInternalType = HMTYPE_EVENTSEM;296 SetLastError(ERROR_SUCCESS_W);297 return TRUE;298 }299 #endif300 301 #ifdef USE_OS2SEMAPHORES302 /*****************************************************************************303 * Name : DWORD HMDeviceEventClass::WaitForSingleObject304 * Purpose : object synchronization305 * Parameters: PHMHANDLEDATA pHMHandleData306 * DWORD dwTimeout307 * Variables :308 * Result : API returncode309 * Remark :310 * Status :311 *312 * Author : SvL313 *****************************************************************************/314 315 DWORD HMDeviceEventClass::WaitForSingleObject(PHMHANDLEDATA pHMHandleData,316 DWORD dwTimeout)317 {318 DWORD rc;319 320 dprintf2(("KERNEL32: HMDeviceEventClass::WaitForSingleObject(%08xh %08xh)",321 pHMHandleData->hHMHandle, dwTimeout));322 323 if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )324 {325 dprintf(("ERROR: Access denied!!"));326 SetLastError(ERROR_ACCESS_DENIED_W);327 return WAIT_FAILED_W;328 }329 330 rc = DosWaitEventSem(pHMHandleData->hHMHandle, dwTimeout);331 if(rc && rc != ERROR_INTERRUPT && rc != ERROR_TIMEOUT && rc != ERROR_SEM_OWNER_DIED) {332 dprintf(("DosWaitEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));333 SetLastError(error2WinError(rc));334 return WAIT_FAILED_W;335 }336 SetLastError(ERROR_SUCCESS_W);337 if(rc == ERROR_INTERRUPT || rc == ERROR_SEM_OWNER_DIED) {338 return WAIT_ABANDONED_W;339 }340 else341 if(rc == ERROR_TIMEOUT) {342 return WAIT_TIMEOUT_W;343 }344 return WAIT_OBJECT_0_W;345 }346 #endif347 348 #ifdef USE_OS2SEMAPHORES349 /*****************************************************************************350 * Name : DWORD HMDeviceEventClass::WaitForSingleObjectEx351 * Purpose : object synchronization352 * Parameters: PHMHANDLEDATA pHMHandleData353 * DWORD dwTimeout354 * BOOL fAlertable355 * Variables :356 * Result : API returncode357 * Remark :358 * Status :359 *360 * Author : SvL361 *****************************************************************************/362 363 DWORD HMDeviceEventClass::WaitForSingleObjectEx(PHMHANDLEDATA pHMHandleData,364 DWORD dwTimeout,365 BOOL fAlertable)366 {367 dprintf2(("KERNEL32: HMDeviceEventClass::WaitForSingleObjectEx(%08xh,%08h,%08xh) not implemented correctly.\n",368 pHMHandleData->hHMHandle, dwTimeout, fAlertable));369 370 if(!(pHMHandleData->dwAccess & SYNCHRONIZE_W) )371 {372 dprintf(("ERROR: Access denied!!"));373 SetLastError(ERROR_ACCESS_DENIED_W);374 return WAIT_FAILED_W;375 }376 377 return WaitForSingleObject(pHMHandleData, dwTimeout);378 }379 #endif380 381 #ifdef USE_OS2SEMAPHORES382 /*****************************************************************************383 * Name : BOOL HMDeviceEventClass::MsgWaitForMultipleObjects384 * Purpose :385 * Variables :386 * Result :387 * Remark :388 * Status :389 *390 * Author : SvL391 *****************************************************************************/392 DWORD HMDeviceEventClass::MsgWaitForMultipleObjects(PHMHANDLEDATA pHMHandleData,393 DWORD nCount,394 PHANDLE pHandles,395 BOOL fWaitAll,396 DWORD dwMilliseconds,397 DWORD dwWakeMask)398 {399 return HMSemMsgWaitForMultipleObjects(nCount, pHandles, fWaitAll, dwMilliseconds, dwWakeMask);400 }401 #endif402 403 #ifdef USE_OS2SEMAPHORES404 /*****************************************************************************405 * Name : BOOL HMDeviceHandler::WaitForMultipleObjects406 * Purpose :407 * Variables :408 * Result :409 * Remark :410 * Status :411 *412 * Author : SvL413 *****************************************************************************/414 DWORD HMDeviceEventClass::WaitForMultipleObjects(PHMHANDLEDATA pHMHandleData,415 DWORD cObjects,416 PHANDLE lphObjects,417 BOOL fWaitAll,418 DWORD dwTimeout)419 {420 return HMSemWaitForMultipleObjects(cObjects, lphObjects, fWaitAll, dwTimeout);421 }422 #endif423 137 424 138 /***************************************************************************** … … 436 150 BOOL HMDeviceEventClass::SetEvent(PHMHANDLEDATA pHMHandleData) 437 151 { 438 #ifdef USE_OS2SEMAPHORES439 APIRET rc;440 441 dprintf(("KERNEL32: HandleManager::Event::SetEvent(%08xh)\n",442 pHMHandleData->hHMHandle));443 444 if(!(pHMHandleData->dwAccess & EVENT_MODIFY_STATE_W) )445 {446 dprintf(("ERROR: Access denied!!"));447 SetLastError(ERROR_ACCESS_DENIED_W);448 return FALSE;449 }450 451 rc = DosPostEventSem(pHMHandleData->hHMHandle);452 if(rc && rc != ERROR_ALREADY_POSTED) {453 dprintf(("DosPostEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));454 SetLastError(error2WinError(rc));455 return FALSE;456 }457 SetLastError(ERROR_SUCCESS_W);458 return TRUE;459 #else460 152 dprintf(("KERNEL32: HandleManager::Event::SetEvent(%08xh)\n", 461 153 pHMHandleData->hHMHandle)); 462 154 463 155 return (O32_SetEvent(pHMHandleData->hHMHandle)); 464 #endif465 156 } 466 157 … … 480 171 BOOL HMDeviceEventClass::PulseEvent(PHMHANDLEDATA pHMHandleData) 481 172 { 482 #ifdef USE_OS2SEMAPHORES483 APIRET rc;484 ULONG count;485 486 dprintf2(("KERNEL32: HandleManager::Event::PulseEvent(%08xh)\n",487 pHMHandleData->hHMHandle));488 489 if(!(pHMHandleData->dwAccess & EVENT_MODIFY_STATE_W) )490 {491 dprintf(("ERROR: Access denied!!"));492 SetLastError(ERROR_ACCESS_DENIED_W);493 return FALSE;494 }495 496 rc = DosPostEventSem(pHMHandleData->hHMHandle);497 if(rc && rc != ERROR_ALREADY_POSTED) {498 dprintf(("DosPostEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));499 SetLastError(error2WinError(rc));500 return FALSE;501 }502 if(pHMHandleData->dwFlags == TRUE) {//fManualReset503 rc = DosResetEventSem(pHMHandleData->hHMHandle, &count);504 if(rc && rc != ERROR_ALREADY_RESET) {505 dprintf(("DosResetEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));506 SetLastError(error2WinError(rc));507 return FALSE;508 }509 }510 SetLastError(ERROR_SUCCESS_W);511 return TRUE;512 #else513 173 dprintf2(("KERNEL32: HandleManager::Event::PulseEvent(%08xh)\n", 514 174 pHMHandleData->hHMHandle)); 515 175 516 176 return (O32_PulseEvent(pHMHandleData->hHMHandle)); 517 #endif518 177 } 519 178 … … 533 192 BOOL HMDeviceEventClass::ResetEvent(PHMHANDLEDATA pHMHandleData) 534 193 { 535 #ifdef USE_OS2SEMAPHORES536 APIRET rc;537 ULONG count;538 539 dprintf2(("KERNEL32: HandleManager::Event::ResetEvent(%08xh)\n",540 pHMHandleData->hHMHandle));541 542 if(!(pHMHandleData->dwAccess & EVENT_MODIFY_STATE_W) )543 {544 dprintf(("ERROR: Access denied!!"));545 SetLastError(ERROR_ACCESS_DENIED_W);546 return FALSE;547 }548 549 rc = DosResetEventSem(pHMHandleData->hHMHandle, &count);550 if(rc && rc != ERROR_ALREADY_RESET) {551 dprintf(("DosResetEventSem %x failed with rc %d", pHMHandleData->hHMHandle, rc));552 SetLastError(error2WinError(rc));553 return FALSE;554 }555 SetLastError(ERROR_SUCCESS_W);556 return TRUE;557 #else558 194 dprintf2(("KERNEL32: HandleManager::Event::ResetEvent(%08xh)\n", 559 195 pHMHandleData->hHMHandle)); 560 196 561 197 return (O32_ResetEvent(pHMHandleData->hHMHandle)); 562 #endif563 198 } 564 199
Note:
See TracChangeset
for help on using the changeset viewer.