#define GLOBAL_REMOVE_IF_UNREFERENCED\r
#endif\r
\r
+//\r
+// Should be used in combination with NORETURN to avoid 'noreturn' returns\r
+// warnings.\r
+//\r
+#ifndef UNREACHABLE\r
+ #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)\r
+ ///\r
+ /// Signal compilers and analyzers that this call is not reachable. It is\r
+ /// up to the compiler to remove any code past that point.\r
+ /// Not implemented by GCC 4.4 or earlier.\r
+ ///\r
+ #define UNREACHABLE() __builtin_unreachable ()\r
+ #elif defined (__has_feature)\r
+ #if __has_builtin (__builtin_unreachable)\r
+ ///\r
+ /// Signal compilers and analyzers that this call is not reachable. It is\r
+ /// up to the compiler to remove any code past that point.\r
+ ///\r
+ #define UNREACHABLE() __builtin_unreachable ()\r
+ #endif\r
+ #endif\r
+\r
+ #ifndef UNREACHABLE\r
+ ///\r
+ /// Signal compilers and analyzers that this call is not reachable. It is\r
+ /// up to the compiler to remove any code past that point.\r
+ ///\r
+ #define UNREACHABLE()\r
+ #endif\r
+#endif\r
+\r
+//\r
+// Signaling compilers and analyzers that a certain function cannot return may\r
+// remove all following code and thus lead to better optimization and less\r
+// false positives.\r
+//\r
+#ifndef NORETURN\r
+ #if defined (__GNUC__) || defined (__clang__)\r
+ ///\r
+ /// Signal compilers and analyzers that the function cannot return.\r
+ /// It is up to the compiler to remove any code past a call to functions\r
+ /// flagged with this attribute.\r
+ ///\r
+ #define NORETURN __attribute__((noreturn))\r
+ #elif defined(_MSC_EXTENSIONS) && !defined(MDE_CPU_EBC)\r
+ ///\r
+ /// Signal compilers and analyzers that the function cannot return.\r
+ /// It is up to the compiler to remove any code past a call to functions\r
+ /// flagged with this attribute.\r
+ ///\r
+ #define NORETURN __declspec(noreturn)\r
+ #else\r
+ ///\r
+ /// Signal compilers and analyzers that the function cannot return.\r
+ /// It is up to the compiler to remove any code past a call to functions\r
+ /// flagged with this attribute.\r
+ ///\r
+ #define NORETURN\r
+ #endif\r
+#endif\r
+\r
+//\r
+// Should be used in combination with ANALYZER_NORETURN to avoid 'noreturn'\r
+// returns warnings.\r
+//\r
+#ifndef ANALYZER_UNREACHABLE\r
+ #ifdef __clang_analyzer__\r
+ #if __has_builtin (__builtin_unreachable)\r
+ ///\r
+ /// Signal the analyzer that this call is not reachable.\r
+ /// This excludes compilers.\r
+ ///\r
+ #define ANALYZER_UNREACHABLE() __builtin_unreachable ()\r
+ #endif\r
+ #endif\r
+\r
+ #ifndef ANALYZER_UNREACHABLE\r
+ ///\r
+ /// Signal the analyzer that this call is not reachable.\r
+ /// This excludes compilers.\r
+ ///\r
+ #define ANALYZER_UNREACHABLE()\r
+ #endif\r
+#endif\r
+\r
+//\r
+// Static Analyzers may issue errors about potential NULL-dereferences when\r
+// dereferencing a pointer, that has been checked before, outside of a\r
+// NULL-check. This may lead to false positives, such as when using ASSERT()\r
+// for verification.\r
+//\r
+#ifndef ANALYZER_NORETURN\r
+ #ifdef __has_feature\r
+ #if __has_feature (attribute_analyzer_noreturn)\r
+ ///\r
+ /// Signal analyzers that the function cannot return.\r
+ /// This excludes compilers.\r
+ ///\r
+ #define ANALYZER_NORETURN __attribute__((analyzer_noreturn))\r
+ #endif\r
+ #endif\r
+\r
+ #ifndef ANALYZER_NORETURN\r
+ ///\r
+ /// Signal the analyzer that the function cannot return.\r
+ /// This excludes compilers.\r
+ ///\r
+ #define ANALYZER_NORETURN\r
+ #endif\r
+#endif\r
+\r
//\r
// For symbol name in assembly code, an extra "_" is sometimes necessary\r
//\r
#define VA_COPY(Dest, Start) __va_copy (Dest, Start)\r
\r
#elif defined(__GNUC__) && !defined(NO_BUILTIN_VA_FUNCS)\r
+\r
+#if defined(MDE_CPU_X64) && !defined(NO_MSABI_VA_FUNCS)\r
+//\r
+// X64 only. Use MS ABI version of GCC built-in macros for variable argument lists.\r
+//\r
+///\r
+/// Both GCC and LLVM 3.8 for X64 support new variable argument intrinsics for Microsoft ABI\r
+///\r
+\r
+///\r
+/// Variable used to traverse the list of arguments. This type can vary by\r
+/// implementation and could be an array or structure.\r
+///\r
+typedef __builtin_ms_va_list VA_LIST;\r
+\r
+#define VA_START(Marker, Parameter) __builtin_ms_va_start (Marker, Parameter)\r
+\r
+#define VA_ARG(Marker, TYPE) ((sizeof (TYPE) < sizeof (UINTN)) ? (TYPE)(__builtin_va_arg (Marker, UINTN)) : (TYPE)(__builtin_va_arg (Marker, TYPE)))\r
+\r
+#define VA_END(Marker) __builtin_ms_va_end (Marker)\r
+\r
+#define VA_COPY(Dest, Start) __builtin_ms_va_copy (Dest, Start)\r
+\r
+#else\r
//\r
// Use GCC built-in macros for variable argument lists.\r
//\r
\r
#define VA_COPY(Dest, Start) __builtin_va_copy (Dest, Start)\r
\r
+#endif\r
+\r
#else\r
///\r
/// Variable used to traverse the list of arguments. This type can vary by\r
#if defined(_MSC_EXTENSIONS) && !defined (__INTEL_COMPILER) && !defined (MDE_CPU_EBC)\r
#pragma intrinsic(_ReturnAddress)\r
/**\r
- Get the return address of the calling funcation.\r
+ Get the return address of the calling function.\r
\r
Based on intrinsic function _ReturnAddress that provides the address of\r
the instruction in the calling function that will be executed after\r
\r
@param L Return Level.\r
\r
- @return The return address of the calling funcation or 0 if L != 0.\r
+ @return The return address of the calling function or 0 if L != 0.\r
\r
**/\r
#define RETURN_ADDRESS(L) ((L == 0) ? _ReturnAddress() : (VOID *) 0)\r
#elif defined(__GNUC__)\r
void * __builtin_return_address (unsigned int level);\r
/**\r
- Get the return address of the calling funcation.\r
+ Get the return address of the calling function.\r
\r
Based on built-in Function __builtin_return_address that returns\r
the return address of the current function, or of one of its callers.\r
\r
@param L Return Level.\r
\r
- @return The return address of the calling funcation.\r
+ @return The return address of the calling function.\r
\r
**/\r
#define RETURN_ADDRESS(L) __builtin_return_address (L)\r
#else\r
/**\r
- Get the return address of the calling funcation.\r
+ Get the return address of the calling function.\r
\r
@param L Return Level.\r
\r