Commit ab687979 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved standard syslevel APIs declaration to winbase.h.

Use exported syslevel function wherever possible. Moved SEGPTR declaration to windef16.h.
parent 3606dc55
...@@ -389,8 +389,8 @@ owner kernel32 ...@@ -389,8 +389,8 @@ owner kernel32
477 stub WOAFullScreen 477 stub WOAFullScreen
478 stub WOATerminateProcess 478 stub WOATerminateProcess
479 pascal KERNEL_479(long) VWin32_EventSet # ??? 479 pascal KERNEL_479(long) VWin32_EventSet # ???
480 pascal16 _EnterWin16Lock() SYSLEVEL_EnterWin16Lock 480 pascal16 _EnterWin16Lock() _EnterWin16Lock
481 pascal16 _LeaveWin16Lock() SYSLEVEL_LeaveWin16Lock 481 pascal16 _LeaveWin16Lock() _LeaveWin16Lock
482 pascal LoadSystemLibrary32(str) LoadLibrary32_16 # FIXME! 482 pascal LoadSystemLibrary32(str) LoadLibrary32_16 # FIXME!
483 pascal MapProcessHandle(long) MapProcessHandle 483 pascal MapProcessHandle(long) MapProcessHandle
484 pascal SetProcessDWORD(long s_word long) SetProcessDword 484 pascal SetProcessDWORD(long s_word long) SetProcessDword
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "winerror.h" #include "winerror.h"
#include "winnls.h" #include "winnls.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "syslevel.h"
#include "server.h" #include "server.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -222,9 +221,11 @@ VOID WINAPI VWin32_EventDestroy(HANDLE event) ...@@ -222,9 +221,11 @@ VOID WINAPI VWin32_EventDestroy(HANDLE event)
*/ */
VOID WINAPI VWin32_EventWait(HANDLE event) VOID WINAPI VWin32_EventWait(HANDLE event)
{ {
SYSLEVEL_ReleaseWin16Lock(); DWORD mutex_count;
ReleaseThunkLock( &mutex_count );
WaitForSingleObject( event, INFINITE ); WaitForSingleObject( event, INFINITE );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
} }
/*********************************************************************** /***********************************************************************
......
...@@ -24,7 +24,6 @@ ...@@ -24,7 +24,6 @@
#include "module.h" #include "module.h"
#include "selectors.h" #include "selectors.h"
#include "stackframe.h" #include "stackframe.h"
#include "syslevel.h"
#include "task.h" #include "task.h"
DEFAULT_DEBUG_CHANNEL(thunk); DEFAULT_DEBUG_CHANNEL(thunk);
...@@ -1134,7 +1133,9 @@ void WINAPI K32Thk1632Prolog( CONTEXT86 *context ) ...@@ -1134,7 +1133,9 @@ void WINAPI K32Thk1632Prolog( CONTEXT86 *context )
context->Ebp, context->Esp, NtCurrentTeb()->cur_stack); context->Ebp, context->Esp, NtCurrentTeb()->cur_stack);
} }
SYSLEVEL_ReleaseWin16Lock(); /* entry_point is never used again once the entry point has
been called. Thus we re-use it to hold the Win16Lock count */
ReleaseThunkLock(&CURRENT_STACK16->entry_point);
} }
/*********************************************************************** /***********************************************************************
...@@ -1144,7 +1145,7 @@ void WINAPI K32Thk1632Epilog( CONTEXT86 *context ) ...@@ -1144,7 +1145,7 @@ void WINAPI K32Thk1632Epilog( CONTEXT86 *context )
{ {
LPBYTE code = (LPBYTE)context->Eip - 13; LPBYTE code = (LPBYTE)context->Eip - 13;
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock(CURRENT_STACK16->entry_point);
/* We undo the SYSTHUNK hack if necessary. See K32Thk1632Prolog. */ /* We undo the SYSTHUNK hack if necessary. See K32Thk1632Prolog. */
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "file.h" #include "file.h"
#include "heap.h" #include "heap.h"
#include "miscemu.h" #include "miscemu.h"
#include "syslevel.h"
#include "stackframe.h" #include "stackframe.h"
#include "builtin16.h" #include "builtin16.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -315,6 +314,7 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ...@@ -315,6 +314,7 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags
{ {
HMODULE hModule; HMODULE hModule;
DOS_FULL_NAME full_name; DOS_FULL_NAME full_name;
DWORD mutex_count;
/* if the file can not be found, call LoadLibraryExA anyway, since it might be /* if the file can not be found, call LoadLibraryExA anyway, since it might be
a buildin module. This case is handled in MODULE_LoadLibraryExA */ a buildin module. This case is handled in MODULE_LoadLibraryExA */
...@@ -323,10 +323,9 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags ...@@ -323,10 +323,9 @@ DWORD WINAPI LoadLibraryEx32W16( LPCSTR lpszLibFile, DWORD hFile, DWORD dwFlags
strcpy ( full_name.short_name, lpszLibFile ); strcpy ( full_name.short_name, lpszLibFile );
} }
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
hModule = LoadLibraryExA( full_name.short_name, (HANDLE)hFile, dwFlags ); hModule = LoadLibraryExA( full_name.short_name, (HANDLE)hFile, dwFlags );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return (DWORD)hModule; return (DWORD)hModule;
} }
...@@ -344,11 +343,11 @@ DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc ) ...@@ -344,11 +343,11 @@ DWORD WINAPI GetProcAddress32W16( DWORD hModule, LPCSTR lpszProc )
DWORD WINAPI FreeLibrary32W16( DWORD hLibModule ) DWORD WINAPI FreeLibrary32W16( DWORD hLibModule )
{ {
BOOL retv; BOOL retv;
DWORD mutex_count;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
retv = FreeLibrary( (HMODULE)hLibModule ); retv = FreeLibrary( (HMODULE)hLibModule );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return (DWORD)retv; return (DWORD)retv;
} }
...@@ -361,11 +360,12 @@ static DWORD WOW_CallProc32W16( BOOL Ex ) ...@@ -361,11 +360,12 @@ static DWORD WOW_CallProc32W16( BOOL Ex )
DWORD nrofargs, argconvmask; DWORD nrofargs, argconvmask;
FARPROC proc32; FARPROC proc32;
DWORD *args, ret; DWORD *args, ret;
DWORD mutex_count;
VA_LIST16 valist; VA_LIST16 valist;
int i; int i;
int aix; int aix;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
VA_START16( valist ); VA_START16( valist );
nrofargs = VA_ARG16( valist, DWORD ); nrofargs = VA_ARG16( valist, DWORD );
...@@ -446,8 +446,7 @@ static DWORD WOW_CallProc32W16( BOOL Ex ) ...@@ -446,8 +446,7 @@ static DWORD WOW_CallProc32W16( BOOL Ex )
TRACE("returns %08lx\n",ret); TRACE("returns %08lx\n",ret);
HeapFree( GetProcessHeap(), 0, args ); HeapFree( GetProcessHeap(), 0, args );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return ret; return ret;
} }
......
...@@ -432,12 +432,6 @@ static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext ) ...@@ -432,12 +432,6 @@ static void save_context( CONTEXT *context, const SIGCONTEXT *sigcontext )
} }
#endif /* linux */ #endif /* linux */
if (!fs)
{
fs = SYSLEVEL_EmergencyTeb;
__set_fs(fs);
ERR("fallback to emergency TEB\n");
}
__set_fs(fs); __set_fs(fs);
context->Eax = EAX_sig(sigcontext); context->Eax = EAX_sig(sigcontext);
......
...@@ -135,9 +135,6 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -135,9 +135,6 @@ BOOL WINAPI USER_Init(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
/* Load the graphics driver */ /* Load the graphics driver */
if (!load_driver()) return FALSE; if (!load_driver()) return FALSE;
/* Initialize window handling (critical section) */
WIN_Init();
/* Initialize system colors and metrics*/ /* Initialize system colors and metrics*/
SYSMETRICS_Init(); SYSMETRICS_Init();
SYSCOLOR_Init(); SYSCOLOR_Init();
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include "winbase.h" #include "winbase.h"
#include "wine/windef16.h"
/*********************************************************************** /***********************************************************************
* GetWin32sDirectory * GetWin32sDirectory
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "windef.h" #include "windef.h"
#include "wine/windef16.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(dll); DEFAULT_DEBUG_CHANNEL(dll);
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "wine/winestring.h" #include "wine/winestring.h"
#include "heap.h" #include "heap.h"
#include "winemm.h" #include "winemm.h"
#include "syslevel.h"
#include "selectors.h" #include "selectors.h"
#include "module.h" #include "module.h"
#include "debugtools.h" #include "debugtools.h"
......
...@@ -13,10 +13,9 @@ ...@@ -13,10 +13,9 @@
#include "winuser.h" #include "winuser.h"
#include "winemm.h" #include "winemm.h"
#include "services.h" #include "services.h"
#include "syslevel.h"
#include "debugtools.h" #include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(mmtime) DEFAULT_DEBUG_CHANNEL(mmtime);
/* /*
* FIXME * FIXME
...@@ -383,10 +382,8 @@ DWORD WINAPI timeGetTime(void) ...@@ -383,10 +382,8 @@ DWORD WINAPI timeGetTime(void)
/* FIXME: releasing the win16 lock here is a temporary hack (I hope) /* FIXME: releasing the win16 lock here is a temporary hack (I hope)
* that lets mciavi.drv run correctly * that lets mciavi.drv run correctly
*/ */
if ( _ConfirmWin16Lock() ) { DWORD count;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock(&count);
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock(count);
}
return MULTIMEDIA_MMTimeStart()->mmSysTimeMS; return MULTIMEDIA_MMTimeStart()->mmSysTimeMS;
} }
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "file.h" #include "file.h"
#include "heap.h" #include "heap.h"
#include "msdos.h" #include "msdos.h"
#include "syslevel.h"
#include "server.h" #include "server.h"
#include "options.h" #include "options.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -1501,7 +1500,7 @@ int DOSFS_FindNext( const char *path, const char *short_mask, ...@@ -1501,7 +1500,7 @@ int DOSFS_FindNext( const char *path, const char *short_mask,
LPCSTR short_name, long_name; LPCSTR short_name, long_name;
int count; int count;
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
/* Check the cached directory */ /* Check the cached directory */
if (!(info.dir && info.path == path && info.short_mask == short_mask if (!(info.dir && info.path == path && info.short_mask == short_mask
...@@ -1538,7 +1537,7 @@ int DOSFS_FindNext( const char *path, const char *short_mask, ...@@ -1538,7 +1537,7 @@ int DOSFS_FindNext( const char *path, const char *short_mask,
memset( &info, '\0', sizeof(info) ); memset( &info, '\0', sizeof(info) );
} }
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
return count; return count;
} }
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "config.h" #include "config.h"
#include "winbase.h" #include "winbase.h"
#include "wine/windef16.h" /* for SEGPTR */
extern HANDLE SystemHeap; extern HANDLE SystemHeap;
extern HANDLE SegptrHeap; extern HANDLE SegptrHeap;
......
...@@ -10,32 +10,9 @@ ...@@ -10,32 +10,9 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
typedef struct tagSYSLEVEL
{
CRITICAL_SECTION crst;
INT level;
} SYSLEVEL;
extern WORD SYSLEVEL_Win16CurrentTeb; extern WORD SYSLEVEL_Win16CurrentTeb;
extern WORD SYSLEVEL_EmergencyTeb; extern WORD SYSLEVEL_EmergencyTeb;
void SYSLEVEL_Init(void);
VOID WINAPI SYSLEVEL_EnterWin16Lock(void);
VOID WINAPI SYSLEVEL_LeaveWin16Lock(void);
VOID SYSLEVEL_ReleaseWin16Lock(void);
VOID SYSLEVEL_RestoreWin16Lock(void);
VOID SYSLEVEL_CheckNotLevel( INT level ); VOID SYSLEVEL_CheckNotLevel( INT level );
VOID WINAPI GetpWin16Lock(SYSLEVEL **lock);
SEGPTR WINAPI GetpWin16Lock16(void);
DWORD WINAPI _ConfirmWin16Lock(void);
VOID WINAPI _CreateSysLevel(SYSLEVEL *lock, INT level);
VOID WINAPI _EnterSysLevel(SYSLEVEL *lock);
VOID WINAPI _LeaveSysLevel(SYSLEVEL *lock);
DWORD WINAPI _ConfirmSysLevel(SYSLEVEL *lock);
VOID WINAPI ReleaseThunkLock(DWORD *mutex_count);
VOID WINAPI RestoreThunkLock(DWORD mutex_count);
#endif /* __WINE_SYSLEVEL_H */ #endif /* __WINE_SYSLEVEL_H */
...@@ -174,7 +174,6 @@ typedef struct ...@@ -174,7 +174,6 @@ typedef struct
#define UNC_IN_BEGINPAINT 0x0020 #define UNC_IN_BEGINPAINT 0x0020
/* Window functions */ /* Window functions */
extern void WIN_Init( void );
extern void WIN_LockWnds( void ); extern void WIN_LockWnds( void );
extern void WIN_UnlockWnds( void ); extern void WIN_UnlockWnds( void );
extern int WIN_SuspendWndsLock( void ); extern int WIN_SuspendWndsLock( void );
......
...@@ -1476,8 +1476,6 @@ BOOL WINAPI LookupPrivilegeValueW(LPCWSTR,LPCWSTR,LPVOID); ...@@ -1476,8 +1476,6 @@ BOOL WINAPI LookupPrivilegeValueW(LPCWSTR,LPCWSTR,LPVOID);
BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD); BOOL WINAPI MakeSelfRelativeSD(PSECURITY_DESCRIPTOR,PSECURITY_DESCRIPTOR,LPDWORD);
HMODULE WINAPI MapHModuleSL(WORD); HMODULE WINAPI MapHModuleSL(WORD);
WORD WINAPI MapHModuleLS(HMODULE); WORD WINAPI MapHModuleLS(HMODULE);
SEGPTR WINAPI MapLS(LPVOID);
LPVOID WINAPI MapSL(SEGPTR);
LPVOID WINAPI MapViewOfFile(HANDLE,DWORD,DWORD,DWORD,DWORD); LPVOID WINAPI MapViewOfFile(HANDLE,DWORD,DWORD,DWORD,DWORD);
LPVOID WINAPI MapViewOfFileEx(HANDLE,DWORD,DWORD,DWORD,DWORD,LPVOID); LPVOID WINAPI MapViewOfFileEx(HANDLE,DWORD,DWORD,DWORD,DWORD,LPVOID);
BOOL WINAPI MoveFileA(LPCSTR,LPCSTR); BOOL WINAPI MoveFileA(LPCSTR,LPCSTR);
...@@ -1599,7 +1597,6 @@ BOOL WINAPI TlsFree(DWORD); ...@@ -1599,7 +1597,6 @@ BOOL WINAPI TlsFree(DWORD);
LPVOID WINAPI TlsGetValue(DWORD); LPVOID WINAPI TlsGetValue(DWORD);
BOOL WINAPI TlsSetValue(DWORD,LPVOID); BOOL WINAPI TlsSetValue(DWORD,LPVOID);
BOOL WINAPI TransmitCommChar(HANDLE,CHAR); BOOL WINAPI TransmitCommChar(HANDLE,CHAR);
VOID WINAPI UnMapLS(SEGPTR);
BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD); BOOL WINAPI UnlockFile(HANDLE,DWORD,DWORD,DWORD,DWORD);
BOOL WINAPI UnmapViewOfFile(LPVOID); BOOL WINAPI UnmapViewOfFile(LPVOID);
LPVOID WINAPI VirtualAlloc(LPVOID,DWORD,DWORD,DWORD); LPVOID WINAPI VirtualAlloc(LPVOID,DWORD,DWORD,DWORD);
...@@ -1875,6 +1872,25 @@ INT WINAPI lstrcmpiW(LPCWSTR,LPCWSTR); ...@@ -1875,6 +1872,25 @@ INT WINAPI lstrcmpiW(LPCWSTR,LPCWSTR);
#define ZeroMemory RtlZeroMemory #define ZeroMemory RtlZeroMemory
#define CopyMemory RtlCopyMemory #define CopyMemory RtlCopyMemory
/* undocumented functions */
typedef struct tagSYSLEVEL
{
CRITICAL_SECTION crst;
INT level;
} SYSLEVEL;
VOID WINAPI GetpWin16Lock(SYSLEVEL**);
DWORD WINAPI MapLS(LPVOID);
LPVOID WINAPI MapSL(DWORD);
VOID WINAPI ReleaseThunkLock(DWORD*);
VOID WINAPI RestoreThunkLock(DWORD);
VOID WINAPI UnMapLS(DWORD);
DWORD WINAPI _ConfirmWin16Lock(void);
DWORD WINAPI _ConfirmSysLevel(SYSLEVEL*);
VOID WINAPI _EnterSysLevel(SYSLEVEL*);
VOID WINAPI _LeaveSysLevel(SYSLEVEL*);
/* a few optimizations for i386/gcc */ /* a few optimizations for i386/gcc */
#if defined(__i386__) && defined(__GNUC__) #if defined(__i386__) && defined(__GNUC__)
......
...@@ -234,14 +234,6 @@ typedef FLOAT *LPFLOAT; ...@@ -234,14 +234,6 @@ typedef FLOAT *LPFLOAT;
typedef BOOL *PBOOL; typedef BOOL *PBOOL;
typedef BOOL *LPBOOL; typedef BOOL *LPBOOL;
/* Special case: a segmented pointer is just a pointer in the user's code. */
#ifdef __WINE__
typedef DWORD SEGPTR;
#else
typedef void* SEGPTR;
#endif /* __WINE__ */
/* Handle types that exist both in Win16 and Win32. */ /* Handle types that exist both in Win16 and Win32. */
#ifdef STRICT #ifdef STRICT
......
...@@ -78,6 +78,7 @@ INT16 WINAPI GetInstanceData16(HINSTANCE16,WORD,INT16); ...@@ -78,6 +78,7 @@ INT16 WINAPI GetInstanceData16(HINSTANCE16,WORD,INT16);
BOOL16 WINAPI GetModuleName16(HINSTANCE16,LPSTR,INT16); BOOL16 WINAPI GetModuleName16(HINSTANCE16,LPSTR,INT16);
INT16 WINAPI GetModuleUsage16(HINSTANCE16); INT16 WINAPI GetModuleUsage16(HINSTANCE16);
UINT16 WINAPI GetNumTasks16(void); UINT16 WINAPI GetNumTasks16(void);
SEGPTR WINAPI GetpWin16Lock16(void);
DWORD WINAPI GetSelectorLimit16(WORD); DWORD WINAPI GetSelectorLimit16(WORD);
FARPROC16 WINAPI GetSetKernelDOSProc16(FARPROC16 DosProc); FARPROC16 WINAPI GetSetKernelDOSProc16(FARPROC16 DosProc);
HINSTANCE16 WINAPI GetTaskDS16(void); HINSTANCE16 WINAPI GetTaskDS16(void);
...@@ -117,6 +118,9 @@ VOID WINAPI SwitchStackTo16(WORD,WORD,WORD); ...@@ -117,6 +118,9 @@ VOID WINAPI SwitchStackTo16(WORD,WORD,WORD);
BOOL16 WINAPI WaitEvent16(HTASK16); BOOL16 WINAPI WaitEvent16(HTASK16);
VOID WINAPI WriteOutProfiles16(void); VOID WINAPI WriteOutProfiles16(void);
VOID WINAPI hmemcpy16(LPVOID,LPCVOID,LONG); VOID WINAPI hmemcpy16(LPVOID,LPCVOID,LONG);
VOID WINAPI _CreateSysLevel(SYSLEVEL*,INT);
VOID WINAPI _EnterWin16Lock(void);
VOID WINAPI _LeaveWin16Lock(void);
INT16 WINAPI AccessResource16(HINSTANCE16,HRSRC16); INT16 WINAPI AccessResource16(HINSTANCE16,HRSRC16);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
typedef short INT16; typedef short INT16;
typedef unsigned short UINT16; typedef unsigned short UINT16;
typedef unsigned short BOOL16; typedef unsigned short BOOL16;
typedef DWORD SEGPTR;
typedef UINT16 HANDLE16; typedef UINT16 HANDLE16;
typedef HANDLE16 *LPHANDLE16; typedef HANDLE16 *LPHANDLE16;
......
...@@ -153,7 +153,7 @@ typedef struct WSAData { ...@@ -153,7 +153,7 @@ typedef struct WSAData {
char szSystemStatus[WSASYS_STATUS_LEN+1]; char szSystemStatus[WSASYS_STATUS_LEN+1];
WORD iMaxSockets; WORD iMaxSockets;
WORD iMaxUdpDg; WORD iMaxUdpDg;
SEGPTR lpVendorInfo; char *lpVendorInfo;
} WSADATA, *LPWSADATA; } WSADATA, *LPWSADATA;
#include "poppack.h" #include "poppack.h"
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "heap.h" #include "heap.h"
#include "neexe.h" #include "neexe.h"
#include "process.h" #include "process.h"
#include "syslevel.h"
#include "selectors.h" #include "selectors.h"
#include "debugtools.h" #include "debugtools.h"
#include "callback.h" #include "callback.h"
...@@ -798,9 +797,10 @@ HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow ) ...@@ -798,9 +797,10 @@ HINSTANCE16 WINAPI WinExec16( LPCSTR lpCmdLine, UINT16 nCmdShow )
if (ret == 21) /* 32-bit module */ if (ret == 21) /* 32-bit module */
{ {
SYSLEVEL_ReleaseWin16Lock(); DWORD count;
ReleaseThunkLock( &count );
ret = WinExec( lpCmdLine, nCmdShow ); ret = WinExec( lpCmdLine, nCmdShow );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( count );
} }
return ret; return ret;
} }
...@@ -1452,11 +1452,11 @@ HMODULE WINAPI LoadLibraryW(LPCWSTR libnameW) ...@@ -1452,11 +1452,11 @@ HMODULE WINAPI LoadLibraryW(LPCWSTR libnameW)
HMODULE WINAPI LoadLibrary32_16( LPCSTR libname ) HMODULE WINAPI LoadLibrary32_16( LPCSTR libname )
{ {
HMODULE hModule; HMODULE hModule;
DWORD count;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &count );
hModule = LoadLibraryA( libname ); hModule = LoadLibraryA( libname );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( count );
return hModule; return hModule;
} }
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "global.h" #include "global.h"
#include "process.h" #include "process.h"
#include "snoop.h" #include "snoop.h"
#include "syslevel.h"
#include "builtin16.h" #include "builtin16.h"
#include "stackframe.h" #include "stackframe.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -1120,7 +1119,7 @@ static void NE_InitProcess(void) ...@@ -1120,7 +1119,7 @@ static void NE_InitProcess(void)
SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule ); SEGTABLEENTRY *pSegTable = NE_SEG_TABLE( pModule );
WORD sp; WORD sp;
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
if ( pModule->count > 0 ) if ( pModule->count > 0 )
{ {
...@@ -1197,7 +1196,7 @@ static void NE_InitProcess(void) ...@@ -1197,7 +1196,7 @@ static void NE_InitProcess(void)
ExitThread( LOWORD(context.Eax) ); ExitThread( LOWORD(context.Eax) );
} }
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
ExitThread( hInstance ); ExitThread( hInstance );
} }
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
#include "thread.h" #include "thread.h"
#include "toolhelp.h" #include "toolhelp.h"
#include "winnt.h" #include "winnt.h"
#include "winsock.h"
#include "syslevel.h" #include "syslevel.h"
#include "winsock.h"
#include "debugtools.h" #include "debugtools.h"
#include "services.h" #include "services.h"
#include "server.h" #include "server.h"
...@@ -336,9 +336,9 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline, ...@@ -336,9 +336,9 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
/* Add the task to the linked list */ /* Add the task to the linked list */
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
TASK_LinkTask( hTask ); TASK_LinkTask( hTask );
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
return TRUE; return TRUE;
} }
...@@ -384,12 +384,12 @@ void TASK_ExitTask(void) ...@@ -384,12 +384,12 @@ void TASK_ExitTask(void)
DWORD lockCount; DWORD lockCount;
/* Enter the Win16Lock to protect global data structures */ /* Enter the Win16Lock to protect global data structures */
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
pTask = (TDB *)GlobalLock16( GetCurrentTask() ); pTask = (TDB *)GlobalLock16( GetCurrentTask() );
if ( !pTask ) if ( !pTask )
{ {
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
return; return;
} }
...@@ -486,7 +486,7 @@ void TASK_Reschedule(void) ...@@ -486,7 +486,7 @@ void TASK_Reschedule(void)
enum { MODE_YIELD, MODE_SLEEP, MODE_WAKEUP } mode; enum { MODE_YIELD, MODE_SLEEP, MODE_WAKEUP } mode;
DWORD lockCount; DWORD lockCount;
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
/* Check what we need to do */ /* Check what we need to do */
hOldTask = GetCurrentTask(); hOldTask = GetCurrentTask();
...@@ -521,7 +521,7 @@ void TASK_Reschedule(void) ...@@ -521,7 +521,7 @@ void TASK_Reschedule(void)
else else
{ {
/* nothing to do */ /* nothing to do */
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
return; return;
} }
} }
...@@ -555,7 +555,7 @@ void TASK_Reschedule(void) ...@@ -555,7 +555,7 @@ void TASK_Reschedule(void)
if ( mode == MODE_YIELD && hNewTask && hNewTask == hCurrentTask ) if ( mode == MODE_YIELD && hNewTask && hNewTask == hCurrentTask )
{ {
TRACE("returning to the current task (%04x)\n", hCurrentTask ); TRACE("returning to the current task (%04x)\n", hCurrentTask );
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
/* Allow Win32 threads to thunk down even while a Win16 task is /* Allow Win32 threads to thunk down even while a Win16 task is
in a tight PeekMessage() or Yield() loop ... */ in a tight PeekMessage() or Yield() loop ... */
...@@ -600,7 +600,7 @@ void TASK_Reschedule(void) ...@@ -600,7 +600,7 @@ void TASK_Reschedule(void)
RestoreThunkLock( lockCount ); RestoreThunkLock( lockCount );
} }
SYSLEVEL_LeaveWin16Lock(); _LeaveWin16Lock();
} }
/*********************************************************************** /***********************************************************************
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "debugtools.h" #include "debugtools.h"
#include "gdi.h" #include "gdi.h"
#include "tweak.h" #include "tweak.h"
#include "syslevel.h"
DEFAULT_DEBUG_CHANNEL(gdi); DEFAULT_DEBUG_CHANNEL(gdi);
...@@ -178,7 +177,7 @@ static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] = ...@@ -178,7 +177,7 @@ static GDIOBJHDR * StockObjects[NB_STOCK_OBJECTS] =
HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */ HBITMAP hPseudoStockBitmap; /* 1x1 bitmap for memory DCs */
static SYSLEVEL GDI_level; static SYSLEVEL GDI_level = { CRITICAL_SECTION_INIT, 3 };
static WORD GDI_HeapSel; static WORD GDI_HeapSel;
...@@ -327,8 +326,6 @@ BOOL GDI_Init(void) ...@@ -327,8 +326,6 @@ BOOL GDI_Init(void)
HPALETTE16 hpalette; HPALETTE16 hpalette;
HINSTANCE16 instance; HINSTANCE16 instance;
_CreateSysLevel( &GDI_level, 3 );
/* create GDI heap */ /* create GDI heap */
if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE; if ((instance = LoadLibrary16( "GDI.EXE" )) < 32) return FALSE;
GDI_HeapSel = GlobalHandleToSel16( instance ); GDI_HeapSel = GlobalHandleToSel16( instance );
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "heap.h" #include "heap.h"
#include "task.h" #include "task.h"
#include "ldt.h" #include "ldt.h"
#include "syslevel.h"
#include "thread.h" #include "thread.h"
#include "winerror.h" #include "winerror.h"
#include "server.h" #include "server.h"
...@@ -211,9 +210,6 @@ static BOOL process_init( char *argv[] ) ...@@ -211,9 +210,6 @@ static BOOL process_init( char *argv[] )
SERVER_END_REQ; SERVER_END_REQ;
if (!ret) return FALSE; if (!ret) return FALSE;
/* Remember TEB selector of initial process for emergency use */
SYSLEVEL_EmergencyTeb = NtCurrentTeb()->teb_sel;
/* Create the system and process heaps */ /* Create the system and process heaps */
if (!HEAP_CreateSystemHeap()) return FALSE; if (!HEAP_CreateSystemHeap()) return FALSE;
current_process.heap = HeapCreate( HEAP_GROWABLE, 0, 0 ); current_process.heap = HeapCreate( HEAP_GROWABLE, 0, 0 );
...@@ -227,9 +223,6 @@ static BOOL process_init( char *argv[] ) ...@@ -227,9 +223,6 @@ static BOOL process_init( char *argv[] )
/* Initialize the critical sections */ /* Initialize the critical sections */
InitializeCriticalSection( &current_process.crit_section ); InitializeCriticalSection( &current_process.crit_section );
/* Initialize syslevel handling */
SYSLEVEL_Init();
/* Parse command line arguments */ /* Parse command line arguments */
OPTIONS_ParseOptions( argv ); OPTIONS_ParseOptions( argv );
...@@ -456,7 +449,7 @@ void PROCESS_InitWine( int argc, char *argv[] ) ...@@ -456,7 +449,7 @@ void PROCESS_InitWine( int argc, char *argv[] )
main_exe_name[0] = 0; main_exe_name[0] = 0;
CloseHandle( main_exe_file ); CloseHandle( main_exe_file );
main_exe_file = INVALID_HANDLE_VALUE; main_exe_file = INVALID_HANDLE_VALUE;
SYSLEVEL_EnterWin16Lock(); _EnterWin16Lock();
found: found:
/* allocate main thread stack */ /* allocate main thread stack */
...@@ -846,7 +839,8 @@ void WINAPI ExitProcess( DWORD status ) ...@@ -846,7 +839,8 @@ void WINAPI ExitProcess( DWORD status )
*/ */
void WINAPI ExitProcess16( WORD status ) void WINAPI ExitProcess16( WORD status )
{ {
SYSLEVEL_ReleaseWin16Lock(); DWORD count;
ReleaseThunkLock( &count );
ExitProcess( status ); ExitProcess( status );
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "file.h" /* for DOSFS_UnixTimeToFileTime */ #include "file.h" /* for DOSFS_UnixTimeToFileTime */
#include "thread.h" #include "thread.h"
#include "winerror.h" #include "winerror.h"
#include "syslevel.h"
#include "server.h" #include "server.h"
...@@ -154,12 +153,11 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, ...@@ -154,12 +153,11 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles,
*/ */
DWORD WINAPI WIN16_WaitForSingleObject( HANDLE handle, DWORD timeout ) DWORD WINAPI WIN16_WaitForSingleObject( HANDLE handle, DWORD timeout )
{ {
DWORD retval; DWORD retval, mutex_count;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
retval = WaitForSingleObject( handle, timeout ); retval = WaitForSingleObject( handle, timeout );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return retval; return retval;
} }
...@@ -169,12 +167,11 @@ DWORD WINAPI WIN16_WaitForSingleObject( HANDLE handle, DWORD timeout ) ...@@ -169,12 +167,11 @@ DWORD WINAPI WIN16_WaitForSingleObject( HANDLE handle, DWORD timeout )
DWORD WINAPI WIN16_WaitForMultipleObjects( DWORD count, const HANDLE *handles, DWORD WINAPI WIN16_WaitForMultipleObjects( DWORD count, const HANDLE *handles,
BOOL wait_all, DWORD timeout ) BOOL wait_all, DWORD timeout )
{ {
DWORD retval; DWORD retval, mutex_count;
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjects( count, handles, wait_all, timeout ); retval = WaitForMultipleObjects( count, handles, wait_all, timeout );
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return retval; return retval;
} }
...@@ -186,13 +183,11 @@ DWORD WINAPI WIN16_WaitForMultipleObjectsEx( DWORD count, ...@@ -186,13 +183,11 @@ DWORD WINAPI WIN16_WaitForMultipleObjectsEx( DWORD count,
BOOL wait_all, DWORD timeout, BOOL wait_all, DWORD timeout,
BOOL alertable ) BOOL alertable )
{ {
DWORD retval; DWORD retval, mutex_count;
SYSLEVEL_ReleaseWin16Lock();
retval = WaitForMultipleObjectsEx( count, handles,
wait_all, timeout, alertable );
SYSLEVEL_RestoreWin16Lock();
ReleaseThunkLock( &mutex_count );
retval = WaitForMultipleObjectsEx( count, handles, wait_all, timeout, alertable );
RestoreThunkLock( mutex_count );
return retval; return retval;
} }
...@@ -15,28 +15,11 @@ ...@@ -15,28 +15,11 @@
DEFAULT_DEBUG_CHANNEL(win32); DEFAULT_DEBUG_CHANNEL(win32);
static SYSLEVEL Win16Mutex; static SYSLEVEL Win16Mutex = { CRITICAL_SECTION_INIT, 1 };
static SEGPTR segpWin16Mutex;
/* Global variable to save current TEB while in 16-bit code */ /* Global variable to save current TEB while in 16-bit code */
WORD SYSLEVEL_Win16CurrentTeb = 0; WORD SYSLEVEL_Win16CurrentTeb = 0;
/* TEB of initial process for emergency use */
WORD SYSLEVEL_EmergencyTeb = 0;
/************************************************************************
* SYSLEVEL_Init
*/
void SYSLEVEL_Init(void)
{
SYSLEVEL **w16Mutex = SEGPTR_ALLOC(sizeof(SYSLEVEL *));
*w16Mutex = &Win16Mutex;
segpWin16Mutex = SEGPTR_GET(w16Mutex);
_CreateSysLevel( &Win16Mutex, 1 );
}
/************************************************************************ /************************************************************************
* GetpWin16Lock (KERNEL32.93) * GetpWin16Lock (KERNEL32.93)
...@@ -49,8 +32,15 @@ VOID WINAPI GetpWin16Lock(SYSLEVEL **lock) ...@@ -49,8 +32,15 @@ VOID WINAPI GetpWin16Lock(SYSLEVEL **lock)
/************************************************************************ /************************************************************************
* GetpWin16Lock16 (KERNEL.449) * GetpWin16Lock16 (KERNEL.449)
*/ */
SEGPTR WINAPI GetpWin16Lock16(void) SEGPTR WINAPI GetpWin16Lock16(void)
{ {
static SEGPTR segpWin16Mutex;
if (!segpWin16Mutex)
{
SYSLEVEL **w16Mutex = SEGPTR_ALLOC(sizeof(SYSLEVEL *));
*w16Mutex = &Win16Mutex;
segpWin16Mutex = SEGPTR_GET(w16Mutex);
}
return segpWin16Mutex; return segpWin16Mutex;
} }
...@@ -157,20 +147,21 @@ VOID WINAPI _CheckNotSysLevel(SYSLEVEL *lock) ...@@ -157,20 +147,21 @@ VOID WINAPI _CheckNotSysLevel(SYSLEVEL *lock)
/************************************************************************ /************************************************************************
* SYSLEVEL_EnterWin16Lock [KERNEL.480] * _EnterWin16Lock [KERNEL.480]
*/ */
VOID WINAPI SYSLEVEL_EnterWin16Lock(VOID) VOID WINAPI _EnterWin16Lock(void)
{ {
_EnterSysLevel(&Win16Mutex); _EnterSysLevel(&Win16Mutex);
} }
/************************************************************************ /************************************************************************
* SYSLEVEL_LeaveWin16Lock [KERNEL.481] * _LeaveWin16Lock [KERNEL.481]
*/ */
VOID WINAPI SYSLEVEL_LeaveWin16Lock(VOID) VOID WINAPI _LeaveWin16Lock(void)
{ {
_LeaveSysLevel(&Win16Mutex); _LeaveSysLevel(&Win16Mutex);
} }
/************************************************************************ /************************************************************************
* _ConfirmWin16Lock (KERNEL32.96) * _ConfirmWin16Lock (KERNEL32.96)
*/ */
...@@ -201,25 +192,6 @@ VOID WINAPI RestoreThunkLock(DWORD mutex_count) ...@@ -201,25 +192,6 @@ VOID WINAPI RestoreThunkLock(DWORD mutex_count)
} }
/************************************************************************ /************************************************************************
* SYSLEVEL_ReleaseWin16Lock
*/
VOID SYSLEVEL_ReleaseWin16Lock(VOID)
{
/* entry_point is never used again once the entry point has
been called. Thus we re-use it to hold the Win16Lock count */
ReleaseThunkLock(&CURRENT_STACK16->entry_point);
}
/************************************************************************
* SYSLEVEL_RestoreWin16Lock
*/
VOID SYSLEVEL_RestoreWin16Lock(VOID)
{
RestoreThunkLock(CURRENT_STACK16->entry_point);
}
/************************************************************************
* SYSLEVEL_CheckNotLevel * SYSLEVEL_CheckNotLevel
*/ */
VOID SYSLEVEL_CheckNotLevel( INT level ) VOID SYSLEVEL_CheckNotLevel( INT level )
...@@ -235,4 +207,3 @@ VOID SYSLEVEL_CheckNotLevel( INT level ) ...@@ -235,4 +207,3 @@ VOID SYSLEVEL_CheckNotLevel( INT level )
break; break;
} }
} }
...@@ -478,9 +478,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) ...@@ -478,9 +478,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
/* Enter Win16 Mutex */ /* Enter Win16 Mutex */
if ( UsePIC ) if ( UsePIC )
fprintf( outfile, "\tcall " PREFIX "SYSLEVEL_EnterWin16Lock@PLT\n" ); fprintf( outfile, "\tcall " PREFIX "_EnterWin16Lock@PLT\n" );
else else
fprintf( outfile, "\tcall " PREFIX "SYSLEVEL_EnterWin16Lock\n" ); fprintf( outfile, "\tcall " PREFIX "_EnterWin16Lock\n" );
/* Print debugging info */ /* Print debugging info */
if (debugging) if (debugging)
...@@ -574,9 +574,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func ) ...@@ -574,9 +574,9 @@ static void BuildCallTo16Core( FILE *outfile, int short_ret, int reg_func )
/* Leave Win16 Mutex */ /* Leave Win16 Mutex */
if ( UsePIC ) if ( UsePIC )
fprintf( outfile, "\tcall " PREFIX "SYSLEVEL_LeaveWin16Lock@PLT\n" ); fprintf( outfile, "\tcall " PREFIX "_LeaveWin16Lock@PLT\n" );
else else
fprintf( outfile, "\tcall " PREFIX "SYSLEVEL_LeaveWin16Lock\n" ); fprintf( outfile, "\tcall " PREFIX "_LeaveWin16Lock\n" );
/* Get return value */ /* Get return value */
fprintf( outfile, "\tpopl %%eax\n" ); fprintf( outfile, "\tpopl %%eax\n" );
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "winerror.h" #include "winerror.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/winuser16.h" #include "wine/winuser16.h"
#include "syslevel.h"
#include "module.h" #include "module.h"
#include "queue.h" #include "queue.h"
#include "task.h" #include "task.h"
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "winerror.h" #include "winerror.h"
#include "mdi.h" #include "mdi.h"
#include "local.h" #include "local.h"
#include "syslevel.h"
#include "stackframe.h" #include "stackframe.h"
#include "debugtools.h" #include "debugtools.h"
...@@ -51,16 +50,7 @@ static WORD wDragWidth = 4; ...@@ -51,16 +50,7 @@ static WORD wDragWidth = 4;
static WORD wDragHeight= 3; static WORD wDragHeight= 3;
/* thread safeness */ /* thread safeness */
static SYSLEVEL WIN_SysLevel; static SYSLEVEL WIN_SysLevel = { CRITICAL_SECTION_INIT, 2 };
/***********************************************************************
* WIN_Init
*/
void WIN_Init( void )
{
/* Initialisation of the critical section for thread safeness */
_CreateSysLevel( &WIN_SysLevel, 2 );
}
/*********************************************************************** /***********************************************************************
* WIN_LockWnds * WIN_LockWnds
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "heap.h" #include "heap.h"
#include "ldt.h" #include "ldt.h"
#include "syslevel.h"
DEFAULT_DEBUG_CHANNEL(win); DEFAULT_DEBUG_CHANNEL(win);
...@@ -36,8 +35,10 @@ BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand, ...@@ -36,8 +35,10 @@ BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
DWORD dwData ) DWORD dwData )
{ {
BOOL ret; BOOL ret;
DWORD mutex_count;
/* We might call WinExec() */ /* We might call WinExec() */
SYSLEVEL_ReleaseWin16Lock(); ReleaseThunkLock( &mutex_count );
if (!(ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) ))) if (!(ret = WinHelpA( hWnd, lpHelpFile, wCommand, (DWORD)PTR_SEG_TO_LIN(dwData) )))
{ {
...@@ -49,7 +50,7 @@ BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand, ...@@ -49,7 +50,7 @@ BOOL16 WINAPI WinHelp16( HWND16 hWnd, LPCSTR lpHelpFile, UINT16 wCommand,
} }
} }
SYSLEVEL_RestoreWin16Lock(); RestoreThunkLock( mutex_count );
return ret; return ret;
} }
......
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