ULONG->DWORD as seen on MSDN for (U)LARGE_INTEGER
[reactos.git] / reactos / include / ddk / ntdef.h
index b17afaf..cf32ad2 100644 (file)
@@ -11,7 +11,7 @@
 
 // FIXME: Should we include these here?
 #include <stdarg.h>
-#include <string.h> 
+#include <string.h>
 
 
 typedef unsigned long POINTER_64; // FIXME! HACK!!!
@@ -60,14 +60,6 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 #define CONST const
 #endif
 
-
-//
-// FIXME: Non standard, should be deprecated
-//
-#ifndef STATIC
-#define STATIC static
-#endif
-
 //
 // TRUE/FALSE
 //
@@ -93,8 +85,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 // We should use the -fms-extensions compiler flag for gcc,
 // and clean up the mess.
 //
-#ifdef __GNUC__
 #ifndef NONAMELESSUNION
+#ifdef __GNUC__
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
 #define _ANONYMOUS_UNION __extension__
 #define _ANONYMOUS_STRUCT __extension__
@@ -103,11 +95,11 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 #define _ANONYMOUS_UNION __extension__
 #endif /* __cplusplus */
 #endif /* __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) */
-#endif /* NONAMELESSUNION */
 #elif defined(__WATCOMC__) || defined(_MSC_VER)
 #define _ANONYMOUS_UNION
 #define _ANONYMOUS_STRUCT
 #endif /* __GNUC__/__WATCOMC__ */
+#endif /* NONAMELESSUNION */
 
 #ifndef _ANONYMOUS_UNION
 #define _ANONYMOUS_UNION
@@ -148,6 +140,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 
 
 // FIXME
+#undef UNALIGNED
 #define UNALIGNED
 #define RESTRICTED_POINTER
 
@@ -162,16 +155,20 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 //
 // Returns the byte offset of the specified structure's member
 //
-#ifndef FIELD_OFFSET
-#define FIELD_OFFSET(Type, Field) \
-  ((LONG_PTR) (&(((Type *) 0)->Field)))
+#ifndef __GNUC__
+#define FIELD_OFFSET(Type, Field) ((LONG)(LONG_PTR)&(((Type*) 0)->Field))
+#else
+#define FIELD_OFFSET(Type, Field) __builtin_offsetof(Type, Field)
 #endif
 
 //
 // Returns the type's alignment
 //
+#if defined(_MSC_VER) && (_MSC_VER >= 1300)
+#define TYPE_ALIGNMENT(t) __alignof(t)
+#else
 #define TYPE_ALIGNMENT(t) FIELD_OFFSET( struct { char x; t test; }, test )
-
+#endif
 
 //
 // Calling Conventions
@@ -193,14 +190,8 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 //
 // Import and Export Specifiers
 //
-#ifndef DECL_IMPORT
-#define DECL_IMPORT DECLSPEC_IMPORT //FIXME: DECL_IMPORT -> DECLSPEC_IMPORT
-#endif
-#ifndef DECL_EXPORT
-#define DECL_EXPORT DECLSPEC_EXPORT //FIXME: DECL_EXPORT -> DECLSPEC_EXPORT
-#endif
 
-// Done the same way as in windef.h (for now *cough*)
+// Done the same way as in windef.h for now
 #define DECLSPEC_IMPORT __declspec(dllimport)
 #define DECLSPEC_EXPORT __declspec(dllexport)
 #define DECLSPEC_NORETURN __declspec(noreturn)
@@ -239,6 +230,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 #endif
 #endif
 
+#ifndef DECLSPEC_NOINLINE
 #if (_MSC_VER >= 1300)
 #define DECLSPEC_NOINLINE  __declspec(noinline)
 #elif defined(__GNUC__)
@@ -246,6 +238,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 #else
 #define DECLSPEC_NOINLINE
 #endif
+#endif
 
 #if !defined(_M_CEE_PURE)
 #define NTAPI_INLINE    NTAPI
@@ -269,7 +262,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 
 
 //
-// Use to silence unused variable warnings when it is intentional 
+// Use to silence unused variable warnings when it is intentional
 //
 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
 #define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);}
@@ -304,7 +297,7 @@ typedef unsigned long POINTER_64; // FIXME! HACK!!!
 // Void Pointers
 //
 typedef void *PVOID;
-//typedef void * POINTER_64 PVOID64; 
+//typedef void * POINTER_64 PVOID64;
 typedef PVOID PVOID64; // FIXME!
 
 //
@@ -448,12 +441,12 @@ typedef struct _LARGE_INTEGER {
 typedef union _LARGE_INTEGER {
     _ANONYMOUS_STRUCT struct
     {
-        ULONG LowPart;
+        DWORD LowPart;
         LONG HighPart;
     } DUMMYSTRUCTNAME;
     struct
     {
-        ULONG LowPart;
+        DWORD LowPart;
         LONG HighPart;
     } u;
 #endif //MIDL_PASS
@@ -466,13 +459,13 @@ typedef struct _ULARGE_INTEGER {
 typedef union _ULARGE_INTEGER {
     _ANONYMOUS_STRUCT struct
     {
-        ULONG LowPart;
-        ULONG HighPart;
+        DWORD LowPart;
+        DWORD HighPart;
     } DUMMYSTRUCTNAME;
     struct
     {
-        ULONG LowPart;
-        ULONG HighPart;
+        DWORD LowPart;
+        DWORD HighPart;
     } u;
 #endif //MIDL_PASS
     ULONGLONG QuadPart;