Synchronize with trunk revision 59636 (just before Alex's CreateProcess revamp).
[reactos.git] / include / psdk / ntdef.h
index 9d99ccb..e8eb3dd 100644 (file)
 #endif
 #endif /* DECLSPEC_ADDRSAFE */
 
+#ifndef NOP_FUNCTION
+#if (_MSC_VER >= 1210)
+#define NOP_FUNCTION __noop
+#else
+#define NOP_FUNCTION (void)0
+#endif
+#endif
+
 #if !defined(_NTSYSTEM_)
 #define NTSYSAPI     DECLSPEC_IMPORT
 #define NTSYSCALLAPI DECLSPEC_IMPORT
 #elif defined(_MSC_VER)
 #define FORCEINLINE __inline
 #else /* __GNUC__ */
-#define FORCEINLINE extern __inline__ __attribute__((always_inline))
+# if ( __MINGW_GNUC_PREREQ(4, 3)  &&  __STDC_VERSION__ >= 199901L)
+#  define FORCEINLINE extern inline __attribute__((__always_inline__,__gnu_inline__))
+# else
+#  define FORCEINLINE extern __inline__ __attribute__((__always_inline__))
+# endif
 #endif
 #endif /* FORCEINLINE */
 
 #endif
 #endif /* DECLSPEC_ALIGN */
 
+#ifndef SYSTEM_CACHE_ALIGNMENT_SIZE
+#if defined(_AMD64_) || defined(_X86_)
+#define SYSTEM_CACHE_ALIGNMENT_SIZE 64
+#else
+#define SYSTEM_CACHE_ALIGNMENT_SIZE 128
+#endif
+#endif
+
+#ifndef DECLSPEC_CACHEALIGN
+#define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(SYSTEM_CACHE_ALIGNMENT_SIZE)
+#endif
+
+#ifndef DECLSPEC_SELECTANY
+#if (_MSC_VER >= 1100) || defined(__GNUC__)
+#define DECLSPEC_SELECTANY  __declspec(selectany)
+#else
+#define DECLSPEC_SELECTANY
+#endif
+#endif
+
 /* Use to silence unused variable warnings when it is intentional */
 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
-#define UNREFERENCED_LOCAL_VARIABLE(L) {(L)=(L);}
-#define DBG_UNREFERENCED_PARAMETER(P)
-#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
+#define UNREFERENCED_LOCAL_VARIABLE(L) ((void)(L))
+#define DBG_UNREFERENCED_PARAMETER(P) {(P)=(P);}
+#define DBG_UNREFERENCED_LOCAL_VARIABLE(L) ((void)(L))
 
 /* min/max helper macros */
 #ifndef NOMINMAX
@@ -353,7 +385,7 @@ typedef ULONG *PLOGICAL;
 /* Signed Types */
 typedef SHORT *PSHORT;
 typedef LONG *PLONG;
-typedef LONG NTSTATUS;
+typedef _Return_type_success_(return >= 0) LONG NTSTATUS;
 typedef NTSTATUS *PNTSTATUS;
 typedef signed char SCHAR;
 typedef SCHAR *PSCHAR;
@@ -381,8 +413,8 @@ typedef _Null_terminated_ CONST CHAR *LPCSTR, *PCSTR;
 typedef _Null_terminated_ PCSTR *PZPCSTR;
 
 /* Pointer to an Asciiz string */
-typedef CHAR *PSZ;
-typedef CONST char *PCSZ;
+typedef _Null_terminated_ CHAR *PSZ;
+typedef _Null_terminated_ CONST char *PCSZ;
 
 /* UNICODE (Wide Character) types */
 typedef wchar_t WCHAR;
@@ -395,6 +427,7 @@ typedef _Null_terminated_ WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
 typedef _Null_terminated_ CONST WCHAR *LPCWSTR, *PCWSTR;
 typedef _Null_terminated_ PCWSTR *PZPCWSTR;
 typedef _Null_terminated_ CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
+typedef _NullNull_terminated_ WCHAR *PZZWSTR;
 
 /* Cardinal Data Types */
 typedef char CCHAR, *PCCHAR;
@@ -406,6 +439,15 @@ typedef ULONG LCID;
 typedef PULONG PLCID;
 typedef USHORT LANGID;
 
+typedef enum {
+  UNSPECIFIED_COMPARTMENT_ID = 0,
+  DEFAULT_COMPARTMENT_ID
+} COMPARTMENT_ID, *PCOMPARTMENT_ID;
+
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4201)
+#endif
 /* Used to store a non-float 8 byte aligned structure */
 typedef struct _QUAD
 {
@@ -453,6 +495,10 @@ typedef union _ULARGE_INTEGER {
     ULONGLONG QuadPart;
 } ULARGE_INTEGER, *PULARGE_INTEGER;
 
+#ifdef _MSC_VER
+#pragma warning(pop) /* disable:4201 */
+#endif
+
 /* Physical Addresses are always treated as 64-bit wide */
 typedef LARGE_INTEGER PHYSICAL_ADDRESS, *PPHYSICAL_ADDRESS;
 
@@ -489,7 +535,10 @@ typedef struct _CSTRING {
 typedef struct _STRING {
   USHORT Length;
   USHORT MaximumLength;
-  PCHAR  Buffer;
+#ifdef MIDL_PASS
+  [size_is(MaximumLength), length_is(Length) ]
+#endif
+  _Field_size_bytes_part_opt_(MaximumLength, Length) PCHAR Buffer;
 } STRING, *PSTRING;
 
 typedef STRING ANSI_STRING;
@@ -617,12 +666,14 @@ typedef struct _PROCESSOR_NUMBER {
 struct _CONTEXT;
 struct _EXCEPTION_RECORD;
 
+_IRQL_requires_same_
+_Function_class_(EXCEPTION_ROUTINE)
 typedef EXCEPTION_DISPOSITION
 (NTAPI *PEXCEPTION_ROUTINE)(
-  struct _EXCEPTION_RECORD *ExceptionRecord,
-  PVOID EstablisherFrame,
-  struct _CONTEXT *ContextRecord,
-  PVOID DispatcherContext);
+    _Inout_ struct _EXCEPTION_RECORD *ExceptionRecord,
+    _In_ PVOID EstablisherFrame,
+    _Inout_ struct _CONTEXT *ContextRecord,
+    _In_ PVOID DispatcherContext);
 
 typedef struct _GROUP_AFFINITY {
   KAFFINITY Mask;
@@ -631,6 +682,11 @@ typedef struct _GROUP_AFFINITY {
 } GROUP_AFFINITY, *PGROUP_AFFINITY;
 
 /* Helper Macros */
+
+#define RTL_FIELD_TYPE(type, field)    (((type*)0)->field)
+#define RTL_BITS_OF(sizeOfArg)         (sizeof(sizeOfArg) * 8)
+#define RTL_BITS_OF_FIELD(type, field) (RTL_BITS_OF(RTL_FIELD_TYPE(type, field)))
+
 #define RTL_CONSTANT_STRING(s) { sizeof(s)-sizeof((s)[0]), sizeof(s), s }
 
 #define RTL_FIELD_SIZE(type, field) (sizeof(((type *)0)->field))
@@ -672,6 +728,15 @@ typedef struct _GROUP_AFFINITY {
 /* C_ASSERT Definition */
 #define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
 
+/* Eliminate Microsoft C/C++ compiler warning 4715 */
+#if defined(_MSC_VER) && (_MSC_VER > 1200)
+# define DEFAULT_UNREACHABLE default: __assume(0)
+#elif defined(__clang__) || (defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))
+# define DEFAULT_UNREACHABLE default: __builtin_unreachable()
+#else
+# define DEFAULT_UNREACHABLE default: break
+#endif
+
 #define VER_WORKSTATION_NT                  0x40000000
 #define VER_SERVER_NT                       0x80000000
 #define VER_SUITE_SMALLBUSINESS             0x00000001