Added stubs for HttpEndRequestA/W, InternetReadFileExA/W,
[wine/gsoc_dplay.git] / dlls / ntdll / sync.c
blob206ee7d4a36a5ac4c5ec03c8b49ccbb628eb52a1
1 /*
2 * Process synchronisation
4 * Copyright 1999, 2000 Juergen Schmied
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <time.h>
25 #include "wine/debug.h"
27 #include "winerror.h"
28 #include "wine/unicode.h"
29 #include "wine/server.h"
30 #include "winternl.h"
31 #include "ntdll_misc.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(ntdll);
37 * Semaphores
40 /******************************************************************************
41 * NtCreateSemaphore (NTDLL.@)
43 NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
44 IN ACCESS_MASK access,
45 IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
46 IN ULONG InitialCount,
47 IN ULONG MaximumCount )
49 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
50 NTSTATUS ret;
52 if ((MaximumCount <= 0) || (InitialCount > MaximumCount))
53 return STATUS_INVALID_PARAMETER;
55 SERVER_START_REQ( create_semaphore )
57 req->initial = InitialCount;
58 req->max = MaximumCount;
59 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
60 if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
61 ret = wine_server_call( req );
62 *SemaphoreHandle = reply->handle;
64 SERVER_END_REQ;
65 return ret;
68 /******************************************************************************
69 * NtOpenSemaphore (NTDLL.@)
71 NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
72 IN ACCESS_MASK access,
73 IN const OBJECT_ATTRIBUTES *attr )
75 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
76 NTSTATUS ret;
78 SERVER_START_REQ( open_semaphore )
80 req->access = access;
81 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
82 if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
83 ret = wine_server_call( req );
84 *SemaphoreHandle = reply->handle;
86 SERVER_END_REQ;
87 return ret;
90 /******************************************************************************
91 * NtQuerySemaphore (NTDLL.@)
93 NTSTATUS WINAPI NtQuerySemaphore(
94 HANDLE SemaphoreHandle,
95 PVOID SemaphoreInformationClass,
96 OUT PVOID SemaphoreInformation,
97 ULONG Length,
98 PULONG ReturnLength)
100 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
101 SemaphoreHandle, SemaphoreInformationClass, SemaphoreInformation, Length, ReturnLength);
102 return STATUS_SUCCESS;
105 /******************************************************************************
106 * NtReleaseSemaphore (NTDLL.@)
108 NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
110 NTSTATUS ret;
111 SERVER_START_REQ( release_semaphore )
113 req->handle = handle;
114 req->count = count;
115 if (!(ret = wine_server_call( req )))
117 if (previous) *previous = reply->prev_count;
120 SERVER_END_REQ;
121 return ret;
125 * Events
128 /**************************************************************************
129 * NtCreateEvent (NTDLL.@)
130 * ZwCreateEvent (NTDLL.@)
132 NTSTATUS WINAPI NtCreateEvent(
133 OUT PHANDLE EventHandle,
134 IN ACCESS_MASK DesiredAccess,
135 IN const OBJECT_ATTRIBUTES *attr,
136 IN BOOLEAN ManualReset,
137 IN BOOLEAN InitialState)
139 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
140 NTSTATUS ret;
142 SERVER_START_REQ( create_event )
144 req->manual_reset = ManualReset;
145 req->initial_state = InitialState;
146 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
147 if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
148 ret = wine_server_call( req );
149 *EventHandle = reply->handle;
151 SERVER_END_REQ;
152 return ret;
155 /******************************************************************************
156 * NtOpenEvent (NTDLL.@)
157 * ZwOpenEvent (NTDLL.@)
159 NTSTATUS WINAPI NtOpenEvent(
160 OUT PHANDLE EventHandle,
161 IN ACCESS_MASK DesiredAccess,
162 IN const OBJECT_ATTRIBUTES *attr )
164 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
165 NTSTATUS ret;
167 SERVER_START_REQ( open_event )
169 req->access = DesiredAccess;
170 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
171 if (len) wine_server_add_data( req, attr->ObjectName->Buffer, len );
172 ret = wine_server_call( req );
173 *EventHandle = reply->handle;
175 SERVER_END_REQ;
176 return ret;
180 /******************************************************************************
181 * NtSetEvent (NTDLL.@)
182 * ZwSetEvent (NTDLL.@)
184 NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
186 NTSTATUS ret;
188 /* FIXME: set NumberOfThreadsReleased */
190 SERVER_START_REQ( event_op )
192 req->handle = handle;
193 req->op = SET_EVENT;
194 ret = wine_server_call( req );
196 SERVER_END_REQ;
197 return ret;
200 /******************************************************************************
201 * NtResetEvent (NTDLL.@)
203 NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
205 NTSTATUS ret;
207 /* resetting an event can't release any thread... */
208 if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0;
210 SERVER_START_REQ( event_op )
212 req->handle = handle;
213 req->op = RESET_EVENT;
214 ret = wine_server_call( req );
216 SERVER_END_REQ;
217 return ret;
220 /******************************************************************************
221 * NtClearEvent (NTDLL.@)
223 * FIXME
224 * same as NtResetEvent ???
226 NTSTATUS WINAPI NtClearEvent ( HANDLE handle )
228 return NtResetEvent( handle, NULL );
231 /******************************************************************************
232 * NtPulseEvent (NTDLL.@)
234 * FIXME
235 * PulseCount
237 NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
239 NTSTATUS ret;
240 FIXME("(0x%08x,%p)\n", handle, PulseCount);
241 SERVER_START_REQ( event_op )
243 req->handle = handle;
244 req->op = PULSE_EVENT;
245 ret = wine_server_call( req );
247 SERVER_END_REQ;
248 return ret;
251 /******************************************************************************
252 * NtQueryEvent (NTDLL.@)
254 NTSTATUS WINAPI NtQueryEvent (
255 IN HANDLE EventHandle,
256 IN UINT EventInformationClass,
257 OUT PVOID EventInformation,
258 IN ULONG EventInformationLength,
259 OUT PULONG ReturnLength)
261 FIXME("(0x%08x)\n", EventHandle);
262 return STATUS_SUCCESS;