Portability fixes.
Modified: trunk/reactos/include/ddk/mmfuncs.h
Modified: trunk/reactos/include/ddk/mmtypes.h
Modified: trunk/reactos/include/msvcrt/crttypes.h
Modified: trunk/reactos/include/msvcrt/stddef.h
Modified: trunk/reactos/include/napi/teb.h
Modified: trunk/reactos/include/ntos/mm.h
Modified: trunk/reactos/include/pseh/framebased.h
_____
Modified: trunk/reactos/include/ddk/mmfuncs.h
--- trunk/reactos/include/ddk/mmfuncs.h 2005-01-12 09:31:44 UTC (rev
12948)
+++ trunk/reactos/include/ddk/mmfuncs.h 2005-01-12 10:05:05 UTC (rev
12949)
@@ -26,21 +26,9 @@
* 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 @@
/*
* 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 @@
* 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 @@
{ \
(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); \
}
_____
Modified: trunk/reactos/include/ddk/mmtypes.h
--- trunk/reactos/include/ddk/mmtypes.h 2005-01-12 09:31:44 UTC (rev
12948)
+++ trunk/reactos/include/ddk/mmtypes.h 2005-01-12 10:05:05 UTC (rev
12949)
@@ -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)
_____
Modified: trunk/reactos/include/msvcrt/crttypes.h
--- trunk/reactos/include/msvcrt/crttypes.h 2005-01-12 09:31:44 UTC
(rev 12948)
+++ trunk/reactos/include/msvcrt/crttypes.h 2005-01-12 10:05:05 UTC
(rev 12949)
@@ -49,20 +49,6 @@
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__*/
_____
Modified: trunk/reactos/include/msvcrt/stddef.h
--- trunk/reactos/include/msvcrt/stddef.h 2005-01-12 09:31:44 UTC
(rev 12948)
+++ trunk/reactos/include/msvcrt/stddef.h 2005-01-12 10:05:05 UTC
(rev 12949)
@@ -154,7 +154,11 @@
#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
_____
Modified: trunk/reactos/include/napi/teb.h
--- trunk/reactos/include/napi/teb.h 2005-01-12 09:31:44 UTC (rev
12948)
+++ trunk/reactos/include/napi/teb.h 2005-01-12 10:05:05 UTC (rev
12949)
@@ -286,7 +286,7 @@
#define NtCurrentTeb() ((struct _TEB *)__gregister_get(13))
#else
-#error Unsupported architecture or no architecture specified.
+struct _TEB * NtCurrentTeb(void);
#endif
#endif
_____
Modified: trunk/reactos/include/ntos/mm.h
--- trunk/reactos/include/ntos/mm.h 2005-01-12 09:31:44 UTC (rev
12948)
+++ trunk/reactos/include/ntos/mm.h 2005-01-12 10:05:05 UTC (rev
12949)
@@ -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 */
_____
Modified: trunk/reactos/include/pseh/framebased.h
--- trunk/reactos/include/pseh/framebased.h 2005-01-12 09:31:44 UTC
(rev 12948)
+++ trunk/reactos/include/pseh/framebased.h 2005-01-12 10:05:05 UTC
(rev 12949)
@@ -176,11 +176,11 @@
#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;
\