2 * Kernel synchronization objects
4 * Copyright 1998 Alexandre Julliard
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
22 #include "wine/port.h"
29 #ifdef HAVE_SYS_IOCTL_H
30 #include <sys/ioctl.h>
32 #ifdef HAVE_SYS_POLL_H
44 #include "wine/server.h"
45 #include "wine/unicode.h"
46 #include "wine/winbase16.h"
47 #include "kernel_private.h"
50 #include "wine/debug.h"
52 WINE_DEFAULT_DEBUG_CHANNEL(win32);
54 /* check if current version is NT or Win95 */
55 inline static int is_version_nt(void)
57 return !(GetVersion() & 0x80000000);
61 /***********************************************************************
64 VOID WINAPI Sleep( DWORD timeout )
66 SleepEx( timeout, FALSE );
69 /******************************************************************************
70 * SleepEx (KERNEL32.@)
72 DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable )
76 if (timeout == INFINITE) status = NtDelayExecution( alertable, NULL );
81 time.QuadPart = timeout * (ULONGLONG)10000;
82 time.QuadPart = -time.QuadPart;
83 status = NtDelayExecution( alertable, &time );
85 if (status != STATUS_USER_APC) status = STATUS_SUCCESS;
90 /***********************************************************************
91 * WaitForSingleObject (KERNEL32.@)
93 DWORD WINAPI WaitForSingleObject( HANDLE handle, DWORD timeout )
95 return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, FALSE );
99 /***********************************************************************
100 * WaitForSingleObjectEx (KERNEL32.@)
102 DWORD WINAPI WaitForSingleObjectEx( HANDLE handle, DWORD timeout,
105 return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, alertable );
109 /***********************************************************************
110 * WaitForMultipleObjects (KERNEL32.@)
112 DWORD WINAPI WaitForMultipleObjects( DWORD count, const HANDLE *handles,
113 BOOL wait_all, DWORD timeout )
115 return WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
119 /***********************************************************************
120 * WaitForMultipleObjectsEx (KERNEL32.@)
122 DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
123 BOOL wait_all, DWORD timeout,
127 HANDLE hloc[MAXIMUM_WAIT_OBJECTS];
130 if (count >= MAXIMUM_WAIT_OBJECTS)
132 SetLastError(ERROR_INVALID_PARAMETER);
135 for (i = 0; i < count; i++)
137 if ((handles[i] == (HANDLE)STD_INPUT_HANDLE) ||
138 (handles[i] == (HANDLE)STD_OUTPUT_HANDLE) ||
139 (handles[i] == (HANDLE)STD_ERROR_HANDLE))
140 hloc[i] = GetStdHandle( (DWORD)handles[i] );
142 hloc[i] = handles[i];
144 /* yes, even screen buffer console handles are waitable, and are
145 * handled as a handle to the console itself !!
147 if (is_console_handle(hloc[i]))
149 if (!VerifyConsoleIoHandle(hloc[i]))
153 hloc[i] = GetConsoleInputWaitHandle();
157 if (timeout == INFINITE)
159 status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, NULL );
165 time.QuadPart = timeout * (ULONGLONG)10000;
166 time.QuadPart = -time.QuadPart;
167 status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, &time );
170 if (HIWORD(status)) /* is it an error code? */
172 SetLastError( RtlNtStatusToDosError(status) );
173 status = WAIT_FAILED;
179 /***********************************************************************
180 * WaitForSingleObject (KERNEL.460)
182 DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
184 DWORD retval, mutex_count;
186 ReleaseThunkLock( &mutex_count );
187 retval = WaitForSingleObject( handle, timeout );
188 RestoreThunkLock( mutex_count );
192 /***********************************************************************
193 * WaitForMultipleObjects (KERNEL.461)
195 DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
196 BOOL wait_all, DWORD timeout )
198 DWORD retval, mutex_count;
200 ReleaseThunkLock( &mutex_count );
201 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
202 RestoreThunkLock( mutex_count );
206 /***********************************************************************
207 * WaitForMultipleObjectsEx (KERNEL.495)
209 DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
210 BOOL wait_all, DWORD timeout, BOOL alertable )
212 DWORD retval, mutex_count;
214 ReleaseThunkLock( &mutex_count );
215 retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
216 RestoreThunkLock( mutex_count );
220 /***********************************************************************
221 * RegisterWaitForSingleObject (KERNEL32.@)
223 BOOL WINAPI RegisterWaitForSingleObject(PHANDLE phNewWaitObject, HANDLE hObject,
224 WAITORTIMERCALLBACK Callback, PVOID Context,
225 ULONG dwMilliseconds, ULONG dwFlags)
227 FIXME("%p %p %p %p %ld %ld\n",
228 phNewWaitObject,hObject,Callback,Context,dwMilliseconds,dwFlags);
232 /***********************************************************************
233 * RegisterWaitForSingleObjectEx (KERNEL32.@)
235 BOOL WINAPI RegisterWaitForSingleObjectEx( HANDLE hObject,
236 WAITORTIMERCALLBACK Callback, PVOID Context,
237 ULONG dwMilliseconds, ULONG dwFlags )
239 FIXME("%p %p %p %ld %ld\n",
240 hObject,Callback,Context,dwMilliseconds,dwFlags);
244 /***********************************************************************
245 * UnregisterWait (KERNEL32.@)
247 BOOL WINAPI UnregisterWait( HANDLE WaitHandle )
249 FIXME("%p\n",WaitHandle);
253 /***********************************************************************
254 * UnregisterWaitEx (KERNEL32.@)
256 BOOL WINAPI UnregisterWaitEx( HANDLE WaitHandle, HANDLE CompletionEvent )
258 FIXME("%p %p\n",WaitHandle, CompletionEvent);
262 /***********************************************************************
263 * InitializeCriticalSection (KERNEL32.@)
265 * Initialise a critical section before use.
268 * crit [O] Critical section to initialise.
271 * Nothing. If the function fails an exception is raised.
273 void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
275 NTSTATUS ret = RtlInitializeCriticalSection( crit );
276 if (ret) RtlRaiseStatus( ret );
279 /***********************************************************************
280 * InitializeCriticalSectionAndSpinCount (KERNEL32.@)
282 * Initialise a critical section with a spin count.
285 * crit [O] Critical section to initialise.
286 * spincount [I] Number of times to spin upon contention.
290 * Failure: Nothing. If the function fails an exception is raised.
293 * spincount is ignored on uni-processor systems.
295 BOOL WINAPI InitializeCriticalSectionAndSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
297 NTSTATUS ret = RtlInitializeCriticalSectionAndSpinCount( crit, spincount );
298 if (ret) RtlRaiseStatus( ret );
302 /***********************************************************************
303 * SetCriticalSectionSpinCount (KERNEL32.@)
305 * Set the spin count for a critical section.
308 * crit [O] Critical section to set the spin count for.
309 * spincount [I] Number of times to spin upon contention.
312 * The previous spin count value of crit.
315 * This function is available on NT4SP3 or later, but not Win98.
317 DWORD WINAPI SetCriticalSectionSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
319 ULONG_PTR oldspincount = crit->SpinCount;
320 if(spincount) FIXME("critsection=%p: spincount=%ld not supported\n", crit, spincount);
321 crit->SpinCount = spincount;
325 /***********************************************************************
326 * MakeCriticalSectionGlobal (KERNEL32.@)
328 void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
330 /* let's assume that only one thread at a time will try to do this */
331 HANDLE sem = crit->LockSemaphore;
332 if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
333 crit->LockSemaphore = ConvertToGlobalHandle( sem );
336 RtlFreeHeap( GetProcessHeap(), 0, crit->DebugInfo );
337 crit->DebugInfo = NULL;
342 /***********************************************************************
343 * ReinitializeCriticalSection (KERNEL32.@)
345 * Initialise an already used critical section.
348 * crit [O] Critical section to initialise.
353 void WINAPI ReinitializeCriticalSection( CRITICAL_SECTION *crit )
355 if ( !crit->LockSemaphore )
356 RtlInitializeCriticalSection( crit );
360 /***********************************************************************
361 * UninitializeCriticalSection (KERNEL32.@)
363 * UnInitialise a critical section after use.
366 * crit [O] Critical section to uninitialise (destroy).
371 void WINAPI UninitializeCriticalSection( CRITICAL_SECTION *crit )
373 RtlDeleteCriticalSection( crit );
377 /***********************************************************************
378 * CreateEventA (KERNEL32.@)
380 HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
381 BOOL initial_state, LPCSTR name )
383 WCHAR buffer[MAX_PATH];
385 if (!name) return CreateEventW( sa, manual_reset, initial_state, NULL );
387 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
389 SetLastError( ERROR_FILENAME_EXCED_RANGE );
392 return CreateEventW( sa, manual_reset, initial_state, buffer );
396 /***********************************************************************
397 * CreateEventW (KERNEL32.@)
399 HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
400 BOOL initial_state, LPCWSTR name )
403 DWORD len = name ? strlenW(name) : 0;
406 SetLastError( ERROR_FILENAME_EXCED_RANGE );
409 /* one buggy program needs this
410 * ("Van Dale Groot woordenboek der Nederlandse taal")
412 if (sa && IsBadReadPtr(sa,sizeof(SECURITY_ATTRIBUTES)))
414 ERR("Bad security attributes pointer %p\n",sa);
415 SetLastError( ERROR_INVALID_PARAMETER);
418 SERVER_START_REQ( create_event )
420 req->manual_reset = manual_reset;
421 req->initial_state = initial_state;
422 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
423 wine_server_add_data( req, name, len * sizeof(WCHAR) );
425 wine_server_call_err( req );
433 /***********************************************************************
434 * CreateW32Event (KERNEL.457)
436 HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
438 return CreateEventA( NULL, manual_reset, initial_state, NULL );
442 /***********************************************************************
443 * OpenEventA (KERNEL32.@)
445 HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
447 WCHAR buffer[MAX_PATH];
449 if (!name) return OpenEventW( access, inherit, NULL );
451 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
453 SetLastError( ERROR_FILENAME_EXCED_RANGE );
456 return OpenEventW( access, inherit, buffer );
460 /***********************************************************************
461 * OpenEventW (KERNEL32.@)
463 HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
466 DWORD len = name ? strlenW(name) : 0;
469 SetLastError( ERROR_FILENAME_EXCED_RANGE );
472 if (!is_version_nt()) access = EVENT_ALL_ACCESS;
474 SERVER_START_REQ( open_event )
476 req->access = access;
477 req->inherit = inherit;
478 wine_server_add_data( req, name, len * sizeof(WCHAR) );
479 wine_server_call_err( req );
487 /***********************************************************************
490 * Execute an event operation (set,reset,pulse).
492 static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
495 SERVER_START_REQ( event_op )
497 req->handle = handle;
499 ret = !wine_server_call_err( req );
506 /***********************************************************************
507 * PulseEvent (KERNEL32.@)
509 BOOL WINAPI PulseEvent( HANDLE handle )
511 return EVENT_Operation( handle, PULSE_EVENT );
515 /***********************************************************************
516 * SetW32Event (KERNEL.458)
517 * SetEvent (KERNEL32.@)
519 BOOL WINAPI SetEvent( HANDLE handle )
521 return EVENT_Operation( handle, SET_EVENT );
525 /***********************************************************************
526 * ResetW32Event (KERNEL.459)
527 * ResetEvent (KERNEL32.@)
529 BOOL WINAPI ResetEvent( HANDLE handle )
531 return EVENT_Operation( handle, RESET_EVENT );
535 /***********************************************************************
536 * NOTE: The Win95 VWin32_Event routines given below are really low-level
537 * routines implemented directly by VWin32. The user-mode libraries
538 * implement Win32 synchronisation routines on top of these low-level
539 * primitives. We do it the other way around here :-)
542 /***********************************************************************
543 * VWin32_EventCreate (KERNEL.442)
545 HANDLE WINAPI VWin32_EventCreate(VOID)
547 HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
548 return ConvertToGlobalHandle( hEvent );
551 /***********************************************************************
552 * VWin32_EventDestroy (KERNEL.443)
554 VOID WINAPI VWin32_EventDestroy(HANDLE event)
556 CloseHandle( event );
559 /***********************************************************************
560 * VWin32_EventWait (KERNEL.450)
562 VOID WINAPI VWin32_EventWait(HANDLE event)
566 ReleaseThunkLock( &mutex_count );
567 WaitForSingleObject( event, INFINITE );
568 RestoreThunkLock( mutex_count );
571 /***********************************************************************
572 * VWin32_EventSet (KERNEL.451)
573 * KERNEL_479 (KERNEL.479)
575 VOID WINAPI VWin32_EventSet(HANDLE event)
582 /***********************************************************************
583 * CreateMutexA (KERNEL32.@)
585 HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
587 WCHAR buffer[MAX_PATH];
589 if (!name) return CreateMutexW( sa, owner, NULL );
591 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
593 SetLastError( ERROR_FILENAME_EXCED_RANGE );
596 return CreateMutexW( sa, owner, buffer );
600 /***********************************************************************
601 * CreateMutexW (KERNEL32.@)
603 HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
606 DWORD len = name ? strlenW(name) : 0;
609 SetLastError( ERROR_FILENAME_EXCED_RANGE );
612 SERVER_START_REQ( create_mutex )
615 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
616 wine_server_add_data( req, name, len * sizeof(WCHAR) );
618 wine_server_call_err( req );
626 /***********************************************************************
627 * OpenMutexA (KERNEL32.@)
629 HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
631 WCHAR buffer[MAX_PATH];
633 if (!name) return OpenMutexW( access, inherit, NULL );
635 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
637 SetLastError( ERROR_FILENAME_EXCED_RANGE );
640 return OpenMutexW( access, inherit, buffer );
644 /***********************************************************************
645 * OpenMutexW (KERNEL32.@)
647 HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
650 DWORD len = name ? strlenW(name) : 0;
653 SetLastError( ERROR_FILENAME_EXCED_RANGE );
656 if (!is_version_nt()) access = MUTEX_ALL_ACCESS;
658 SERVER_START_REQ( open_mutex )
660 req->access = access;
661 req->inherit = inherit;
662 wine_server_add_data( req, name, len * sizeof(WCHAR) );
663 wine_server_call_err( req );
671 /***********************************************************************
672 * ReleaseMutex (KERNEL32.@)
674 BOOL WINAPI ReleaseMutex( HANDLE handle )
677 SERVER_START_REQ( release_mutex )
679 req->handle = handle;
680 ret = !wine_server_call_err( req );
692 /***********************************************************************
693 * CreateSemaphoreA (KERNEL32.@)
695 HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
697 WCHAR buffer[MAX_PATH];
699 if (!name) return CreateSemaphoreW( sa, initial, max, NULL );
701 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
703 SetLastError( ERROR_FILENAME_EXCED_RANGE );
706 return CreateSemaphoreW( sa, initial, max, buffer );
710 /***********************************************************************
711 * CreateSemaphoreW (KERNEL32.@)
713 HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
714 LONG max, LPCWSTR name )
717 DWORD len = name ? strlenW(name) : 0;
719 /* Check parameters */
721 if ((max <= 0) || (initial < 0) || (initial > max))
723 SetLastError( ERROR_INVALID_PARAMETER );
728 SetLastError( ERROR_FILENAME_EXCED_RANGE );
732 SERVER_START_REQ( create_semaphore )
734 req->initial = (unsigned int)initial;
735 req->max = (unsigned int)max;
736 req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
737 wine_server_add_data( req, name, len * sizeof(WCHAR) );
739 wine_server_call_err( req );
747 /***********************************************************************
748 * OpenSemaphoreA (KERNEL32.@)
750 HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
752 WCHAR buffer[MAX_PATH];
754 if (!name) return OpenSemaphoreW( access, inherit, NULL );
756 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
758 SetLastError( ERROR_FILENAME_EXCED_RANGE );
761 return OpenSemaphoreW( access, inherit, buffer );
765 /***********************************************************************
766 * OpenSemaphoreW (KERNEL32.@)
768 HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
771 DWORD len = name ? strlenW(name) : 0;
774 SetLastError( ERROR_FILENAME_EXCED_RANGE );
777 if (!is_version_nt()) access = SEMAPHORE_ALL_ACCESS;
779 SERVER_START_REQ( open_semaphore )
781 req->access = access;
782 req->inherit = inherit;
783 wine_server_add_data( req, name, len * sizeof(WCHAR) );
784 wine_server_call_err( req );
792 /***********************************************************************
793 * ReleaseSemaphore (KERNEL32.@)
795 BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
797 NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
798 if (status) SetLastError( RtlNtStatusToDosError(status) );
808 /***********************************************************************
809 * CreateWaitableTimerA (KERNEL32.@)
811 HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name )
813 WCHAR buffer[MAX_PATH];
815 if (!name) return CreateWaitableTimerW( sa, manual, NULL );
817 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
819 SetLastError( ERROR_FILENAME_EXCED_RANGE );
822 return CreateWaitableTimerW( sa, manual, buffer );
826 /***********************************************************************
827 * CreateWaitableTimerW (KERNEL32.@)
829 HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name )
835 OBJECT_ATTRIBUTES oa;
837 if (name) RtlInitUnicodeString(&us, name);
838 if (sa && (sa->nLength >= sizeof(*sa)) && sa->bInheritHandle)
840 InitializeObjectAttributes(&oa, name ? &us : NULL, attr,
841 NULL /* FIXME */, NULL /* FIXME */);
842 status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &oa,
843 manual ? NotificationTimer : SynchronizationTimer);
845 if (status != STATUS_SUCCESS)
847 SetLastError( RtlNtStatusToDosError(status) );
854 /***********************************************************************
855 * OpenWaitableTimerA (KERNEL32.@)
857 HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
859 WCHAR buffer[MAX_PATH];
861 if (!name) return OpenWaitableTimerW( access, inherit, NULL );
863 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
865 SetLastError( ERROR_FILENAME_EXCED_RANGE );
868 return OpenWaitableTimerW( access, inherit, buffer );
872 /***********************************************************************
873 * OpenWaitableTimerW (KERNEL32.@)
875 HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
881 OBJECT_ATTRIBUTES oa;
883 if (inherit) attr |= OBJ_INHERIT;
885 if (name) RtlInitUnicodeString(&us, name);
886 InitializeObjectAttributes(&oa, name ? &us : NULL, attr, NULL /* FIXME */, NULL /* FIXME */);
887 status = NtOpenTimer(&handle, access, &oa);
888 if (status != STATUS_SUCCESS)
890 SetLastError( RtlNtStatusToDosError(status) );
897 /***********************************************************************
898 * SetWaitableTimer (KERNEL32.@)
900 BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period,
901 PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume )
903 NTSTATUS status = NtSetTimer(handle, when, callback, arg, resume, period, NULL);
905 if (status != STATUS_SUCCESS)
907 SetLastError( RtlNtStatusToDosError(status) );
908 if (status != STATUS_TIMER_RESUME_IGNORED) return FALSE;
914 /***********************************************************************
915 * CancelWaitableTimer (KERNEL32.@)
917 BOOL WINAPI CancelWaitableTimer( HANDLE handle )
921 status = NtCancelTimer(handle, NULL);
922 if (status != STATUS_SUCCESS)
924 SetLastError( RtlNtStatusToDosError(status) );
931 /***********************************************************************
932 * CreateTimerQueue (KERNEL32.@)
934 HANDLE WINAPI CreateTimerQueue(void)
937 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
942 /***********************************************************************
943 * DeleteTimerQueueEx (KERNEL32.@)
945 BOOL WINAPI DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
947 FIXME("(%p, %p): stub\n", TimerQueue, CompletionEvent);
948 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
952 /***********************************************************************
953 * CreateTimerQueueTimer (KERNEL32.@)
955 * Creates a timer-queue timer. This timer expires at the specified due
956 * time (in ms), then after every specified period (in ms). When the timer
957 * expires, the callback function is called.
960 * nonzero on success or zero on faillure
965 BOOL WINAPI CreateTimerQueueTimer( PHANDLE phNewTimer, HANDLE TimerQueue,
966 WAITORTIMERCALLBACK Callback, PVOID Parameter,
967 DWORD DueTime, DWORD Period, ULONG Flags )
970 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
974 /***********************************************************************
975 * DeleteTimerQueueTimer (KERNEL32.@)
977 * Cancels a timer-queue timer.
980 * nonzero on success or zero on faillure
985 BOOL WINAPI DeleteTimerQueueTimer( HANDLE TimerQueue, HANDLE Timer,
986 HANDLE CompletionEvent )
989 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
999 /***********************************************************************
1000 * CreateNamedPipeA (KERNEL32.@)
1002 HANDLE WINAPI CreateNamedPipeA( LPCSTR name, DWORD dwOpenMode,
1003 DWORD dwPipeMode, DWORD nMaxInstances,
1004 DWORD nOutBufferSize, DWORD nInBufferSize,
1005 DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
1007 WCHAR buffer[MAX_PATH];
1009 if (!name) return CreateNamedPipeW( NULL, dwOpenMode, dwPipeMode, nMaxInstances,
1010 nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
1012 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
1014 SetLastError( ERROR_FILENAME_EXCED_RANGE );
1015 return INVALID_HANDLE_VALUE;
1017 return CreateNamedPipeW( buffer, dwOpenMode, dwPipeMode, nMaxInstances,
1018 nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
1022 /***********************************************************************
1023 * CreateNamedPipeW (KERNEL32.@)
1025 HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
1026 DWORD dwPipeMode, DWORD nMaxInstances,
1027 DWORD nOutBufferSize, DWORD nInBufferSize,
1028 DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
1032 static const WCHAR leadin[] = {'\\','\\','.','\\','P','I','P','E','\\'};
1034 TRACE("(%s, %#08lx, %#08lx, %ld, %ld, %ld, %ld, %p)\n",
1035 debugstr_w(name), dwOpenMode, dwPipeMode, nMaxInstances,
1036 nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
1040 SetLastError( ERROR_PATH_NOT_FOUND );
1041 return INVALID_HANDLE_VALUE;
1043 len = strlenW(name);
1044 if (len >= MAX_PATH)
1046 SetLastError( ERROR_FILENAME_EXCED_RANGE );
1047 return INVALID_HANDLE_VALUE;
1049 if (strncmpiW(name, leadin, sizeof(leadin)/sizeof(leadin[0])))
1051 SetLastError( ERROR_INVALID_NAME );
1052 return INVALID_HANDLE_VALUE;
1054 SERVER_START_REQ( create_named_pipe )
1056 req->openmode = dwOpenMode;
1057 req->pipemode = dwPipeMode;
1058 req->maxinstances = nMaxInstances;
1059 req->outsize = nOutBufferSize;
1060 req->insize = nInBufferSize;
1061 req->timeout = nDefaultTimeOut;
1062 wine_server_add_data( req, name, len * sizeof(WCHAR) );
1064 if (!wine_server_call_err( req )) ret = reply->handle;
1065 else ret = INVALID_HANDLE_VALUE;
1072 /***********************************************************************
1073 * PeekNamedPipe (KERNEL32.@)
1075 BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
1076 LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage )
1079 int avail=0, fd, ret, flags;
1081 ret = wine_server_handle_to_fd( hPipe, GENERIC_READ, &fd, NULL, &flags );
1084 SetLastError( RtlNtStatusToDosError(ret) );
1087 if (flags & FD_FLAG_RECV_SHUTDOWN)
1089 wine_server_release_fd( hPipe, fd );
1090 SetLastError ( ERROR_PIPE_NOT_CONNECTED );
1094 if (ioctl(fd,FIONREAD, &avail ) != 0)
1096 TRACE("FIONREAD failed reason: %s\n",strerror(errno));
1097 wine_server_release_fd( hPipe, fd );
1100 if (!avail) /* check for closed pipe */
1102 struct pollfd pollfd;
1104 pollfd.events = POLLIN;
1106 switch (poll( &pollfd, 1, 0 ))
1110 case 1: /* got something */
1111 if (!(pollfd.revents & (POLLHUP | POLLERR))) break;
1112 TRACE("POLLHUP | POLLERR\n");
1115 wine_server_release_fd( hPipe, fd );
1116 SetLastError(ERROR_BROKEN_PIPE);
1120 wine_server_release_fd( hPipe, fd );
1121 TRACE(" 0x%08x bytes available\n", avail );
1122 if (!lpvBuffer && lpcbAvail)
1127 #endif /* defined(FIONREAD) */
1129 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1130 FIXME("function not implemented\n");
1134 /***********************************************************************
1135 * SYNC_CompletePipeOverlapped (Internal)
1137 static void SYNC_CompletePipeOverlapped (LPOVERLAPPED overlapped, DWORD result)
1139 TRACE("for %p result %08lx\n",overlapped,result);
1142 overlapped->Internal = result;
1143 SetEvent(overlapped->hEvent);
1147 /***********************************************************************
1148 * WaitNamedPipeA (KERNEL32.@)
1150 BOOL WINAPI WaitNamedPipeA (LPCSTR name, DWORD nTimeOut)
1152 WCHAR buffer[MAX_PATH];
1154 if (!name) return WaitNamedPipeW( NULL, nTimeOut );
1156 if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
1158 SetLastError( ERROR_FILENAME_EXCED_RANGE );
1161 return WaitNamedPipeW( buffer, nTimeOut );
1165 /***********************************************************************
1166 * WaitNamedPipeW (KERNEL32.@)
1168 BOOL WINAPI WaitNamedPipeW (LPCWSTR name, DWORD nTimeOut)
1170 DWORD len = name ? strlenW(name) : 0;
1174 if (len >= MAX_PATH)
1176 SetLastError( ERROR_FILENAME_EXCED_RANGE );
1180 TRACE("%s 0x%08lx\n",debugstr_w(name),nTimeOut);
1182 memset(&ov,0,sizeof(ov));
1183 ov.hEvent = CreateEventA( NULL, 0, 0, NULL );
1187 SERVER_START_REQ( wait_named_pipe )
1189 req->timeout = nTimeOut;
1190 req->overlapped = &ov;
1191 req->func = SYNC_CompletePipeOverlapped;
1192 wine_server_add_data( req, name, len * sizeof(WCHAR) );
1193 ret = !wine_server_call_err( req );
1199 if (WAIT_OBJECT_0==WaitForSingleObject(ov.hEvent,INFINITE))
1201 SetLastError(ov.Internal);
1202 ret = (ov.Internal==STATUS_SUCCESS);
1205 CloseHandle(ov.hEvent);
1210 /***********************************************************************
1211 * SYNC_ConnectNamedPipe (Internal)
1213 static BOOL SYNC_ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
1220 overlapped->Internal = STATUS_PENDING;
1222 SERVER_START_REQ( connect_named_pipe )
1224 req->handle = hPipe;
1225 req->overlapped = overlapped;
1226 req->func = SYNC_CompletePipeOverlapped;
1227 ret = !wine_server_call_err( req );
1234 /***********************************************************************
1235 * ConnectNamedPipe (KERNEL32.@)
1237 BOOL WINAPI ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
1242 TRACE("(%p,%p)\n",hPipe, overlapped);
1246 if(SYNC_ConnectNamedPipe(hPipe,overlapped))
1247 SetLastError( ERROR_IO_PENDING );
1251 memset(&ov,0,sizeof(ov));
1252 ov.hEvent = CreateEventA(NULL,0,0,NULL);
1256 ret=SYNC_ConnectNamedPipe(hPipe, &ov);
1259 if (WAIT_OBJECT_0==WaitForSingleObject(ov.hEvent,INFINITE))
1261 SetLastError(ov.Internal);
1262 ret = (ov.Internal==STATUS_SUCCESS);
1266 CloseHandle(ov.hEvent);
1271 /***********************************************************************
1272 * DisconnectNamedPipe (KERNEL32.@)
1274 BOOL WINAPI DisconnectNamedPipe(HANDLE hPipe)
1278 TRACE("(%p)\n",hPipe);
1280 SERVER_START_REQ( disconnect_named_pipe )
1282 req->handle = hPipe;
1283 ret = !wine_server_call_err( req );
1284 if (ret && reply->fd != -1) close( reply->fd );
1291 /***********************************************************************
1292 * TransactNamedPipe (KERNEL32.@)
1294 BOOL WINAPI TransactNamedPipe(
1295 HANDLE hPipe, LPVOID lpInput, DWORD dwInputSize, LPVOID lpOutput,
1296 DWORD dwOutputSize, LPDWORD lpBytesRead, LPOVERLAPPED lpOverlapped)
1298 FIXME("%p %p %ld %p %ld %p %p\n",
1299 hPipe, lpInput, dwInputSize, lpOutput,
1300 dwOutputSize, lpBytesRead, lpOverlapped);
1306 /***********************************************************************
1307 * GetNamedPipeInfo (KERNEL32.@)
1309 BOOL WINAPI GetNamedPipeInfo(
1310 HANDLE hNamedPipe, LPDWORD lpFlags, LPDWORD lpOutputBufferSize,
1311 LPDWORD lpInputBufferSize, LPDWORD lpMaxInstances)
1315 TRACE("%p %p %p %p %p\n", hNamedPipe, lpFlags,
1316 lpOutputBufferSize, lpInputBufferSize, lpMaxInstances);
1318 SERVER_START_REQ( get_named_pipe_info )
1320 req->handle = hNamedPipe;
1321 ret = !wine_server_call_err( req );
1322 if(lpFlags) *lpFlags = reply->flags;
1323 if(lpOutputBufferSize) *lpOutputBufferSize = reply->outsize;
1324 if(lpInputBufferSize) *lpInputBufferSize = reply->outsize;
1325 if(lpMaxInstances) *lpMaxInstances = reply->maxinstances;
1332 /***********************************************************************
1333 * GetNamedPipeHandleStateA (KERNEL32.@)
1335 BOOL WINAPI GetNamedPipeHandleStateA(
1336 HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
1337 LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
1338 LPSTR lpUsername, DWORD nUsernameMaxSize)
1340 FIXME("%p %p %p %p %p %p %ld\n",
1341 hNamedPipe, lpState, lpCurInstances,
1342 lpMaxCollectionCount, lpCollectDataTimeout,
1343 lpUsername, nUsernameMaxSize);
1348 /***********************************************************************
1349 * GetNamedPipeHandleStateW (KERNEL32.@)
1351 BOOL WINAPI GetNamedPipeHandleStateW(
1352 HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
1353 LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
1354 LPWSTR lpUsername, DWORD nUsernameMaxSize)
1356 FIXME("%p %p %p %p %p %p %ld\n",
1357 hNamedPipe, lpState, lpCurInstances,
1358 lpMaxCollectionCount, lpCollectDataTimeout,
1359 lpUsername, nUsernameMaxSize);
1364 /***********************************************************************
1365 * SetNamedPipeHandleState (KERNEL32.@)
1367 BOOL WINAPI SetNamedPipeHandleState(
1368 HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount,
1369 LPDWORD lpCollectDataTimeout)
1371 FIXME("%p %p %p %p\n",
1372 hNamedPipe, lpMode, lpMaxCollectionCount, lpCollectDataTimeout);
1376 /***********************************************************************
1377 * CallNamedPipeA (KERNEL32.@)
1379 BOOL WINAPI CallNamedPipeA(
1380 LPCSTR lpNamedPipeName, LPVOID lpInput, DWORD lpInputSize,
1381 LPVOID lpOutput, DWORD lpOutputSize,
1382 LPDWORD lpBytesRead, DWORD nTimeout)
1384 FIXME("%s %p %ld %p %ld %p %ld\n",
1385 debugstr_a(lpNamedPipeName), lpInput, lpInputSize,
1386 lpOutput, lpOutputSize, lpBytesRead, nTimeout);
1390 /***********************************************************************
1391 * CallNamedPipeW (KERNEL32.@)
1393 BOOL WINAPI CallNamedPipeW(
1394 LPCWSTR lpNamedPipeName, LPVOID lpInput, DWORD lpInputSize,
1395 LPVOID lpOutput, DWORD lpOutputSize,
1396 LPDWORD lpBytesRead, DWORD nTimeout)
1398 FIXME("%s %p %ld %p %ld %p %ld\n",
1399 debugstr_w(lpNamedPipeName), lpInput, lpInputSize,
1400 lpOutput, lpOutputSize, lpBytesRead, nTimeout);
1404 /******************************************************************
1405 * CreatePipe (KERNEL32.@)
1408 BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
1409 LPSECURITY_ATTRIBUTES sa, DWORD size )
1411 static unsigned index = 0;
1414 unsigned in_index = index;
1416 *hReadPipe = *hWritePipe = INVALID_HANDLE_VALUE;
1417 /* generate a unique pipe name (system wide) */
1420 sprintf(name, "\\\\.\\pipe\\Win32.Pipes.%08lu.%08u", GetCurrentProcessId(), ++index);
1421 hr = CreateNamedPipeA(name, PIPE_ACCESS_INBOUND,
1422 PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size,
1423 NMPWAIT_USE_DEFAULT_WAIT, sa);
1424 } while (hr == INVALID_HANDLE_VALUE && index != in_index);
1425 /* from completion sakeness, I think system resources might be exhausted before this happens !! */
1426 if (hr == INVALID_HANDLE_VALUE) return FALSE;
1428 hw = CreateFileA(name, GENERIC_WRITE, 0, sa, OPEN_EXISTING, 0, 0);
1429 if (hw == INVALID_HANDLE_VALUE)
1441 /******************************************************************************
1442 * CreateMailslotA [KERNEL32.@]
1444 HANDLE WINAPI CreateMailslotA( LPCSTR lpName, DWORD nMaxMessageSize,
1445 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
1451 TRACE("%s %ld %ld %p\n", debugstr_a(lpName),
1452 nMaxMessageSize, lReadTimeout, sa);
1456 len = MultiByteToWideChar( CP_ACP, 0, lpName, -1, NULL, 0 );
1457 name = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1458 MultiByteToWideChar( CP_ACP, 0, lpName, -1, name, len );
1461 handle = CreateMailslotW( name, nMaxMessageSize, lReadTimeout, sa );
1464 HeapFree( GetProcessHeap(), 0, name );
1470 /******************************************************************************
1471 * CreateMailslotW [KERNEL32.@]
1473 * Create a mailslot with specified name.
1476 * lpName [I] Pointer to string for mailslot name
1477 * nMaxMessageSize [I] Maximum message size
1478 * lReadTimeout [I] Milliseconds before read time-out
1479 * sa [I] Pointer to security structure
1482 * Success: Handle to mailslot
1483 * Failure: INVALID_HANDLE_VALUE
1485 HANDLE WINAPI CreateMailslotW( LPCWSTR lpName, DWORD nMaxMessageSize,
1486 DWORD lReadTimeout, LPSECURITY_ATTRIBUTES sa )
1488 FIXME("(%s,%ld,%ld,%p): stub\n", debugstr_w(lpName),
1489 nMaxMessageSize, lReadTimeout, sa);
1490 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1491 return INVALID_HANDLE_VALUE;
1495 /******************************************************************************
1496 * GetMailslotInfo [KERNEL32.@]
1498 * Retrieve information about a mailslot.
1501 * hMailslot [I] Mailslot handle
1502 * lpMaxMessageSize [O] Address of maximum message size
1503 * lpNextSize [O] Address of size of next message
1504 * lpMessageCount [O] Address of number of messages
1505 * lpReadTimeout [O] Address of read time-out
1511 BOOL WINAPI GetMailslotInfo( HANDLE hMailslot, LPDWORD lpMaxMessageSize,
1512 LPDWORD lpNextSize, LPDWORD lpMessageCount,
1513 LPDWORD lpReadTimeout )
1515 FIXME("(%p): stub\n",hMailslot);
1516 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1521 /******************************************************************************
1522 * SetMailslotInfo [KERNEL32.@]
1524 * Set the read timeout of a mailslot.
1527 * hMailslot [I] Mailslot handle
1528 * dwReadTimeout [I] Timeout in milliseconds.
1534 BOOL WINAPI SetMailslotInfo( HANDLE hMailslot, DWORD dwReadTimeout)
1536 FIXME("%p %ld: stub\n", hMailslot, dwReadTimeout);
1537 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1542 /******************************************************************************
1543 * CreateIoCompletionPort (KERNEL32.@)
1545 HANDLE WINAPI CreateIoCompletionPort(HANDLE hFileHandle, HANDLE hExistingCompletionPort,
1546 DWORD dwCompletionKey, DWORD dwNumberOfConcurrentThreads)
1548 FIXME("(%p, %p, %08lx, %08lx): stub.\n",
1549 hFileHandle, hExistingCompletionPort, dwCompletionKey, dwNumberOfConcurrentThreads);
1554 /******************************************************************************
1555 * GetQueuedCompletionStatus (KERNEL32.@)
1557 BOOL WINAPI GetQueuedCompletionStatus( HANDLE CompletionPort, LPDWORD lpNumberOfBytesTransferred,
1558 LPDWORD lpCompletionKey, LPOVERLAPPED *lpOverlapped,
1559 DWORD dwMilliseconds )
1561 FIXME("(%p,%p,%p,%p,%ld), stub!\n",
1562 CompletionPort,lpNumberOfBytesTransferred,lpCompletionKey,lpOverlapped,dwMilliseconds);
1563 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1567 /******************************************************************************
1568 * CreateJobObjectW (KERNEL32.@)
1570 HANDLE WINAPI CreateJobObjectW( LPSECURITY_ATTRIBUTES attr, LPCWSTR name )
1572 FIXME("%p %s\n", attr, debugstr_w(name) );
1573 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1577 /******************************************************************************
1578 * CreateJobObjectA (KERNEL32.@)
1580 HANDLE WINAPI CreateJobObjectA( LPSECURITY_ATTRIBUTES attr, LPCSTR name )
1586 TRACE("%p %s\n", attr, debugstr_a(name) );
1590 len = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
1591 str = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
1594 SetLastError( ERROR_OUTOFMEMORY );
1597 len = MultiByteToWideChar( CP_ACP, 0, name, -1, str, len );
1600 r = CreateJobObjectW( attr, str );
1603 HeapFree( GetProcessHeap(), 0, str );
1608 /******************************************************************************
1609 * AssignProcessToJobObject (KERNEL32.@)
1611 BOOL WINAPI AssignProcessToJobObject( HANDLE hJob, HANDLE hProcess )
1613 FIXME("%p %p\n", hJob, hProcess);
1619 /***********************************************************************
1620 * InterlockedCompareExchange (KERNEL32.@)
1622 /* LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare ); */
1623 __ASM_GLOBAL_FUNC(InterlockedCompareExchange,
1624 "movl 12(%esp),%eax\n\t"
1625 "movl 8(%esp),%ecx\n\t"
1626 "movl 4(%esp),%edx\n\t"
1627 "lock; cmpxchgl %ecx,(%edx)\n\t"
1630 /***********************************************************************
1631 * InterlockedExchange (KERNEL32.@)
1633 /* LONG WINAPI InterlockedExchange( PLONG dest, LONG val ); */
1634 __ASM_GLOBAL_FUNC(InterlockedExchange,
1635 "movl 8(%esp),%eax\n\t"
1636 "movl 4(%esp),%edx\n\t"
1637 "lock; xchgl %eax,(%edx)\n\t"
1640 /***********************************************************************
1641 * InterlockedExchangeAdd (KERNEL32.@)
1643 /* LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr ); */
1644 __ASM_GLOBAL_FUNC(InterlockedExchangeAdd,
1645 "movl 8(%esp),%eax\n\t"
1646 "movl 4(%esp),%edx\n\t"
1647 "lock; xaddl %eax,(%edx)\n\t"
1650 /***********************************************************************
1651 * InterlockedIncrement (KERNEL32.@)
1653 /* LONG WINAPI InterlockedIncrement( PLONG dest ); */
1654 __ASM_GLOBAL_FUNC(InterlockedIncrement,
1655 "movl 4(%esp),%edx\n\t"
1657 "lock; xaddl %eax,(%edx)\n\t"
1661 /***********************************************************************
1662 * InterlockedDecrement (KERNEL32.@)
1664 __ASM_GLOBAL_FUNC(InterlockedDecrement,
1665 "movl 4(%esp),%edx\n\t"
1667 "lock; xaddl %eax,(%edx)\n\t"
1671 #else /* __i386__ */
1673 /***********************************************************************
1674 * InterlockedCompareExchange (KERNEL32.@)
1676 * Atomically swap one value with another.
1679 * dest [I/O] The value to replace
1680 * xchq [I] The value to be swapped
1681 * compare [I] The value to compare to dest
1684 * The resulting value of dest.
1687 * dest is updated only if it is equal to compare, otherwise no swap is done.
1689 LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare )
1691 return interlocked_cmpxchg( dest, xchg, compare );
1694 /***********************************************************************
1695 * InterlockedExchange (KERNEL32.@)
1697 * Atomically swap one value with another.
1700 * dest [I/O] The value to replace
1701 * val [I] The value to be swapped
1704 * The resulting value of dest.
1706 LONG WINAPI InterlockedExchange( PLONG dest, LONG val )
1708 return interlocked_xchg( dest, val );
1711 /***********************************************************************
1712 * InterlockedExchangeAdd (KERNEL32.@)
1714 * Atomically add one value to another.
1717 * dest [I/O] The value to add to
1718 * incr [I] The value to be added
1721 * The resulting value of dest.
1723 LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr )
1725 return interlocked_xchg_add( dest, incr );
1728 /***********************************************************************
1729 * InterlockedIncrement (KERNEL32.@)
1731 * Atomically increment a value.
1734 * dest [I/O] The value to increment
1737 * The resulting value of dest.
1739 LONG WINAPI InterlockedIncrement( PLONG dest )
1741 return interlocked_xchg_add( dest, 1 ) + 1;
1744 /***********************************************************************
1745 * InterlockedDecrement (KERNEL32.@)
1747 * Atomically decrement a value.
1750 * dest [I/O] The value to decrement
1753 * The resulting value of dest.
1755 LONG WINAPI InterlockedDecrement( PLONG dest )
1757 return interlocked_xchg_add( dest, -1 ) - 1;
1760 #endif /* __i386__ */