Miscellaneous fixes:

- activated dependency tracking for ntdll [tested]
 - fixed trivial warning [tested]
 - build rules now define appropriate _M_<arch> macro, for compatibility with the Microsoft DDK [tested]
 - faster implementation of NtCurrentPeb() on the x86 [tested]
 - NtCurrentTeb() implementations for the Alpha AXP and MIPS R4000 architectures

svn path=/trunk/; revision=4477
This commit is contained in:
KJK::Hyperion 2003-04-02 21:55:16 +00:00
parent 323478bacf
commit 01da24f40c
5 changed files with 98 additions and 20 deletions

View file

@ -228,19 +228,72 @@ typedef struct _TEB
PVOID WineDebugInfo; // Needed for WINE DLL's PVOID WineDebugInfo; // Needed for WINE DLL's
} TEB, *PTEB; } TEB, *PTEB;
static inline PTEB NtCurrentTeb(void)
#define NtCurrentPeb() (NtCurrentTeb()->Peb)
static inline PTEB NtCurrentTeb(VOID)
{ {
int x; PTEB pTeb;
__asm__ __volatile__("movl %%fs:0x18, %0\n\t" #if defined(_M_IX86)
: "=r" (x) /* can't have two memory operands */ /* on the x86, the TEB is contained in the FS segment */
/* FIXME: instead of hardcoded offsets, use offsetof() - if possible */
/*
FIXME: GCC should allow defining a variable that directly maps to a register.
It could make for even faster code
*/
__asm__ __volatile__
(
"movl %%fs:0x18, %0\n" /* fs:18h == Teb->Tib.Self */
: "=r" (pTeb) /* can't have two memory operands */
: /* no inputs */ : /* no inputs */
); );
return((PTEB)x); return pTeb;
#elif defined(_M_ALPHA)
/* on the Alpha AXP, we call the rdteb PAL to retrieve the address of the TEB */
/* FIXME: this is probably wrong */
__asm__ __volatile__("call_pal rdteb\n");
__asm__ __volatile__
(
"mov %0, $0\n"
: "=r" (pTeb)
:
);
#elif defined(_M_MIPS)
/* on the MIPS R4000, the TEB is loaded at a fixed address (?) */
/* FIXME: again, not terribly sure about this */
__asm__ __volatile__
(
"lw %0, 0x7FFFF4A8\n"
: "=r" (pTeb)
:
);
/* #elif defined(_M_PPC) */
/* FIXME: sorry, I couldn't disassemble the PPC ntdll.dll */
#else
#error Unsupported architecture or no architecture specified.
#endif
} }
#ifdef _M_IX86
static inline PPEB NtCurrentPeb(void)
{
PPEB pPeb;
__asm__ __volatile__
(
"movl %%fs:0x30, %0\n" /* fs:30h == Teb->Peb */
: "=r" (pPeb) /* can't have two memory operands */
: /* no inputs */
);
return pPeb;
}
#else
/* generic NtCurrentPeb() */
static inline PPEB NtCurrentPeb(void) { return NtCurrentTeb()->Peb; }
#endif
#endif /* __INCLUDE_INTERNAL_TEB */ #endif /* __INCLUDE_INTERNAL_TEB */

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.78 2003/04/02 00:06:00 hyperion Exp $ # $Id: makefile,v 1.79 2003/04/02 21:55:15 hyperion Exp $
PATH_TO_TOP = ../.. PATH_TO_TOP = ../..
@ -73,10 +73,15 @@ TARGET_OBJECTS = \
ldr/utils.o \ ldr/utils.o \
$(CSR_OBJECTS) $(CSR_OBJECTS)
DEP_OBJECTS = $(TARGET_OBJECTS)
DEP_EXCLUDE_FILTER = napi.%
include $(PATH_TO_TOP)/rules.mak include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk include $(TOOLS_PATH)/helper.mk
include $(TOOLS_PATH)/depend.mk
%/TAGS: %/TAGS:
etags -o $(@D)/TAGS $(@D)/\*.c etags -o $(@D)/TAGS $(@D)/\*.c

View file

@ -1,4 +1,4 @@
/* $Id: resource.c,v 1.3 2002/09/08 10:23:06 chorns Exp $ /* $Id: resource.c,v 1.4 2003/04/02 21:55:15 hyperion Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries

View file

@ -89,11 +89,11 @@ MC = $(TOOLS_PATH)/wmc/wmc
# Maybe we can delete these soon # Maybe we can delete these soon
ifeq ($(HOST),mingw32-linux) ifeq ($(HOST),mingw32-linux)
CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe -march=i386 CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe -march=i386 -D_M_IX86
endif endif
ifeq ($(HOST),mingw32-windows) ifeq ($(HOST),mingw32-windows)
CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe -march=i386 CFLAGS := $(CFLAGS) -I$(PATH_TO_TOP)/include -pipe -march=i386 -D_M_IX86
endif endif
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)

View file

@ -1,4 +1,4 @@
# $Id: helper.mk,v 1.28 2003/04/01 08:13:30 gvg Exp $ # $Id: helper.mk,v 1.29 2003/04/02 21:55:16 hyperion Exp $
# #
# Helper makefile for ReactOS modules # Helper makefile for ReactOS modules
# Variables this makefile accepts: # Variables this makefile accepts:
@ -52,6 +52,26 @@ ifeq ($(TARGET_PATH),)
TARGET_PATH := . TARGET_PATH := .
endif endif
ifeq ($(ARCH),i386)
MK_ARCH_ID := _M_IX86
endif
ifeq ($(ARCH),alpha)
MK_ARCH_ID := _M_ALPHA
endif
ifeq ($(ARCH),mips)
MK_ARCH_ID := _M_MIPS
endif
ifeq ($(ARCH),powerpc)
MK_ARCH_ID := _M_PPC
endif
# unknown architecture
ifeq ($(MK_ARCH_ID),)
MK_ARCH_ID := _M_UNKNOWN
endif
ifeq ($(TARGET_TYPE),program) ifeq ($(TARGET_TYPE),program)
MK_MODE := user MK_MODE := user
@ -450,7 +470,7 @@ include $(PATH_TO_TOP)/config
TARGET_CFLAGS += $(MK_CFLAGS) TARGET_CFLAGS += $(MK_CFLAGS)
TARGET_CFLAGS += -pipe -march=$(ARCH) TARGET_CFLAGS += -pipe -march=$(ARCH) -D$(MK_ARCH_ID)
ifeq ($(DBG),1) ifeq ($(DBG),1)
TARGET_ASFLAGS += -g TARGET_ASFLAGS += -g
TARGET_CFLAGS += -g TARGET_CFLAGS += -g
@ -458,7 +478,7 @@ TARGET_LFLAGS += -g
endif endif
TARGET_CPPFLAGS += $(MK_CPPFLAGS) TARGET_CPPFLAGS += $(MK_CPPFLAGS)
TARGET_CPPFLAGS += -pipe -march=$(ARCH) TARGET_CPPFLAGS += -pipe -march=$(ARCH) -D$(MK_ARCH_ID)
TARGET_RCFLAGS += $(MK_RCFLAGS) TARGET_RCFLAGS += $(MK_RCFLAGS)