Added wine_ldt_is_system() to replace the IS_SELECTOR_SYSTEM macro,
and stop exporting the WINE_LDT_FIRST_ENTRY constant.
diff --git a/dlls/kernel/instr.c b/dlls/kernel/instr.c
index e2a1f2f..35b0d3f 100644
--- a/dlls/kernel/instr.c
+++ b/dlls/kernel/instr.c
@@ -54,7 +54,7 @@
inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
{
if (ISV86(context)) return (void *)((seg << 4) + LOWORD(off));
- if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
+ if (wine_ldt_is_system(seg)) return (void *)off;
if (!long_addr) off = LOWORD(off);
return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
}
@@ -268,7 +268,7 @@
if (segprefix != -1) seg = segprefix;
/* Make sure the segment and offset are valid */
- if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
+ if (wine_ldt_is_system(seg)) return (BYTE *)(base + (index << ss));
if ((seg & 7) != 7) return NULL;
wine_ldt_get_entry( seg, &entry );
if (wine_ldt_is_empty( &entry )) return NULL;
@@ -716,7 +716,7 @@
break; /* Unable to emulate it */
case 0xcd: /* int <XX> */
- if (IS_SELECTOR_SYSTEM(context->SegCs)) break; /* don't emulate it in 32-bit code */
+ if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
if (!DOS_EmulateInterruptPM) init_winedos();
if (DOS_EmulateInterruptPM)
{
@@ -727,7 +727,7 @@
break; /* Unable to emulate it */
case 0xcf: /* iret */
- if (IS_SELECTOR_SYSTEM(context->SegCs)) break; /* don't emulate it in 32-bit code */
+ if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
if (long_op)
{
DWORD *stack = get_stack( context );
diff --git a/dlls/kernel/wowthunk.c b/dlls/kernel/wowthunk.c
index 9421caa..9df980f 100644
--- a/dlls/kernel/wowthunk.c
+++ b/dlls/kernel/wowthunk.c
@@ -35,6 +35,7 @@
#include "file.h"
#include "task.h"
#include "miscemu.h"
+#include "selectors.h"
#include "stackframe.h"
#include "kernel_private.h"
#include "wine/exception.h"
@@ -182,7 +183,7 @@
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
{
- if (IS_SELECTOR_SYSTEM(context->SegCs))
+ if (wine_ldt_is_system(context->SegCs))
{
if (fix_selector( context )) return ExceptionContinueExecution;
}
@@ -248,7 +249,7 @@
EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
CONTEXT *context = ptrs->ContextRecord;
- if (IS_SELECTOR_SYSTEM(context->SegCs) &&
+ if (wine_ldt_is_system(context->SegCs) &&
(record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION))
{
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index 423f656..5f15a59 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -57,7 +57,6 @@
#include "winternl.h"
#include "wine/library.h"
#include "ntdll_misc.h"
-#include "selectors.h"
/***********************************************************************
* signal context platform-specific definitions
@@ -616,8 +615,8 @@
wine_set_fs( teb->teb_sel );
/* now restore a proper %gs for the fault handler */
- if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext)) ||
- !IS_SELECTOR_SYSTEM(SS_sig(sigcontext))) /* 16-bit mode */
+ if (!wine_ldt_is_system(CS_sig(sigcontext)) ||
+ !wine_ldt_is_system(SS_sig(sigcontext))) /* 16-bit mode */
{
/*
* Win16 or DOS protected mode. Note that during switch
@@ -927,8 +926,8 @@
merge_vm86_pending_flags( rec );
}
else if (NtCurrentTeb()->dpmi_vif &&
- !IS_SELECTOR_SYSTEM(context->SegCs) &&
- !IS_SELECTOR_SYSTEM(context->SegSs))
+ !wine_ldt_is_system(context->SegCs) &&
+ !wine_ldt_is_system(context->SegSs))
{
/* Executing DPMI code and virtual interrupts are enabled. */
NtCurrentTeb()->vm86_pending = 0;
diff --git a/dlls/winedos/int31.c b/dlls/winedos/int31.c
index 0bc50f4..e2dfa96 100644
--- a/dlls/winedos/int31.c
+++ b/dlls/winedos/int31.c
@@ -29,6 +29,7 @@
#include "wownt32.h"
#include "task.h"
#include "dosexe.h"
+#include "selectors.h"
#include "excpt.h"
#include "wine/debug.h"
@@ -339,7 +340,7 @@
/* Disable virtual interrupts. */
NtCurrentTeb()->dpmi_vif = 0;
- if (IS_SELECTOR_SYSTEM( rmcb->proc_sel )) {
+ if (wine_ldt_is_system( rmcb->proc_sel )) {
/* Wine-internal RMCB, call directly */
((RMCBPROC)rmcb->proc_ofs)(context);
} else __TRY {
diff --git a/include/selectors.h b/include/selectors.h
index 5a1d5ff..9c8cd1a 100644
--- a/include/selectors.h
+++ b/include/selectors.h
@@ -28,10 +28,7 @@
extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size );
extern void SELECTOR_FreeBlock( WORD sel );
-/* Determine if sel is a system selector (i.e. not managed by Wine) */
-#define IS_SELECTOR_SYSTEM(sel) \
- (!((sel) & 4) || ((LOWORD(sel) >> 3) < WINE_LDT_FIRST_ENTRY))
#define IS_SELECTOR_32BIT(sel) \
- (IS_SELECTOR_SYSTEM(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
+ (wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
#endif /* __WINE_SELECTORS_H */
diff --git a/include/wine/library.h b/include/wine/library.h
index 7aebaf2..9967404 100644
--- a/include/wine/library.h
+++ b/include/wine/library.h
@@ -75,6 +75,7 @@
extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
+extern int wine_ldt_is_system( unsigned short sel );
extern void *wine_ldt_get_ptr( unsigned short sel, unsigned int offset );
extern unsigned short wine_ldt_alloc_entries( int count );
extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
@@ -115,8 +116,6 @@
#define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
#define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
-#define WINE_LDT_FIRST_ENTRY 512
-
/* helper functions to manipulate the LDT_ENTRY structure */
inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
{
diff --git a/libs/wine/ldt.c b/libs/wine/ldt.c
index d490d3b..f505489 100644
--- a/libs/wine/ldt.c
+++ b/libs/wine/ldt.c
@@ -124,6 +124,7 @@
static const LDT_ENTRY null_entry; /* all-zeros, used to clear LDT entries */
+#define LDT_FIRST_ENTRY 512
#define LDT_SIZE 8192
/* empty function for default locks */
@@ -182,7 +183,7 @@
{
int ret = 0, index = sel >> 3;
- if (index < WINE_LDT_FIRST_ENTRY) return 0; /* cannot modify reserved entries */
+ if (index < LDT_FIRST_ENTRY) return 0; /* cannot modify reserved entries */
#ifdef __i386__
@@ -257,6 +258,17 @@
/***********************************************************************
+ * wine_ldt_is_system
+ *
+ * Check if the selector is a system selector (i.e. not managed by Wine).
+ */
+int wine_ldt_is_system( unsigned short sel )
+{
+ return is_gdt_sel(sel) || ((sel >> 3) < LDT_FIRST_ENTRY);
+}
+
+
+/***********************************************************************
* wine_ldt_get_ptr
*
* Convert a segment:offset pair to a linear pointer.
@@ -268,7 +280,7 @@
if (is_gdt_sel(sel)) /* GDT selector */
return (void *)offset;
- if ((index = (sel >> 3)) < WINE_LDT_FIRST_ENTRY) /* system selector */
+ if ((index = (sel >> 3)) < LDT_FIRST_ENTRY) /* system selector */
return (void *)offset;
if (!(wine_ldt_copy.flags[index] & WINE_LDT_FLAGS_32BIT)) offset &= 0xffff;
return (char *)wine_ldt_copy.base[index] + offset;
@@ -287,7 +299,7 @@
if (count <= 0) return 0;
lock_ldt();
- for (i = WINE_LDT_FIRST_ENTRY; i < LDT_SIZE; i++)
+ for (i = LDT_FIRST_ENTRY; i < LDT_SIZE; i++)
{
if (wine_ldt_copy.flags[i] & WINE_LDT_FLAGS_ALLOCATED) size = 0;
else if (++size >= count) /* found a large enough block */
diff --git a/libs/wine/wine.def b/libs/wine/wine.def
index 6815955..61dac7b 100644
--- a/libs/wine/wine.def
+++ b/libs/wine/wine.def
@@ -51,6 +51,7 @@
wine_ldt_get_ptr
wine_ldt_init_fs
wine_ldt_init_locking
+ wine_ldt_is_system
wine_ldt_realloc_entries
wine_ldt_set_entry
wine_set_fs