source: trunk/src/kernel32/hmevent.cpp@ 9748

Last change on this file since 9748 was 9748, checked in by sandervl, 23 years ago

Support DuplicateHandle for threads; cleaned up semaphore code

File size: 6.2 KB
Line 
1/* $Id: hmevent.cpp,v 1.9 2003-02-04 11:28:57 sandervl Exp $ */
2
3/*
4 * Win32 Event Semaphore implementation
5 *
6 * TODO: Inheritance
7 * TODO: Does DCE_POSTONE work in Warp 3 or 4 with no FP applied?
8 * TODO: No inheritance when CreateEvent is called for existing named event semaphore?
9 * (see HMCreateEvent in handlemanager.cpp)
10 * TODO: Name collisions with files & mutex not allowed. Check if this can happen in OS/2
11 *
12 * Project Odin Software License can be found in LICENSE.TXT
13 *
14 * Copyright 2001 Sander van Leeuwen (sandervl@xs4all.nl)
15 */
16
17#undef DEBUG_LOCAL
18//#define DEBUG_LOCAL
19
20
21/*****************************************************************************
22 * Remark *
23 *****************************************************************************
24
25 */
26
27
28/*****************************************************************************
29 * Includes *
30 *****************************************************************************/
31
32#include <os2win.h>
33
34#include <stdlib.h>
35#include <string.h>
36#include "unicode.h"
37#include "misc.h"
38
39#include "HandleManager.H"
40#include "HMEvent.h"
41#include "HMSemaphore.h"
42#include "oslibdos.h"
43
44#define DBG_LOCALLOG DBG_hmevent
45#include "dbglocal.h"
46
47/*****************************************************************************
48 * Defines *
49 *****************************************************************************/
50
51/*****************************************************************************
52 * Structures *
53 *****************************************************************************/
54
55/*****************************************************************************
56 * Local Prototypes *
57 *****************************************************************************/
58
59
60/*****************************************************************************
61 * Name : HMCreateEvent
62 * Purpose : router function for CreateEvent
63 * Parameters:
64 * Variables :
65 * Result :
66 * Remark :
67 * Status :
68 *
69 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
70 *****************************************************************************/
71
72DWORD HMDeviceEventClass::CreateEvent(PHMHANDLEDATA pHMHandleData,
73 LPSECURITY_ATTRIBUTES lpsa,
74 BOOL fManualReset,
75 BOOL fInitialState,
76 LPCTSTR lpszEventName)
77{
78 HANDLE hOpen32;
79
80 dprintf(("KERNEL32: HandleManager::Event::CreateEvent(%08xh,%08xh,%08xh,%08xh,%s)\n",
81 pHMHandleData,
82 lpsa,
83 fManualReset,
84 fInitialState,
85 lpszEventName));
86
87 hOpen32 = O32_CreateEvent(lpsa, // call Open32
88 fManualReset,
89 fInitialState,
90 lpszEventName);
91
92 if (0 != hOpen32) // check success
93 {
94 pHMHandleData->hHMHandle = hOpen32; // save handle
95 return (NO_ERROR);
96 }
97 else
98 return (GetLastError());
99}
100
101
102/*****************************************************************************
103 * Name : HMOpenEvent
104 * Purpose : router function for OpenEvent
105 * Parameters:
106 * Variables :
107 * Result :
108 * Remark :
109 * Status :
110 *
111 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
112 *****************************************************************************/
113
114DWORD HMDeviceEventClass::OpenEvent(PHMHANDLEDATA pHMHandleData,
115 BOOL fInheritHandle,
116 LPCTSTR lpszEventName)
117{
118 HANDLE hOpen32;
119
120 dprintf(("KERNEL32: HandleManager::Event::OpenEvent(%08xh,%08xh,%s)\n",
121 pHMHandleData,
122 fInheritHandle,
123 lpszEventName));
124
125 hOpen32 = O32_OpenEvent(pHMHandleData->dwAccess, // call Open32
126 fInheritHandle,
127 lpszEventName);
128
129 if (0 != hOpen32) // check success
130 {
131 pHMHandleData->hHMHandle = hOpen32; // save handle
132 return (NO_ERROR);
133 }
134 else
135 return (GetLastError());
136}
137
138/*****************************************************************************
139 * Name : HMSetEvent
140 * Purpose : router function for SetEvent
141 * Parameters:
142 * Variables :
143 * Result :
144 * Remark :
145 * Status :
146 *
147 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
148 *****************************************************************************/
149
150BOOL HMDeviceEventClass::SetEvent(PHMHANDLEDATA pHMHandleData)
151{
152 dprintf(("KERNEL32: HandleManager::Event::SetEvent(%08xh)\n",
153 pHMHandleData->hHMHandle));
154
155 return (O32_SetEvent(pHMHandleData->hHMHandle));
156}
157
158
159/*****************************************************************************
160 * Name : HMPulseEvent
161 * Purpose : router function for PulseEvent
162 * Parameters:
163 * Variables :
164 * Result :
165 * Remark :
166 * Status :
167 *
168 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
169 *****************************************************************************/
170
171BOOL HMDeviceEventClass::PulseEvent(PHMHANDLEDATA pHMHandleData)
172{
173 dprintf2(("KERNEL32: HandleManager::Event::PulseEvent(%08xh)\n",
174 pHMHandleData->hHMHandle));
175
176 return (O32_PulseEvent(pHMHandleData->hHMHandle));
177}
178
179
180/*****************************************************************************
181 * Name : HMResetEvent
182 * Purpose : router function for ResetEvent
183 * Parameters:
184 * Variables :
185 * Result :
186 * Remark :
187 * Status :
188 *
189 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
190 *****************************************************************************/
191
192BOOL HMDeviceEventClass::ResetEvent(PHMHANDLEDATA pHMHandleData)
193{
194 dprintf2(("KERNEL32: HandleManager::Event::ResetEvent(%08xh)\n",
195 pHMHandleData->hHMHandle));
196
197 return (O32_ResetEvent(pHMHandleData->hHMHandle));
198}
199
Note: See TracBrowser for help on using the repository browser.