Solve remaining problems with scroll bars in the edit control.
[wine.git] / dlls / ntdll / sync.c
blob82de172cc0760876e4db76924102bc60f0cd4671
1 /*
2 * Process synchronisation
3 */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <time.h>
9 #include "debugtools.h"
11 #include "winerror.h"
12 #include "wine/unicode.h"
13 #include "server.h"
14 #include "ntddk.h"
15 #include "ntdll_misc.h"
17 DEFAULT_DEBUG_CHANNEL(ntdll);
21 * Semaphores
24 /******************************************************************************
25 * NtCreateSemaphore
27 NTSTATUS WINAPI NtCreateSemaphore( OUT PHANDLE SemaphoreHandle,
28 IN ACCESS_MASK access,
29 IN const OBJECT_ATTRIBUTES *attr OPTIONAL,
30 IN ULONG InitialCount,
31 IN ULONG MaximumCount )
33 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
34 NTSTATUS ret;
36 if ((MaximumCount <= 0) || (InitialCount < 0) || (InitialCount > MaximumCount))
37 return STATUS_INVALID_PARAMETER;
39 SERVER_START_REQ
41 struct create_semaphore_request *req = server_alloc_req( sizeof(*req), len );
42 req->initial = InitialCount;
43 req->max = MaximumCount;
44 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
45 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
46 ret = server_call_noerr( REQ_CREATE_SEMAPHORE );
47 *SemaphoreHandle = req->handle;
49 SERVER_END_REQ;
50 return ret;
53 /******************************************************************************
54 * NtOpenSemaphore
56 NTSTATUS WINAPI NtOpenSemaphore( OUT PHANDLE SemaphoreHandle,
57 IN ACCESS_MASK access,
58 IN const OBJECT_ATTRIBUTES *attr )
60 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
61 NTSTATUS ret;
63 SERVER_START_REQ
65 struct open_semaphore_request *req = server_alloc_req( sizeof(*req), len );
66 req->access = access;
67 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
68 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
69 ret = server_call_noerr( REQ_OPEN_SEMAPHORE );
70 *SemaphoreHandle = req->handle;
72 SERVER_END_REQ;
73 return ret;
76 /******************************************************************************
77 * NtQuerySemaphore
79 NTSTATUS WINAPI NtQuerySemaphore(
80 HANDLE SemaphoreHandle,
81 PVOID SemaphoreInformationClass,
82 OUT PVOID SemaphoreInformation,
83 ULONG Length,
84 PULONG ReturnLength)
86 FIXME("(0x%08x,%p,%p,0x%08lx,%p) stub!\n",
87 SemaphoreHandle, SemaphoreInformationClass, SemaphoreInformation, Length, ReturnLength);
88 return STATUS_SUCCESS;
91 /******************************************************************************
92 * NtReleaseSemaphore
94 NTSTATUS WINAPI NtReleaseSemaphore( HANDLE handle, ULONG count, PULONG previous )
96 NTSTATUS ret;
97 SERVER_START_REQ
99 struct release_semaphore_request *req = server_alloc_req( sizeof(*req), 0 );
100 req->handle = handle;
101 req->count = count;
102 if (!(ret = server_call_noerr( REQ_RELEASE_SEMAPHORE )))
104 if (previous) *previous = req->prev_count;
107 SERVER_END_REQ;
108 return ret;
112 * Events
115 /**************************************************************************
116 * NtCreateEvent
118 NTSTATUS WINAPI NtCreateEvent(
119 OUT PHANDLE EventHandle,
120 IN ACCESS_MASK DesiredAccess,
121 IN const OBJECT_ATTRIBUTES *attr,
122 IN BOOLEAN ManualReset,
123 IN BOOLEAN InitialState)
125 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
126 NTSTATUS ret;
128 SERVER_START_REQ
130 struct create_event_request *req = server_alloc_req( sizeof(*req), len );
131 req->manual_reset = ManualReset;
132 req->initial_state = InitialState;
133 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
134 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
135 ret = server_call_noerr( REQ_CREATE_EVENT );
136 *EventHandle = req->handle;
138 SERVER_END_REQ;
139 return ret;
142 /******************************************************************************
143 * NtOpenEvent
145 NTSTATUS WINAPI NtOpenEvent(
146 OUT PHANDLE EventHandle,
147 IN ACCESS_MASK DesiredAccess,
148 IN const OBJECT_ATTRIBUTES *attr )
150 DWORD len = attr && attr->ObjectName ? attr->ObjectName->Length : 0;
151 NTSTATUS ret;
153 SERVER_START_REQ
155 struct open_event_request *req = server_alloc_req( sizeof(*req), len );
157 req->access = DesiredAccess;
158 req->inherit = attr && (attr->Attributes & OBJ_INHERIT);
159 if (len) memcpy( server_data_ptr(req), attr->ObjectName->Buffer, len );
160 ret = server_call_noerr( REQ_OPEN_EVENT );
161 *EventHandle = req->handle;
163 SERVER_END_REQ;
164 return ret;
168 /******************************************************************************
169 * NtSetEvent
171 NTSTATUS WINAPI NtSetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
173 NTSTATUS ret;
175 /* FIXME: set NumberOfThreadsReleased */
177 SERVER_START_REQ
179 struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
180 req->handle = handle;
181 req->op = SET_EVENT;
182 ret = server_call_noerr( REQ_EVENT_OP );
184 SERVER_END_REQ;
185 return ret;
188 /******************************************************************************
189 * NtResetEvent
191 NTSTATUS WINAPI NtResetEvent( HANDLE handle, PULONG NumberOfThreadsReleased )
193 NTSTATUS ret;
195 /* resetting an event can't release any thread... */
196 if (NumberOfThreadsReleased) *NumberOfThreadsReleased = 0;
198 SERVER_START_REQ
200 struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
201 req->handle = handle;
202 req->op = RESET_EVENT;
203 ret = server_call_noerr( REQ_EVENT_OP );
205 SERVER_END_REQ;
206 return ret;
209 /******************************************************************************
210 * NtClearEvent
212 * FIXME
213 * same as NtResetEvent ???
215 NTSTATUS WINAPI NtClearEvent ( HANDLE handle )
217 return NtResetEvent( handle, NULL );
220 /******************************************************************************
221 * NtPulseEvent
223 * FIXME
224 * PulseCount
226 NTSTATUS WINAPI NtPulseEvent( HANDLE handle, PULONG PulseCount )
228 NTSTATUS ret;
229 FIXME("(0x%08x,%p)\n", handle, PulseCount);
230 SERVER_START_REQ
232 struct event_op_request *req = server_alloc_req( sizeof(*req), 0 );
233 req->handle = handle;
234 req->op = PULSE_EVENT;
235 ret = server_call_noerr( REQ_EVENT_OP );
237 SERVER_END_REQ;
238 return ret;
241 /******************************************************************************
242 * NtQueryEvent
244 NTSTATUS WINAPI NtQueryEvent (
245 IN HANDLE EventHandle,
246 IN UINT EventInformationClass,
247 OUT PVOID EventInformation,
248 IN ULONG EventInformationLength,
249 OUT PULONG ReturnLength)
251 FIXME("(0x%08x)\n", EventHandle);
252 return STATUS_SUCCESS;