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

Last change on this file since 2802 was 2802, checked in by sandervl, 26 years ago

Added new logging feature

File size: 5.2 KB
Line 
1/* $Id: hmsemaphore.cpp,v 1.3 2000-02-16 14:24:00 sandervl 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#define DBG_LOCALLOG DBG_hmsemaphore
34#include "dbglocal.h"
35
36
37/*****************************************************************************
38 * Defines *
39 *****************************************************************************/
40
41/*****************************************************************************
42 * Structures *
43 *****************************************************************************/
44
45/*****************************************************************************
46 * Local Prototypes *
47 *****************************************************************************/
48
49
50/*****************************************************************************
51 * Name : HMCreateSemaphore
52 * Purpose : router function for CreateSemaphore
53 * Parameters:
54 * Variables :
55 * Result :
56 * Remark :
57 * Status :
58 *
59 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
60 *****************************************************************************/
61
62DWORD HMDeviceSemaphoreClass::CreateSemaphore(PHMHANDLEDATA pHMHandleData,
63 LPSECURITY_ATTRIBUTES lpsa,
64 LONG lInitialCount,
65 LONG lMaximumCount,
66 LPCTSTR lpszSemaphoreName)
67{
68 HANDLE hOpen32;
69
70 dprintf(("KERNEL32: HandleManager::Semaphore::CreateSemaphore(%08xh,%08xh,%08xh,%08xh,%s)\n",
71 pHMHandleData,
72 lpsa,
73 lInitialCount,
74 lMaximumCount,
75 lpszSemaphoreName));
76
77 hOpen32 = O32_CreateSemaphore(lpsa, // call Open32
78 lInitialCount,
79 lMaximumCount,
80 (LPTSTR)lpszSemaphoreName);
81
82 if (0 != hOpen32) // check success
83 {
84 pHMHandleData->hHMHandle = hOpen32; // save handle
85 return (NO_ERROR);
86 }
87 else
88 return (O32_GetLastError());
89}
90
91
92/*****************************************************************************
93 * Name : HMOpenSemaphore
94 * Purpose : router function for OpenSemaphore
95 * Parameters:
96 * Variables :
97 * Result :
98 * Remark :
99 * Status :
100 *
101 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
102 *****************************************************************************/
103
104DWORD HMDeviceSemaphoreClass::OpenSemaphore(PHMHANDLEDATA pHMHandleData,
105 BOOL fInheritHandle,
106 LPCTSTR lpszSemaphoreName)
107{
108 HANDLE hOpen32;
109
110 dprintf(("KERNEL32: HandleManager::Semaphore::OpenSemaphore(%08xh,%08xh,%s)\n",
111 pHMHandleData,
112 fInheritHandle,
113 lpszSemaphoreName));
114
115 hOpen32 = O32_OpenSemaphore(pHMHandleData->dwAccess, // call Open32
116 fInheritHandle,
117 lpszSemaphoreName);
118
119 if (0 != hOpen32) // check success
120 {
121 pHMHandleData->hHMHandle = hOpen32; // save handle
122 return (NO_ERROR);
123 }
124 else
125 return (O32_GetLastError());
126}
127
128
129/*****************************************************************************
130 * Name : HMReleaseSemaphore
131 * Purpose : router function for ReleaseSemaphore
132 * Parameters:
133 * Variables :
134 * Result :
135 * Remark :
136 * Status :
137 *
138 * Author : Patrick Haller [Tue, 1999/07/06 20:44]
139 *****************************************************************************/
140
141BOOL HMDeviceSemaphoreClass::ReleaseSemaphore(PHMHANDLEDATA pHMHandleData,
142 LONG cReleaseCount,
143 LPLONG lpPreviousCount)
144{
145 dprintf(("KERNEL32: HandleManager::Semaphore::ReleaseSemaphore(%08xh,%08xh,%08xh)\n",
146 pHMHandleData->hHMHandle,
147 cReleaseCount,
148 lpPreviousCount));
149
150 return (O32_ReleaseSemaphore(pHMHandleData->hHMHandle,
151 cReleaseCount,
152 lpPreviousCount));
153}
154
Note: See TracBrowser for help on using the repository browser.