2000-09-29 22:48:04 +02:00
|
|
|
/*
|
|
|
|
* Kernel synchronization objects
|
|
|
|
*
|
|
|
|
* Copyright 1998 Alexandre Julliard
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "config.h"
|
2002-08-29 01:42:34 +02:00
|
|
|
#include "wine/port.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
#include <string.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2002-07-25 02:22:03 +02:00
|
|
|
#include <errno.h>
|
|
|
|
#ifdef HAVE_SYS_IOCTL_H
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#endif
|
2002-09-05 01:34:03 +02:00
|
|
|
#ifdef HAVE_SYS_POLL_H
|
|
|
|
#include <sys/poll.h>
|
|
|
|
#endif
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-05-20 06:32:53 +02:00
|
|
|
#include <stdio.h>
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#include "windef.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "winbase.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
#include "winerror.h"
|
|
|
|
#include "winnls.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2001-07-19 02:39:09 +02:00
|
|
|
#include "wine/server.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
#include "wine/unicode.h"
|
2002-07-25 02:22:03 +02:00
|
|
|
#include "file.h"
|
2001-07-20 20:00:00 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win32);
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2003-05-12 05:28:26 +02:00
|
|
|
/* check if current version is NT or Win95 */
|
|
|
|
inline static int is_version_nt(void)
|
|
|
|
{
|
|
|
|
return !(GetVersion() & 0x80000000);
|
|
|
|
}
|
2000-09-29 22:48:04 +02:00
|
|
|
|
|
|
|
|
2003-06-24 05:34:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InitializeCriticalSection (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI InitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
NTSTATUS ret = RtlInitializeCriticalSection( crit );
|
|
|
|
if (ret) RtlRaiseStatus( ret );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InitializeCriticalSectionAndSpinCount (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InitializeCriticalSectionAndSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
|
|
|
|
{
|
|
|
|
NTSTATUS ret = RtlInitializeCriticalSectionAndSpinCount( crit, spincount );
|
|
|
|
if (ret) RtlRaiseStatus( ret );
|
|
|
|
return !ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetCriticalSectionSpinCount (KERNEL32.@)
|
|
|
|
* This function is available on NT4SP3 or later, but not Win98
|
|
|
|
* It is SMP related
|
|
|
|
*/
|
|
|
|
DWORD WINAPI SetCriticalSectionSpinCount( CRITICAL_SECTION *crit, DWORD spincount )
|
|
|
|
{
|
|
|
|
ULONG_PTR oldspincount = crit->SpinCount;
|
|
|
|
if(spincount) FIXME("critsection=%p: spincount=%ld not supported\n", crit, spincount);
|
|
|
|
crit->SpinCount = spincount;
|
|
|
|
return oldspincount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MakeCriticalSectionGlobal (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI MakeCriticalSectionGlobal( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
/* let's assume that only one thread at a time will try to do this */
|
|
|
|
HANDLE sem = crit->LockSemaphore;
|
|
|
|
if (!sem) NtCreateSemaphore( &sem, SEMAPHORE_ALL_ACCESS, NULL, 0, 1 );
|
|
|
|
crit->LockSemaphore = ConvertToGlobalHandle( sem );
|
2003-08-18 22:03:00 +02:00
|
|
|
if (crit->DebugInfo)
|
|
|
|
{
|
|
|
|
RtlFreeHeap( GetProcessHeap(), 0, crit->DebugInfo );
|
|
|
|
crit->DebugInfo = NULL;
|
|
|
|
}
|
2003-06-24 05:34:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ReinitializeCriticalSection (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI ReinitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
if ( !crit->LockSemaphore )
|
|
|
|
RtlInitializeCriticalSection( crit );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UninitializeCriticalSection (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
void WINAPI UninitializeCriticalSection( CRITICAL_SECTION *crit )
|
|
|
|
{
|
|
|
|
RtlDeleteCriticalSection( crit );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateEventA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateEventA( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
|
|
|
|
BOOL initial_state, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return CreateEventW( sa, manual_reset, initial_state, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return CreateEventW( sa, manual_reset, initial_state, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateEventW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateEventW( SECURITY_ATTRIBUTES *sa, BOOL manual_reset,
|
|
|
|
BOOL initial_state, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2000-12-29 04:18:08 +01:00
|
|
|
/* one buggy program needs this
|
|
|
|
* ("Van Dale Groot woordenboek der Nederlandse taal")
|
|
|
|
*/
|
|
|
|
if (sa && IsBadReadPtr(sa,sizeof(SECURITY_ATTRIBUTES)))
|
|
|
|
{
|
|
|
|
ERR("Bad security attributes pointer %p\n",sa);
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER);
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_event )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->manual_reset = manual_reset;
|
|
|
|
req->initial_state = initial_state;
|
|
|
|
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2000-09-29 22:48:04 +02:00
|
|
|
SetLastError(0);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-02 21:59:40 +02:00
|
|
|
* CreateW32Event (KERNEL.457)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI WIN16_CreateEvent( BOOL manual_reset, BOOL initial_state )
|
|
|
|
{
|
|
|
|
return CreateEventA( NULL, manual_reset, initial_state, NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenEventA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenEventA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenEventW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return OpenEventW( access, inherit, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenEventW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenEventW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-12 05:28:26 +02:00
|
|
|
if (!is_version_nt()) access = EVENT_ALL_ACCESS;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( open_event )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = inherit;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EVENT_Operation
|
|
|
|
*
|
|
|
|
* Execute an event operation (set,reset,pulse).
|
|
|
|
*/
|
|
|
|
static BOOL EVENT_Operation( HANDLE handle, enum event_op op )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( event_op )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
|
|
|
req->op = op;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* PulseEvent (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI PulseEvent( HANDLE handle )
|
|
|
|
{
|
|
|
|
return EVENT_Operation( handle, PULSE_EVENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* SetW32Event (KERNEL.458)
|
2001-06-13 22:13:18 +02:00
|
|
|
* SetEvent (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI SetEvent( HANDLE handle )
|
|
|
|
{
|
|
|
|
return EVENT_Operation( handle, SET_EVENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-07-11 20:56:41 +02:00
|
|
|
* ResetW32Event (KERNEL.459)
|
2001-06-13 22:13:18 +02:00
|
|
|
* ResetEvent (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ResetEvent( HANDLE handle )
|
|
|
|
{
|
|
|
|
return EVENT_Operation( handle, RESET_EVENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* NOTE: The Win95 VWin32_Event routines given below are really low-level
|
|
|
|
* routines implemented directly by VWin32. The user-mode libraries
|
|
|
|
* implement Win32 synchronisation routines on top of these low-level
|
|
|
|
* primitives. We do it the other way around here :-)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VWin32_EventCreate (KERNEL.442)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI VWin32_EventCreate(VOID)
|
|
|
|
{
|
|
|
|
HANDLE hEvent = CreateEventA( NULL, FALSE, 0, NULL );
|
|
|
|
return ConvertToGlobalHandle( hEvent );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* VWin32_EventDestroy (KERNEL.443)
|
|
|
|
*/
|
|
|
|
VOID WINAPI VWin32_EventDestroy(HANDLE event)
|
|
|
|
{
|
|
|
|
CloseHandle( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-06-01 01:06:46 +02:00
|
|
|
* VWin32_EventWait (KERNEL.450)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
VOID WINAPI VWin32_EventWait(HANDLE event)
|
|
|
|
{
|
2000-11-16 00:41:46 +01:00
|
|
|
DWORD mutex_count;
|
|
|
|
|
|
|
|
ReleaseThunkLock( &mutex_count );
|
2000-09-29 22:48:04 +02:00
|
|
|
WaitForSingleObject( event, INFINITE );
|
2000-11-16 00:41:46 +01:00
|
|
|
RestoreThunkLock( mutex_count );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* VWin32_EventSet (KERNEL.451)
|
2001-07-02 21:59:40 +02:00
|
|
|
* KERNEL_479 (KERNEL.479)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
VOID WINAPI VWin32_EventSet(HANDLE event)
|
|
|
|
{
|
|
|
|
SetEvent( event );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateMutexA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateMutexA( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return CreateMutexW( sa, owner, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return CreateMutexW( sa, owner, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateMutexW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateMutexW( SECURITY_ATTRIBUTES *sa, BOOL owner, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_mutex )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->owned = owner;
|
|
|
|
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2000-09-29 22:48:04 +02:00
|
|
|
SetLastError(0);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenMutexA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenMutexA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenMutexW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return OpenMutexW( access, inherit, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenMutexW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenMutexW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-12 05:28:26 +02:00
|
|
|
if (!is_version_nt()) access = MUTEX_ALL_ACCESS;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( open_mutex )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = inherit;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ReleaseMutex (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ReleaseMutex( HANDLE handle )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
2001-02-27 03:09:16 +01:00
|
|
|
SERVER_START_REQ( release_mutex )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->handle = handle;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Semaphores
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateSemaphoreA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateSemaphoreA( SECURITY_ATTRIBUTES *sa, LONG initial, LONG max, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!name) return CreateSemaphoreW( sa, initial, max, NULL );
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return CreateSemaphoreW( sa, initial, max, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateSemaphoreW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateSemaphoreW( SECURITY_ATTRIBUTES *sa, LONG initial,
|
|
|
|
LONG max, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
|
|
|
|
/* Check parameters */
|
|
|
|
|
|
|
|
if ((max <= 0) || (initial < 0) || (initial > max))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_PARAMETER );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_semaphore )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->initial = (unsigned int)initial;
|
|
|
|
req->max = (unsigned int)max;
|
|
|
|
req->inherit = (sa && (sa->nLength>=sizeof(*sa)) && sa->bInheritHandle);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2000-09-29 22:48:04 +02:00
|
|
|
SetLastError(0);
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenSemaphoreA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenSemaphoreA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenSemaphoreW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return OpenSemaphoreW( access, inherit, buffer );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* OpenSemaphoreW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenSemaphoreW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE ret;
|
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
2003-05-12 05:28:26 +02:00
|
|
|
if (!is_version_nt()) access = SEMAPHORE_ALL_ACCESS;
|
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( open_semaphore )
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
|
|
|
req->access = access;
|
|
|
|
req->inherit = inherit;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
|
|
|
wine_server_call_err( req );
|
|
|
|
ret = reply->handle;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2000-09-29 22:48:04 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* ReleaseSemaphore (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ReleaseSemaphore( HANDLE handle, LONG count, LONG *previous )
|
|
|
|
{
|
|
|
|
NTSTATUS status = NtReleaseSemaphore( handle, count, previous );
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return !status;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-20 06:14:45 +02:00
|
|
|
/*
|
|
|
|
* Timers
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateWaitableTimerA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateWaitableTimerA( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return CreateWaitableTimerW( sa, manual, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return CreateWaitableTimerW( sa, manual, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateWaitableTimerW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateWaitableTimerW( SECURITY_ATTRIBUTES *sa, BOOL manual, LPCWSTR name )
|
|
|
|
{
|
|
|
|
HANDLE handle;
|
|
|
|
NTSTATUS status;
|
|
|
|
UNICODE_STRING us;
|
|
|
|
DWORD attr = 0;
|
|
|
|
OBJECT_ATTRIBUTES oa;
|
|
|
|
|
|
|
|
if (name) RtlInitUnicodeString(&us, name);
|
|
|
|
if (sa && (sa->nLength >= sizeof(*sa)) && sa->bInheritHandle)
|
|
|
|
attr |= OBJ_INHERIT;
|
|
|
|
InitializeObjectAttributes(&oa, name ? &us : NULL, attr,
|
|
|
|
NULL /* FIXME */, NULL /* FIXME */);
|
|
|
|
status = NtCreateTimer(&handle, TIMER_ALL_ACCESS, &oa,
|
|
|
|
manual ? NotificationTimer : SynchronizationTimer);
|
|
|
|
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenWaitableTimerA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenWaitableTimerA( DWORD access, BOOL inherit, LPCSTR name )
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
|
|
|
|
if (!name) return OpenWaitableTimerW( access, inherit, NULL );
|
|
|
|
|
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return OpenWaitableTimerW( access, inherit, buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenWaitableTimerW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI OpenWaitableTimerW( DWORD access, BOOL inherit, LPCWSTR name )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
ULONG attr = 0;
|
|
|
|
UNICODE_STRING us;
|
|
|
|
HANDLE handle;
|
|
|
|
OBJECT_ATTRIBUTES oa;
|
|
|
|
|
|
|
|
if (inherit) attr |= OBJ_INHERIT;
|
|
|
|
|
|
|
|
if (name) RtlInitUnicodeString(&us, name);
|
|
|
|
InitializeObjectAttributes(&oa, name ? &us : NULL, attr, NULL /* FIXME */, NULL /* FIXME */);
|
|
|
|
status = NtOpenTimer(&handle, access, &oa);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetWaitableTimer (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetWaitableTimer( HANDLE handle, const LARGE_INTEGER *when, LONG period,
|
|
|
|
PTIMERAPCROUTINE callback, LPVOID arg, BOOL resume )
|
|
|
|
{
|
|
|
|
NTSTATUS status = NtSetTimer(handle, when, callback, arg, resume, period, NULL);
|
|
|
|
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
if (status != STATUS_TIMER_RESUME_IGNORED) return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CancelWaitableTimer (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CancelWaitableTimer( HANDLE handle )
|
|
|
|
{
|
|
|
|
NTSTATUS status;
|
|
|
|
|
|
|
|
status = NtCancelTimer(handle, NULL);
|
|
|
|
if (status != STATUS_SUCCESS)
|
|
|
|
{
|
|
|
|
SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateTimerQueue (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateTimerQueue(void)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DeleteTimerQueueEx (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteTimerQueueEx(HANDLE TimerQueue, HANDLE CompletionEvent)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p): stub\n", TimerQueue, CompletionEvent);
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CreateTimerQueueTimer (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Creates a timer-queue timer. This timer expires at the specified due
|
|
|
|
* time (in ms), then after every specified period (in ms). When the timer
|
|
|
|
* expires, the callback function is called.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* nonzero on success or zero on faillure
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Unimplemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreateTimerQueueTimer( PHANDLE phNewTimer, HANDLE TimerQueue,
|
|
|
|
WAITORTIMERCALLBACK Callback, PVOID Parameter,
|
|
|
|
DWORD DueTime, DWORD Period, ULONG Flags )
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DeleteTimerQueueTimer (KERNEL32.@)
|
|
|
|
*
|
|
|
|
* Cancels a timer-queue timer.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* nonzero on success or zero on faillure
|
|
|
|
*
|
|
|
|
* BUGS
|
|
|
|
* Unimplemented
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DeleteTimerQueueTimer( HANDLE TimerQueue, HANDLE Timer,
|
|
|
|
HANDLE CompletionEvent )
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
/*
|
|
|
|
* Pipes
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateNamedPipeA (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateNamedPipeA( LPCSTR name, DWORD dwOpenMode,
|
|
|
|
DWORD dwPipeMode, DWORD nMaxInstances,
|
|
|
|
DWORD nOutBufferSize, DWORD nInBufferSize,
|
|
|
|
DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!name) return CreateNamedPipeW( NULL, dwOpenMode, dwPipeMode, nMaxInstances,
|
|
|
|
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
2003-05-06 02:19:59 +02:00
|
|
|
return INVALID_HANDLE_VALUE;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return CreateNamedPipeW( buffer, dwOpenMode, dwPipeMode, nMaxInstances,
|
|
|
|
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* CreateNamedPipeW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
HANDLE WINAPI CreateNamedPipeW( LPCWSTR name, DWORD dwOpenMode,
|
|
|
|
DWORD dwPipeMode, DWORD nMaxInstances,
|
|
|
|
DWORD nOutBufferSize, DWORD nInBufferSize,
|
|
|
|
DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES attr )
|
|
|
|
{
|
2001-07-10 21:16:49 +02:00
|
|
|
HANDLE ret;
|
2003-02-19 23:06:36 +01:00
|
|
|
DWORD len;
|
|
|
|
static const WCHAR leadin[] = {'\\','\\','.','\\','P','I','P','E','\\'};
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
TRACE("(%s, %#08lx, %#08lx, %ld, %ld, %ld, %ld, %p)\n",
|
2000-09-29 22:48:04 +02:00
|
|
|
debugstr_w(name), dwOpenMode, dwPipeMode, nMaxInstances,
|
|
|
|
nOutBufferSize, nInBufferSize, nDefaultTimeOut, attr );
|
|
|
|
|
2003-02-19 23:06:36 +01:00
|
|
|
if (!name)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_PATH_NOT_FOUND );
|
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
len = strlenW(name);
|
2001-07-10 21:16:49 +02:00
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
2003-02-19 23:06:36 +01:00
|
|
|
return INVALID_HANDLE_VALUE;
|
|
|
|
}
|
|
|
|
if (strncmpiW(name, leadin, sizeof(leadin)/sizeof(leadin[0])))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_INVALID_NAME );
|
|
|
|
return INVALID_HANDLE_VALUE;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( create_named_pipe )
|
2001-07-10 21:16:49 +02:00
|
|
|
{
|
|
|
|
req->openmode = dwOpenMode;
|
|
|
|
req->pipemode = dwPipeMode;
|
|
|
|
req->maxinstances = nMaxInstances;
|
|
|
|
req->outsize = nOutBufferSize;
|
|
|
|
req->insize = nInBufferSize;
|
|
|
|
req->timeout = nDefaultTimeOut;
|
2001-11-30 19:46:42 +01:00
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
2001-07-10 21:16:49 +02:00
|
|
|
SetLastError(0);
|
2003-05-06 02:19:59 +02:00
|
|
|
if (!wine_server_call_err( req )) ret = reply->handle;
|
|
|
|
else ret = INVALID_HANDLE_VALUE;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_END_REQ;
|
2001-07-10 21:16:49 +02:00
|
|
|
return ret;
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* PeekNamedPipe (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI PeekNamedPipe( HANDLE hPipe, LPVOID lpvBuffer, DWORD cbBuffer,
|
|
|
|
LPDWORD lpcbRead, LPDWORD lpcbAvail, LPDWORD lpcbMessage )
|
|
|
|
{
|
2002-07-31 22:04:20 +02:00
|
|
|
#ifdef FIONREAD
|
2002-07-25 02:22:03 +02:00
|
|
|
int avail=0,fd;
|
|
|
|
|
|
|
|
fd = FILE_GetUnixHandle(hPipe, GENERIC_READ);
|
2002-09-05 01:34:03 +02:00
|
|
|
if (fd == -1) return FALSE;
|
|
|
|
|
2002-07-25 02:22:03 +02:00
|
|
|
if (ioctl(fd,FIONREAD, &avail ) != 0)
|
2002-09-05 01:34:03 +02:00
|
|
|
{
|
|
|
|
TRACE("FIONREAD failed reason: %s\n",strerror(errno));
|
2002-07-25 02:22:03 +02:00
|
|
|
close(fd);
|
2002-09-05 01:34:03 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (!avail) /* check for closed pipe */
|
|
|
|
{
|
|
|
|
struct pollfd pollfd;
|
|
|
|
pollfd.fd = fd;
|
|
|
|
pollfd.events = POLLIN;
|
|
|
|
pollfd.revents = 0;
|
|
|
|
switch (poll( &pollfd, 1, 0 ))
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case 1: /* got something */
|
|
|
|
if (!(pollfd.revents & (POLLHUP | POLLERR))) break;
|
|
|
|
TRACE("POLLHUP | POLLERR\n");
|
|
|
|
/* fall through */
|
|
|
|
case -1:
|
|
|
|
close(fd);
|
|
|
|
SetLastError(ERROR_BROKEN_PIPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2002-07-25 02:22:03 +02:00
|
|
|
close(fd);
|
|
|
|
TRACE(" 0x%08x bytes available\n", avail );
|
|
|
|
if (!lpvBuffer && lpcbAvail)
|
|
|
|
{
|
|
|
|
*lpcbAvail= avail;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-07-31 22:04:20 +02:00
|
|
|
#endif /* defined(FIONREAD) */
|
2002-07-25 02:22:03 +02:00
|
|
|
|
2000-09-29 22:48:04 +02:00
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
2002-07-25 02:22:03 +02:00
|
|
|
FIXME("function not implemented\n");
|
2000-09-29 22:48:04 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SYNC_CompletePipeOverlapped (Internal)
|
|
|
|
*/
|
|
|
|
static void SYNC_CompletePipeOverlapped (LPOVERLAPPED overlapped, DWORD result)
|
|
|
|
{
|
|
|
|
TRACE("for %p result %08lx\n",overlapped,result);
|
|
|
|
if(!overlapped)
|
|
|
|
return;
|
|
|
|
overlapped->Internal = result;
|
|
|
|
SetEvent(overlapped->hEvent);
|
|
|
|
}
|
2000-09-29 22:48:04 +02:00
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* WaitNamedPipeA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI WaitNamedPipeA (LPCSTR name, DWORD nTimeOut)
|
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
WCHAR buffer[MAX_PATH];
|
2001-11-07 21:14:45 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!name) return WaitNamedPipeW( NULL, nTimeOut );
|
2001-08-24 01:29:20 +02:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
if (!MultiByteToWideChar( CP_ACP, 0, name, -1, buffer, MAX_PATH ))
|
2001-11-07 21:14:45 +01:00
|
|
|
{
|
2001-11-30 19:46:42 +01:00
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return 0;
|
2001-11-07 21:14:45 +01:00
|
|
|
}
|
2001-11-30 19:46:42 +01:00
|
|
|
return WaitNamedPipeW( buffer, nTimeOut );
|
2000-09-29 22:48:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-13 22:13:18 +02:00
|
|
|
* WaitNamedPipeW (KERNEL32.@)
|
2000-09-29 22:48:04 +02:00
|
|
|
*/
|
2001-11-30 19:46:42 +01:00
|
|
|
BOOL WINAPI WaitNamedPipeW (LPCWSTR name, DWORD nTimeOut)
|
2000-09-29 22:48:04 +02:00
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
DWORD len = name ? strlenW(name) : 0;
|
|
|
|
BOOL ret;
|
2001-11-30 19:46:42 +01:00
|
|
|
OVERLAPPED ov;
|
2001-08-24 01:29:20 +02:00
|
|
|
|
|
|
|
if (len >= MAX_PATH)
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_FILENAME_EXCED_RANGE );
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
TRACE("%s 0x%08lx\n",debugstr_w(name),nTimeOut);
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2003-06-18 21:45:22 +02:00
|
|
|
memset(&ov,0,sizeof(ov));
|
2001-11-07 21:14:45 +01:00
|
|
|
ov.hEvent = CreateEventA( NULL, 0, 0, NULL );
|
|
|
|
if (!ov.hEvent)
|
2001-07-10 21:16:49 +02:00
|
|
|
return FALSE;
|
2001-11-07 21:14:45 +01:00
|
|
|
|
2001-11-30 19:46:42 +01:00
|
|
|
SERVER_START_REQ( wait_named_pipe )
|
|
|
|
{
|
|
|
|
req->timeout = nTimeOut;
|
|
|
|
req->overlapped = &ov;
|
|
|
|
req->func = SYNC_CompletePipeOverlapped;
|
|
|
|
wine_server_add_data( req, name, len * sizeof(WCHAR) );
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
if(ret)
|
|
|
|
{
|
|
|
|
if (WAIT_OBJECT_0==WaitForSingleObject(ov.hEvent,INFINITE))
|
|
|
|
{
|
|
|
|
SetLastError(ov.Internal);
|
|
|
|
ret = (ov.Internal==STATUS_SUCCESS);
|
|
|
|
}
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
2001-11-07 21:14:45 +01:00
|
|
|
CloseHandle(ov.hEvent);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SYNC_ConnectNamedPipe (Internal)
|
|
|
|
*/
|
|
|
|
static BOOL SYNC_ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if(!overlapped)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
overlapped->Internal = STATUS_PENDING;
|
2001-07-10 21:16:49 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( connect_named_pipe )
|
|
|
|
{
|
|
|
|
req->handle = hPipe;
|
2001-11-07 21:14:45 +01:00
|
|
|
req->overlapped = overlapped;
|
|
|
|
req->func = SYNC_CompletePipeOverlapped;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
2001-11-07 21:14:45 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ConnectNamedPipe (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ConnectNamedPipe(HANDLE hPipe, LPOVERLAPPED overlapped)
|
|
|
|
{
|
|
|
|
OVERLAPPED ov;
|
|
|
|
BOOL ret;
|
|
|
|
|
2002-10-25 23:02:30 +02:00
|
|
|
TRACE("(%p,%p)\n",hPipe, overlapped);
|
2001-11-07 21:14:45 +01:00
|
|
|
|
|
|
|
if(overlapped)
|
2003-06-06 20:10:36 +02:00
|
|
|
{
|
|
|
|
if(SYNC_ConnectNamedPipe(hPipe,overlapped))
|
|
|
|
SetLastError( ERROR_IO_PENDING );
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-11-07 21:14:45 +01:00
|
|
|
|
2003-06-18 21:45:22 +02:00
|
|
|
memset(&ov,0,sizeof(ov));
|
2001-11-07 21:14:45 +01:00
|
|
|
ov.hEvent = CreateEventA(NULL,0,0,NULL);
|
|
|
|
if (!ov.hEvent)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret=SYNC_ConnectNamedPipe(hPipe, &ov);
|
|
|
|
if(ret)
|
|
|
|
{
|
|
|
|
if (WAIT_OBJECT_0==WaitForSingleObject(ov.hEvent,INFINITE))
|
|
|
|
{
|
|
|
|
SetLastError(ov.Internal);
|
|
|
|
ret = (ov.Internal==STATUS_SUCCESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseHandle(ov.hEvent);
|
2001-07-10 21:16:49 +02:00
|
|
|
|
2001-08-24 01:29:20 +02:00
|
|
|
return ret;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DisconnectNamedPipe (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DisconnectNamedPipe(HANDLE hPipe)
|
|
|
|
{
|
2001-08-24 01:29:20 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2002-10-25 23:02:30 +02:00
|
|
|
TRACE("(%p)\n",hPipe);
|
2001-08-24 01:29:20 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( disconnect_named_pipe )
|
|
|
|
{
|
|
|
|
req->handle = hPipe;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
2003-05-15 06:22:45 +02:00
|
|
|
if (ret && reply->fd != -1) close( reply->fd );
|
2001-08-24 01:29:20 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return ret;
|
2001-07-10 21:16:49 +02:00
|
|
|
}
|
|
|
|
|
2001-08-24 21:15:35 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* TransactNamedPipe (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI TransactNamedPipe(
|
|
|
|
HANDLE hPipe, LPVOID lpInput, DWORD dwInputSize, LPVOID lpOutput,
|
|
|
|
DWORD dwOutputSize, LPDWORD lpBytesRead, LPOVERLAPPED lpOverlapped)
|
|
|
|
{
|
2002-10-25 23:02:30 +02:00
|
|
|
FIXME("%p %p %ld %p %ld %p %p\n",
|
2001-08-24 21:15:35 +02:00
|
|
|
hPipe, lpInput, dwInputSize, lpOutput,
|
|
|
|
dwOutputSize, lpBytesRead, lpOverlapped);
|
|
|
|
if(lpBytesRead)
|
|
|
|
*lpBytesRead=0;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeInfo (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeInfo(
|
|
|
|
HANDLE hNamedPipe, LPDWORD lpFlags, LPDWORD lpOutputBufferSize,
|
|
|
|
LPDWORD lpInputBufferSize, LPDWORD lpMaxInstances)
|
|
|
|
{
|
2001-08-27 21:03:42 +02:00
|
|
|
BOOL ret;
|
|
|
|
|
2002-10-25 23:02:30 +02:00
|
|
|
TRACE("%p %p %p %p %p\n", hNamedPipe, lpFlags,
|
2001-08-24 21:15:35 +02:00
|
|
|
lpOutputBufferSize, lpInputBufferSize, lpMaxInstances);
|
2001-08-27 21:03:42 +02:00
|
|
|
|
|
|
|
SERVER_START_REQ( get_named_pipe_info )
|
|
|
|
{
|
|
|
|
req->handle = hNamedPipe;
|
2001-11-30 19:46:42 +01:00
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
if(lpFlags) *lpFlags = reply->flags;
|
|
|
|
if(lpOutputBufferSize) *lpOutputBufferSize = reply->outsize;
|
|
|
|
if(lpInputBufferSize) *lpInputBufferSize = reply->outsize;
|
|
|
|
if(lpMaxInstances) *lpMaxInstances = reply->maxinstances;
|
2001-08-27 21:03:42 +02:00
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
|
|
|
|
return ret;
|
2001-08-24 21:15:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeHandleStateA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeHandleStateA(
|
|
|
|
HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
|
|
|
|
LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
|
|
|
|
LPSTR lpUsername, DWORD nUsernameMaxSize)
|
|
|
|
{
|
2002-10-25 23:02:30 +02:00
|
|
|
FIXME("%p %p %p %p %p %p %ld\n",
|
2001-08-24 21:15:35 +02:00
|
|
|
hNamedPipe, lpState, lpCurInstances,
|
|
|
|
lpMaxCollectionCount, lpCollectDataTimeout,
|
|
|
|
lpUsername, nUsernameMaxSize);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-24 21:15:35 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetNamedPipeHandleStateW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetNamedPipeHandleStateW(
|
|
|
|
HANDLE hNamedPipe, LPDWORD lpState, LPDWORD lpCurInstances,
|
|
|
|
LPDWORD lpMaxCollectionCount, LPDWORD lpCollectDataTimeout,
|
|
|
|
LPWSTR lpUsername, DWORD nUsernameMaxSize)
|
|
|
|
{
|
2002-10-25 23:02:30 +02:00
|
|
|
FIXME("%p %p %p %p %p %p %ld\n",
|
2001-08-24 21:15:35 +02:00
|
|
|
hNamedPipe, lpState, lpCurInstances,
|
|
|
|
lpMaxCollectionCount, lpCollectDataTimeout,
|
|
|
|
lpUsername, nUsernameMaxSize);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-08-24 21:15:35 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetNamedPipeHandleState (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI SetNamedPipeHandleState(
|
|
|
|
HANDLE hNamedPipe, LPDWORD lpMode, LPDWORD lpMaxCollectionCount,
|
|
|
|
LPDWORD lpCollectDataTimeout)
|
|
|
|
{
|
2002-10-25 23:02:30 +02:00
|
|
|
FIXME("%p %p %p %p\n",
|
2001-08-24 21:15:35 +02:00
|
|
|
hNamedPipe, lpMode, lpMaxCollectionCount, lpCollectDataTimeout);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CallNamedPipeA (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CallNamedPipeA(
|
|
|
|
LPCSTR lpNamedPipeName, LPVOID lpInput, DWORD lpInputSize,
|
|
|
|
LPVOID lpOutput, DWORD lpOutputSize,
|
|
|
|
LPDWORD lpBytesRead, DWORD nTimeout)
|
|
|
|
{
|
|
|
|
FIXME("%s %p %ld %p %ld %p %ld\n",
|
|
|
|
debugstr_a(lpNamedPipeName), lpInput, lpInputSize,
|
|
|
|
lpOutput, lpOutputSize, lpBytesRead, nTimeout);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CallNamedPipeW (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CallNamedPipeW(
|
|
|
|
LPCWSTR lpNamedPipeName, LPVOID lpInput, DWORD lpInputSize,
|
|
|
|
LPVOID lpOutput, DWORD lpOutputSize,
|
|
|
|
LPDWORD lpBytesRead, DWORD nTimeout)
|
|
|
|
{
|
|
|
|
FIXME("%s %p %ld %p %ld %p %ld\n",
|
|
|
|
debugstr_w(lpNamedPipeName), lpInput, lpInputSize,
|
|
|
|
lpOutput, lpOutputSize, lpBytesRead, nTimeout);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-05-20 06:32:53 +02:00
|
|
|
|
|
|
|
/******************************************************************
|
|
|
|
* CreatePipe (KERNEL32.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI CreatePipe( PHANDLE hReadPipe, PHANDLE hWritePipe,
|
|
|
|
LPSECURITY_ATTRIBUTES sa, DWORD size )
|
|
|
|
{
|
|
|
|
static unsigned index = 0;
|
|
|
|
char name[64];
|
|
|
|
HANDLE hr, hw;
|
|
|
|
unsigned in_index = index;
|
|
|
|
|
|
|
|
*hReadPipe = *hWritePipe = INVALID_HANDLE_VALUE;
|
|
|
|
/* generate a unique pipe name (system wide) */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
sprintf(name, "\\\\.\\pipe\\Win32.Pipes.%08lu.%08u", GetCurrentProcessId(), ++index);
|
|
|
|
hr = CreateNamedPipeA(name, PIPE_ACCESS_INBOUND,
|
|
|
|
PIPE_TYPE_BYTE | PIPE_WAIT, 1, size, size,
|
|
|
|
NMPWAIT_USE_DEFAULT_WAIT, sa);
|
|
|
|
} while (hr == INVALID_HANDLE_VALUE && index != in_index);
|
|
|
|
/* from completion sakeness, I think system resources might be exhausted before this happens !! */
|
|
|
|
if (hr == INVALID_HANDLE_VALUE) return FALSE;
|
|
|
|
|
|
|
|
hw = CreateFileA(name, GENERIC_WRITE, 0, sa, OPEN_EXISTING, 0, 0);
|
|
|
|
if (hw == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
CloseHandle(hr);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*hReadPipe = hr;
|
|
|
|
*hWritePipe = hw;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2003-06-24 05:34:15 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare ); */
|
|
|
|
__ASM_GLOBAL_FUNC(InterlockedCompareExchange,
|
|
|
|
"movl 12(%esp),%eax\n\t"
|
|
|
|
"movl 8(%esp),%ecx\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; cmpxchgl %ecx,(%edx)\n\t"
|
|
|
|
"ret $12");
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedExchange( PLONG dest, LONG val ); */
|
|
|
|
__ASM_GLOBAL_FUNC(InterlockedExchange,
|
|
|
|
"movl 8(%esp),%eax\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; xchgl %eax,(%edx)\n\t"
|
|
|
|
"ret $8");
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr ); */
|
|
|
|
__ASM_GLOBAL_FUNC(InterlockedExchangeAdd,
|
|
|
|
"movl 8(%esp),%eax\n\t"
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
|
|
|
"ret $8");
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
/* LONG WINAPI InterlockedIncrement( PLONG dest ); */
|
|
|
|
__ASM_GLOBAL_FUNC(InterlockedIncrement,
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"movl $1,%eax\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
|
|
|
"incl %eax\n\t"
|
|
|
|
"ret $4");
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
__ASM_GLOBAL_FUNC(InterlockedDecrement,
|
|
|
|
"movl 4(%esp),%edx\n\t"
|
|
|
|
"movl $-1,%eax\n\t"
|
|
|
|
"lock; xaddl %eax,(%edx)\n\t"
|
|
|
|
"decl %eax\n\t"
|
|
|
|
"ret $4");
|
|
|
|
|
|
|
|
#else /* __i386__ */
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedCompareExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI InterlockedCompareExchange( PLONG dest, LONG xchg, LONG compare )
|
|
|
|
{
|
|
|
|
return interlocked_cmpxchg( dest, xchg, compare );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchange (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI InterlockedExchange( PLONG dest, LONG val )
|
|
|
|
{
|
|
|
|
return interlocked_xchg( dest, val );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedExchangeAdd (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI InterlockedExchangeAdd( PLONG dest, LONG incr )
|
|
|
|
{
|
|
|
|
return interlocked_xchg_add( dest, incr );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedIncrement (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI InterlockedIncrement( PLONG dest )
|
|
|
|
{
|
|
|
|
return interlocked_xchg_add( dest, 1 ) + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InterlockedDecrement (KERNEL32.@)
|
|
|
|
*/
|
|
|
|
LONG WINAPI InterlockedDecrement( PLONG dest )
|
|
|
|
{
|
|
|
|
return interlocked_xchg_add( dest, -1 ) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|