environment. There are a set of base libraries in the Mde Package that can\r
be used to implement base modules.\r
\r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
//\r
#include <ProcessorBind.h>\r
\r
+#if defined(_MSC_EXTENSIONS)\r
+//\r
+// Disable warning when last field of data structure is a zero sized array.\r
+//\r
+#pragma warning ( disable : 4200 )\r
+#endif\r
\r
/**\r
Verifies the storage size of a given data type.\r
#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
+ #ifdef __GNUC__\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
+ #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
///\r
#define RETURN_COMPROMISED_DATA ENCODE_ERROR (33)\r
\r
+///\r
+/// A HTTP error occurred during the network operation.\r
+///\r
+#define RETURN_HTTP_ERROR ENCODE_ERROR (35)\r
+\r
///\r
/// The string contained one or more characters that\r
/// the device could not render and were skipped.\r
///\r
#define RETURN_WARN_STALE_DATA ENCODE_WARNING (5)\r
\r
+///\r
+/// The resulting buffer contains UEFI-compliant file system.\r
+///\r
+#define RETURN_WARN_FILE_SYSTEM ENCODE_WARNING (6)\r
+\r
+\r
/**\r
Returns a 16-bit signature built from 2 ASCII characters.\r
\r
#define SIGNATURE_64(A, B, C, D, E, F, G, H) \\r
(SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))\r
\r
-#if defined(_MSC_EXTENSIONS)\r
- //\r
- // Intrinsic function provides the address of the instruction in the calling\r
- // function that will be executed after control returns to the caller.\r
- //\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
+\r
+ Based on intrinsic function _ReturnAddress that provides the address of\r
+ the instruction in the calling function that will be executed after\r
+ control returns to the caller.\r
+\r
+ @param L Return Level.\r
+\r
+ @return The return address of the calling funcation or 0 if L != 0.\r
+\r
+ **/\r
#define RETURN_ADDRESS(L) ((L == 0) ? _ReturnAddress() : (VOID *) 0)\r
#elif defined(__GNUC__)\r
- //\r
- // Built-in Function returns the return address of the current function,\r
- // or of one of its callers.\r
- //\r
void * __builtin_return_address (unsigned int level);\r
+ /**\r
+ Get the return address of the calling funcation.\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
+\r
+ **/\r
#define RETURN_ADDRESS(L) __builtin_return_address (L)\r
#else\r
- //\r
- // Compilers don't support this feature.\r
- //\r
+ /**\r
+ Get the return address of the calling funcation.\r
+\r
+ @param L Return Level.\r
+\r
+ @return 0 as compilers don't support this feature.\r
+\r
+ **/\r
#define RETURN_ADDRESS(L) ((VOID *) 0)\r
#endif\r
\r