source: trunk/src/kernel32/hmsemaphore.cpp@ 278

Last change on this file since 278 was 278, checked in by phaller, 26 years ago

Add: HandleManager support for kernel objects, various fixes

File size: 5.1 KB
Line 
1/* $Id: hmsemaphore.cpp,v 1.1 1999-07-06 15:48:48 phaller Exp $ */
2
3/*
4 * Project Odin Software License can be found in LICENSE.TXT
5 * Win32 Unified Handle Manager for OS/2
6 * Copyright 1999 Patrick Haller (haller@zebra.fh-weingarten.de)
7 */
8
9#undef DEBUG_LOCAL
10//#define DEBUG_LOCAL
11
12
13/*****************************************************************************
14 * Remark *
15 *****************************************************************************
16
17 */
18
19
20/*****************************************************************************
21 * Includes *
22 *****************************************************************************/
23
24#include <os2win.h>
25#include <stdlib.h>
26#include <string.h>
27#include "unicode.h"
28#include "misc.h"
29
30#include "HandleManager.H"
31#include "HMSemaphore.h"
32
33
34/*****************************************************************************
35 * Defines *
36 *****************************************************************************/
37
38/*****************************************************************************
39 * Structures *
40 *****************************************************************************/
41
42/*****************************************************************************
43 * Local Prototypes *
44 *****************************************************************************/
45
46
47/*****************************************************************************
48 * Name : HMCreateSemaphore
49 * Purpose : router function for CreateSemaphore
50 * Parameters:
51 * Variables :
52 * Result :
53 * Remark :
54 * Status :
55 *
56 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
57 *****************************************************************************/
58
59DWORD HMDeviceSemaphoreClass::CreateSemaphore(PHMHANDLEDATA pHMHandleData,
60 LPSECURITY_ATTRIBUTES lpsa,
61 LONG lInitialCount,
62 LONG lMaximumCount,
63 LPCTSTR lpszSemaphoreName)
64{
65 HANDLE hOpen32;
66
67 dprintf(("KERNEL32: HandleManager::Semaphore::CreateSemaphore(%08xh,%08xh,%08xh,%08xh,%s)\n",
68 pHMHandleData,
69 lpsa,
70 lInitialCount,
71 lMaximumCount,
72 lpszSemaphoreName));
73
74 hOpen32 = O32_CreateSemaphore(lpsa, // call Open32
75 lInitialCount,
76 lMaximumCount,
77 (LPTSTR)lpszSemaphoreName);
78
79 if (INVALID_HANDLE_VALUE != hOpen32) // check success
80 {
81 pHMHandleData->hHMHandle = hOpen32; // save handle
82 return (NO_ERROR);
83 }
84 else
85 return (O32_GetLastError());
86}
87
88
89/*****************************************************************************
90 * Name : HMOpenSemaphore
91 * Purpose : router function for OpenSemaphore
92 * Parameters:
93 * Variables :
94 * Result :
95 * Remark :
96 * Status :
97 *
98 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
99 *****************************************************************************/
100
101DWORD HMDeviceSemaphoreClass::OpenSemaphore(PHMHANDLEDATA pHMHandleData,
102 BOOL fInheritHandle,
103 LPCTSTR lpszSemaphoreName)
104{
105 HANDLE hOpen32;
106
107 dprintf(("KERNEL32: HandleManager::Semaphore::OpenSemaphore(%08xh,%08xh,%s)\n",
108 pHMHandleData,
109 fInheritHandle,
110 lpszSemaphoreName));
111
112 hOpen32 = O32_OpenSemaphore(pHMHandleData->dwAccess, // call Open32
113 fInheritHandle,
114 lpszSemaphoreName);
115
116 if (INVALID_HANDLE_VALUE != hOpen32) // check success
117 {
118 pHMHandleData->hHMHandle = hOpen32; // save handle
119 return (NO_ERROR);
120 }
121 else
122 return (O32_GetLastError());
123}
124
125
126/*****************************************************************************
127 * Name : HMReleaseSemaphore
128 * Purpose : router function for ReleaseSemaphore
129 * Parameters:
130 * Variables :
131 * Result :
132 * Remark :
133 * Status :
134 *
135 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
136 *****************************************************************************/
137
138BOOL HMDeviceSemaphoreClass::ReleaseSemaphore(PHMHANDLEDATA pHMHandleData,
139 LONG cReleaseCount,
140 LPLONG lpPreviousCount)
141{
142 dprintf(("KERNEL32: HandleManager::Semaphore::ReleaseSemaphore(%08xh,%08xh,%08xh)\n",
143 pHMHandleData->hHMHandle,
144 cReleaseCount,
145 lpPreviousCount));
146
147 return (O32_ReleaseSemaphore(pHMHandleData->hHMHandle,
148 cReleaseCount,
149 lpPreviousCount));
150}
151
Note: See TracBrowser for help on using the repository browser.