Portability fixes.

svn path=/trunk/; revision=12949
This commit is contained in:
Filip Navara 2005-01-12 10:05:05 +00:00
parent 7fb581fc0b
commit 54b6cbb3a2
7 changed files with 26 additions and 42 deletions

View file

@ -26,21 +26,9 @@ extern POBJECT_TYPE IMPORTED MmSectionObjectType;
* Size = Size of range
* RETURNS: The number of pages
*/
#if 0
extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
ULONG Size)
{
ULONG HighestAddr;
ULONG LowestAddr;
HighestAddr = PAGE_ROUND_UP(Size + ((ULONG)Va));
LowestAddr = PAGE_ROUND_DOWN((ULONG)Va);
return((HighestAddr - LowestAddr) / PAGE_SIZE);
}
#endif
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size) \
(ULONG)((PAGE_ROUND_UP((Size) + ((ULONG)(Va))) - \
PAGE_ROUND_DOWN((ULONG)(Va))) / PAGE_SIZE)
(ULONG)((PAGE_ROUND_UP((Size) + ((ULONG_PTR)(Va))) - \
PAGE_ROUND_DOWN((ULONG_PTR)(Va))) / PAGE_SIZE)
/*
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
@ -50,7 +38,7 @@ extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
/*
* FUNCTION: Returns the byte offset of the address within its page
*/
#define BYTE_OFFSET(va) (((ULONG)va)%PAGE_SIZE)
#define BYTE_OFFSET(va) (((ULONG_PTR)va)%PAGE_SIZE)
#define PAGE_OFFSET(va) BYTE_OFFSET(va)
@ -59,10 +47,9 @@ extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
* required to hold it
*/
#define BYTES_TO_PAGES(Size) \
((ULONG) ((ULONG_PTR) (Size) >> PAGE_SHIFT) + (((ULONG) (Size) & (PAGE_SIZE - 1)) != 0))
(((Size) >> PAGE_SHIFT) + (((Size) & (PAGE_SIZE - 1)) != 0))
#define PAGE_ALIGN(va) ( (PVOID) (((ULONG)(va)) & (~(PAGE_SIZE-1))) )
#define PAGE_ALIGN(va) ( (PVOID) (((ULONG_PTR)(va)) & (~(PAGE_SIZE-1))) )
#define PAGE_BASE(va) PAGE_ALIGN(va)
NTSTATUS
@ -331,10 +318,10 @@ MmGrowKernelStack (
{ \
(MemoryDescriptorList)->Next = (PMDL)NULL; \
(MemoryDescriptorList)->Size = (CSHORT)(sizeof(MDL) + \
(ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa),(Length)) * sizeof(ULONG))); \
(ADDRESS_AND_SIZE_TO_SPAN_PAGES((BaseVa),(Length)) * sizeof(PFN_NUMBER))); \
(MemoryDescriptorList)->MdlFlags = 0; \
(MemoryDescriptorList)->StartVa = (PVOID)PAGE_BASE(BaseVa); \
(MemoryDescriptorList)->ByteOffset = (ULONG)PAGE_OFFSET(BaseVa); \
(MemoryDescriptorList)->StartVa = PAGE_ALIGN(BaseVa); \
(MemoryDescriptorList)->ByteOffset = BYTE_OFFSET(BaseVa); \
(MemoryDescriptorList)->ByteCount = (Length); \
}

View file

@ -15,7 +15,7 @@
* PURPOSE: Returns the byte offset of a field within a structure
*/
#ifndef FIELD_OFFSET
#define FIELD_OFFSET(Type,Field) ((LONG)(&(((Type *)(0))->Field)))
#define FIELD_OFFSET(Type,Field) ((ULONG_PTR)(&(((Type *)(0))->Field)))
#endif
/*
@ -27,9 +27,16 @@
* Field = Name of the field whose address is none
*/
#ifndef CONTAINING_RECORD
#define CONTAINING_RECORD(Address,Type,Field) ((Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field)))
#define CONTAINING_RECORD(Address,Type,Field) ((Type *)(((ULONG_PTR)Address) - FIELD_OFFSET(Type,Field)))
#endif
#ifdef _M_IX86
typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
#elif _M_IA64
typedef ULONG64 PFN_NUMBER, *PPFN_NUMBER;
#else
#error Unknown architecture
#endif
#define MDL_MAPPED_TO_SYSTEM_VA (0x1)
#define MDL_PAGES_LOCKED (0x2)

View file

@ -49,20 +49,6 @@ struct _ETHREAD { int foobar; };
struct _EPROCESS { int foobar; };
#endif
#ifndef _DEBUG
#pragma function(_disable,_enable)
#pragma function(_inp,_inpw,_outp,_outpw)
#pragma function(_lrotl,_lrotr,_rotl,_rotr)
#pragma function(abs,fabs,labs)
#pragma function(memcpy,memcmp,memset)
#pragma function(strcat,strcmp,strcpy,strlen,_strset)
#pragma function(fmod,sqrt)
#pragma function(log,log10,pow,exp)
#pragma function(tan,atan,atan2,tanh)
#pragma function(cos,acos,cosh)
#pragma function(sin,asin,sinh)
#endif
#endif /*__GNUC__*/

View file

@ -154,7 +154,11 @@ typedef __WINT_TYPE__ wint_t;
#if defined (__MSVCRT_STDDEF_H_) || defined (__need_NULL)
#undef NULL
#ifdef __cplusplus
#define NULL (0)
#else
#define NULL ((void *)0)
#endif
#endif /* __MSVCRT_STDDEF_H_ or __need_NULL */
#undef __need_NULL

View file

@ -286,7 +286,7 @@ unsigned __gregister_get(unsigned const regnum);
#define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
#else
#error Unsupported architecture or no architecture specified.
struct _TEB * NtCurrentTeb(void);
#endif
#endif

View file

@ -62,7 +62,7 @@
#endif /* __USE_W32API */
#define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
#define PAGE_ROUND_DOWN(x) (((ULONG_PTR)x)&(~(PAGE_SIZE-1)))
#endif /* __INCLUDE_MM_H */

View file

@ -176,11 +176,11 @@ static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler
#define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \
{ \
_SEH_DECLARE_HANDLERS(FILTER_, FINALLY_); \
\
_SEHFrame_t * _SEHFrame; \
volatile _SEHPortableFrame_t * _SEHPortableFrame; \
\
_SEH_DECLARE_HANDLERS(FILTER_, FINALLY_); \
\
_SEHFrame = _alloca(sizeof(_SEHFrame_t)); \
_SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers; \
_SEHFrame->SEH_Locals = &_SEHLocals; \