Commit bff860c4 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved synchronization and syslevel routines to dlls/kernel.

parent 8db8368e
......@@ -52,6 +52,7 @@ C_SRCS = \
stress.c \
string.c \
sync.c \
syslevel.c \
system.c \
tape.c \
task.c \
......
......@@ -51,4 +51,6 @@ void FILE_ConvertOFMode( INT mode, DWORD *access, DWORD *sharing );
extern BOOL WOWTHUNK_Init(void);
extern VOID SYSLEVEL_CheckNotLevel( INT level );
#endif
......@@ -33,7 +33,7 @@
#include "stackframe.h"
#include "selectors.h"
#include "builtin16.h"
#include "syslevel.h"
#include "kernel_private.h"
#include "wine/library.h"
#include "wine/debug.h"
......
......@@ -43,6 +43,7 @@
#include "wine/server.h"
#include "wine/unicode.h"
#include "kernel_private.h"
#include "file.h"
#include "wine/debug.h"
......@@ -57,6 +58,165 @@ inline static int is_version_nt(void)
/***********************************************************************
* Sleep (KERNEL32.@)
*/
VOID WINAPI Sleep( DWORD timeout )
{
SleepEx( timeout, FALSE );
}
/******************************************************************************
* SleepEx (KERNEL32.@)
*/
DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable )
{
NTSTATUS status;
if (timeout == INFINITE) status = NtDelayExecution( alertable, NULL );
else
{
LARGE_INTEGER time;
time.QuadPart = timeout * (ULONGLONG)10000;
time.QuadPart = -time.QuadPart;
status = NtDelayExecution( alertable, &time );
}
if (status != STATUS_USER_APC) status = STATUS_SUCCESS;
return status;
}
/***********************************************************************
* WaitForSingleObject (KERNEL32.@)
*/
DWORD WINAPI WaitForSingleObject( HANDLE handle, DWORD timeout )
{
return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, FALSE );
}
/***********************************************************************
* WaitForSingleObjectEx (KERNEL32.@)
*/
DWORD WINAPI WaitForSingleObjectEx( HANDLE handle, DWORD timeout,
BOOL alertable )
{
return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, alertable );
}
/***********************************************************************
* WaitForMultipleObjects (KERNEL32.@)
*/
DWORD WINAPI WaitForMultipleObjects( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout )
{
return WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
}
/***********************************************************************
* WaitForMultipleObjectsEx (KERNEL32.@)
*/
DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout,
BOOL alertable )
{
NTSTATUS status;
HANDLE hloc[MAXIMUM_WAIT_OBJECTS];
int i;
if (count >= MAXIMUM_WAIT_OBJECTS)
{
SetLastError(ERROR_INVALID_PARAMETER);
return WAIT_FAILED;
}
for (i = 0; i < count; i++)
{
if ((handles[i] == (HANDLE)STD_INPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_OUTPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_ERROR_HANDLE))
hloc[i] = GetStdHandle( (DWORD)handles[i] );
else
hloc[i] = handles[i];
/* yes, even screen buffer console handles are waitable, and are
* handled as a handle to the console itself !!
*/
if (is_console_handle(hloc[i]))
{
if (!VerifyConsoleIoHandle(hloc[i]))
{
return FALSE;
}
hloc[i] = GetConsoleInputWaitHandle();
}
}
if (timeout == INFINITE)
{
status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, NULL );
}
else
{
LARGE_INTEGER time;
time.QuadPart = timeout * (ULONGLONG)10000;
time.QuadPart = -time.QuadPart;
status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, &time );
}
if (HIWORD(status)) /* is it an error code? */
{
SetLastError( RtlNtStatusToDosError(status) );
status = WAIT_FAILED;
}
return status;
}
/***********************************************************************
* WaitForSingleObject (KERNEL.460)
*/
DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForSingleObject( handle, timeout );
RestoreThunkLock( mutex_count );
return retval;
}
/***********************************************************************
* WaitForMultipleObjects (KERNEL.461)
*/
DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
RestoreThunkLock( mutex_count );
return retval;
}
/***********************************************************************
* WaitForMultipleObjectsEx (KERNEL.495)
*/
DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout, BOOL alertable )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
RestoreThunkLock( mutex_count );
return retval;
}
/***********************************************************************
* InitializeCriticalSection (KERNEL32.@)
*
* Initialise a critical section before use.
......
......@@ -30,8 +30,8 @@
#include "winreg.h"
#include "winternl.h"
#include "wine/winbase16.h"
#include "syslevel.h"
#include "thread.h"
#include "kernel_private.h"
#include "wine/library.h"
#include "wine/debug.h"
......@@ -47,7 +47,7 @@ static CRITICAL_SECTION_DEBUG critsect_debug =
static SYSLEVEL Win16Mutex = { { &critsect_debug, -1, 0, 0, 0, 0 }, 1 };
/* Global variable to save current TEB while in 16-bit code */
WORD SYSLEVEL_Win16CurrentTeb = 0;
extern WORD SYSLEVEL_Win16CurrentTeb;
/************************************************************************
......@@ -113,8 +113,9 @@ VOID WINAPI _EnterSysLevel(SYSLEVEL *lock)
TRACE("(%p, level %d): thread %lx count after %ld\n",
lock, lock->level, GetCurrentThreadId(), teb->sys_count[lock->level] );
if (lock == &Win16Mutex)
SYSLEVEL_Win16CurrentTeb = wine_get_fs();
#ifdef __i386__
if (lock == &Win16Mutex) SYSLEVEL_Win16CurrentTeb = wine_get_fs();
#endif
}
/************************************************************************
......
......@@ -45,11 +45,11 @@
#include "winternl.h"
#include "selectors.h"
#include "wine/server.h"
#include "syslevel.h"
#include "stackframe.h"
#include "task.h"
#include "thread.h"
#include "toolhelp.h"
#include "kernel_private.h"
#include "wine/debug.h"
......
......@@ -32,11 +32,11 @@
#include "excpt.h"
#include "winreg.h"
#include "winternl.h"
#include "syslevel.h"
#include "file.h"
#include "task.h"
#include "miscemu.h"
#include "stackframe.h"
#include "kernel_private.h"
#include "wine/exception.h"
#include "wine/debug.h"
......
......@@ -37,8 +37,6 @@ C_SRCS = \
$(TOPOBJDIR)/scheduler/handle.c \
$(TOPOBJDIR)/scheduler/process.c \
$(TOPOBJDIR)/scheduler/pthread.c \
$(TOPOBJDIR)/scheduler/synchro.c \
$(TOPOBJDIR)/scheduler/syslevel.c \
$(TOPOBJDIR)/scheduler/thread.c \
$(TOPOBJDIR)/win32/device.c \
$(TOPOBJDIR)/win32/newfns.c \
......
......@@ -407,7 +407,6 @@ typedef struct
#include "wine/exception.h"
#include "global.h"
#include "syslevel.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(seh);
......@@ -418,6 +417,9 @@ static wine_signal_handler handlers[256];
extern void WINAPI EXC_RtlRaiseException( PEXCEPTION_RECORD, PCONTEXT );
/* Global variable to save current TEB while in 16-bit code (FIXME) */
WORD SYSLEVEL_Win16CurrentTeb = 0;
/***********************************************************************
* dispatch_signal
*/
......
/*
* Win32 'syslevel' routines
*
* Copyright 1998 Ulrich Weigand
*
* 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
*/
#ifndef __WINE_SYSLEVEL_H
#define __WINE_SYSLEVEL_H
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
extern WORD SYSLEVEL_Win16CurrentTeb;
extern WORD SYSLEVEL_EmergencyTeb;
VOID SYSLEVEL_CheckNotLevel( INT level );
#endif /* __WINE_SYSLEVEL_H */
/*
* Win32 process and thread synchronisation
*
* Copyright 1997 Alexandre Julliard
*
* 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
*/
#include "config.h"
#include <stdarg.h>
#include "ntstatus.h"
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winternl.h"
#include "../kernel/kernel_private.h" /* FIXME: to be changed when moving file to dlls/kernel */
/***********************************************************************
* Sleep (KERNEL32.@)
*/
VOID WINAPI Sleep( DWORD timeout )
{
SleepEx( timeout, FALSE );
}
/******************************************************************************
* SleepEx (KERNEL32.@)
*/
DWORD WINAPI SleepEx( DWORD timeout, BOOL alertable )
{
NTSTATUS status;
if (timeout == INFINITE) status = NtDelayExecution( alertable, NULL );
else
{
LARGE_INTEGER time;
time.QuadPart = timeout * (ULONGLONG)10000;
time.QuadPart = -time.QuadPart;
status = NtDelayExecution( alertable, &time );
}
if (status != STATUS_USER_APC) status = STATUS_SUCCESS;
return status;
}
/***********************************************************************
* WaitForSingleObject (KERNEL32.@)
*/
DWORD WINAPI WaitForSingleObject( HANDLE handle, DWORD timeout )
{
return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, FALSE );
}
/***********************************************************************
* WaitForSingleObjectEx (KERNEL32.@)
*/
DWORD WINAPI WaitForSingleObjectEx( HANDLE handle, DWORD timeout,
BOOL alertable )
{
return WaitForMultipleObjectsEx( 1, &handle, FALSE, timeout, alertable );
}
/***********************************************************************
* WaitForMultipleObjects (KERNEL32.@)
*/
DWORD WINAPI WaitForMultipleObjects( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout )
{
return WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
}
/***********************************************************************
* WaitForMultipleObjectsEx (KERNEL32.@)
*/
DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout,
BOOL alertable )
{
NTSTATUS status;
HANDLE hloc[MAXIMUM_WAIT_OBJECTS];
int i;
if (count >= MAXIMUM_WAIT_OBJECTS)
{
SetLastError(ERROR_INVALID_PARAMETER);
return WAIT_FAILED;
}
for (i = 0; i < count; i++)
{
if ((handles[i] == (HANDLE)STD_INPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_OUTPUT_HANDLE) ||
(handles[i] == (HANDLE)STD_ERROR_HANDLE))
hloc[i] = GetStdHandle( (DWORD)handles[i] );
else
hloc[i] = handles[i];
/* yes, even screen buffer console handles are waitable, and are
* handled as a handle to the console itself !!
*/
if (is_console_handle(hloc[i]))
{
if (!VerifyConsoleIoHandle(hloc[i]))
{
return FALSE;
}
hloc[i] = GetConsoleInputWaitHandle();
}
}
if (timeout == INFINITE)
{
status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, NULL );
}
else
{
LARGE_INTEGER time;
time.QuadPart = timeout * (ULONGLONG)10000;
time.QuadPart = -time.QuadPart;
status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, &time );
}
if (HIWORD(status)) /* is it an error code? */
{
SetLastError( RtlNtStatusToDosError(status) );
status = WAIT_FAILED;
}
return status;
}
/***********************************************************************
* WaitForSingleObject (KERNEL.460)
*/
DWORD WINAPI WaitForSingleObject16( HANDLE handle, DWORD timeout )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForSingleObject( handle, timeout );
RestoreThunkLock( mutex_count );
return retval;
}
/***********************************************************************
* WaitForMultipleObjects (KERNEL.461)
*/
DWORD WINAPI WaitForMultipleObjects16( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, FALSE );
RestoreThunkLock( mutex_count );
return retval;
}
/***********************************************************************
* WaitForMultipleObjectsEx (KERNEL.495)
*/
DWORD WINAPI WaitForMultipleObjectsEx16( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout, BOOL alertable )
{
DWORD retval, mutex_count;
ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
RestoreThunkLock( mutex_count );
return retval;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment