]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/Include/assert.h
Update or add comments to files and functions for use by Doxygen.
[mirror_edk2.git] / StdLib / Include / assert.h
index faa3f03294ae8225c51fdd23907d308e0b380617..26c7037ea64019752aef415ef230b3885c0affad 100644 (file)
@@ -1,5 +1,6 @@
 /** @file\r
-  Provides a definition of the assert macro.\r
+  Provides a definition of the assert macro used to insert diagnostic messages\r
+  into code.\r
 \r
   This header file defines the assert macro and refers to the NDEBUG macro,\r
   which is NOT defined in this file.\r
 \r
   If the NDEBUG macro is defined at the point where assert.h\r
   is included, the assert macro is defined so as to not produce code.\r
-  Otherwise, the assertion is tested and if the assertion is true a\r
-  diagnostic message of the form\r
-  "ASSERT <FileName>(<LineNumber>): <Description>\n" is produced.\r
-  A true assertion will also result in the application being terminated.\r
-\r
-  The behavior of the assert macro can be further modified by setting attributes\r
-  in the PcdDebugPropertyMask PCD entry when building the Application Toolkit.\r
-  If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of PcdDebugProperyMask is set\r
-  then CpuBreakpoint() is called. Otherwise, if the\r
-  DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then\r
-  CpuDeadLoop() is called.  If neither of these bits are set, then the\r
-  application will be terminated immediately after the message is printed to\r
-  the debug output device.\r
-\r
-Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  Otherwise, the assertion is tested and if the assertion is FALSE\r
+  (e.g. evaluates to 0) a diagnostic message of the form<BR>\r
+  "Assertion failed: (EXPR), file FILE, function FUNC, line LINE.\n"<BR>\r
+  is produced.\r
+  A FALSE evaluation will also result in the application being aborted.\r
 \r
+  Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials are licensed and made available under\r
+  the terms and conditions of the BSD License that accompanies this distribution.\r
+  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
 #include  <sys/EfiCdefs.h>\r
 \r
 #undef  assert        ///< Remove any existing definition for assert.\r
 \r
+/** Internal helper function for the assert macro.\r
+    The __assert function prints a diagnostic message then exits the\r
+    currently running application.\r
+\r
+    This function should NEVER be called directly.\r
+\r
+    Some pre-processors do not provide the __func__ identifier.  When that is\r
+    the case, __func__ will be NULL.  This function accounts for this and\r
+    will modify the diagnostic message appropriately.\r
+\r
+\r
+    @param[in]    file          The name of the file containing the assert.\r
+    @param[in]    func          The name of the function containing the assert.\r
+    @param[in]    line          The line number the assert is located on.\r
+    @param[in]    failedexpr    A literal representation of the assert's expression.\r
+\r
+    @return       The __assert function will never return.  It aborts the\r
+                  current application and returns to the environment that\r
+                  the application was launched from.\r
+**/\r
 extern void\r
-__assert(const char *func, const char *file, int line, const char *failedexpr);\r
+__assert(const char *file, const char *func, int line, const char *failedexpr);\r
 \r
 /** The assert macro puts diagnostic tests into programs; it expands to a\r
     void expression.\r
 \r
-    When it is executed, if expression (which shall have a scalar type) is\r
-    false (that is, compares equal to 0), the assert macro writes information\r
+    When it is executed, if expression (which must have a scalar type) is\r
+    FALSE (that is, compares equal to 0), the assert macro writes information\r
     about the particular call that failed (including the text of the argument,\r
     the name of the source file, the source line number, and the name of the\r
     enclosing function - the latter are respectively the values of the\r
     preprocessing macros __FILE__ and __LINE__ and of the identifier __func__)\r
     on the standard error stream. It then calls the abort function.\r
 \r
-  If NDEBUG is not defined, Expression is evaluated.  If Expression evaluates to FALSE, then\r
-  __assert is called passing in the source filename, source function, source line number,\r
-  and the Expression.\r
+  If NDEBUG is not defined, Expression is evaluated.  If Expression evaluates to FALSE,\r
+  then __assert is called passing in the source filename, source function, source\r
+  line number, and the Expression.\r
 \r
   @param  Expression  Boolean expression.\r
 \r
@@ -64,7 +76,7 @@ __assert(const char *func, const char *file, int line, const char *failedexpr);
 \r
 #else\r
 #define assert(Expression)   ((Expression) ? (void)0 :\\r
-                              __assert(__func__, __FILE__, __LINE__, #Expression) )\r
+                              __assert(__FILE__, __func__, __LINE__, #Expression) )\r
 #endif\r
 /// @}\r
 /* END of file assert.h */\r