]>
Commit | Line | Data |
---|---|---|
681cc25c | 1 | /** @file\r |
2 | The implementation of the __assert function used internally by the assert macro\r | |
3 | to insert diagnostic messages into code.\r | |
4 | \r | |
5 | Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r | |
2aa62f2b | 6 | This program and the accompanying materials are licensed and made available under\r |
7 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
8 | The full text of the license may be found at\r | |
681cc25c | 9 | http://opensource.org/licenses/bsd-license.\r |
2aa62f2b | 10 | \r |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | **/\r | |
2aa62f2b | 14 | #include <LibConfig.h>\r |
15 | #include <sys/EfiCdefs.h>\r | |
16 | \r | |
17 | #include <stdio.h>\r | |
18 | #include <stdlib.h>\r | |
19 | \r | |
681cc25c | 20 | /** Internal helper function for the assert macro.\r |
21 | The __assert function prints a diagnostic message then exits the\r | |
22 | currently running application.\r | |
23 | \r | |
24 | This function should NEVER be called directly.\r | |
25 | \r | |
26 | Some pre-processors do not provide the __func__ identifier. When that is\r | |
27 | the case, __func__ will be NULL. This function accounts for this and\r | |
28 | will modify the diagnostic message appropriately.\r | |
29 | \r | |
30 | \r | |
31 | @param[in] file The name of the file containing the assert.\r | |
32 | @param[in] func The name of the function containing the assert\r | |
33 | or NULL.\r | |
34 | @param[in] line The line number the assert is located on.\r | |
35 | @param[in] failedexpr A literal representation of the assert's expression.\r | |
36 | \r | |
37 | @return The __assert function will never return. It terminates execution\r | |
38 | of the current application and returns to the environment that\r | |
39 | the application was launched from.\r | |
40 | **/\r | |
2aa62f2b | 41 | void\r |
681cc25c | 42 | __assert(\r |
43 | IN const char *file,\r | |
44 | IN const char *func,\r | |
45 | IN int line,\r | |
46 | IN const char *failedexpr\r | |
47 | )\r | |
2aa62f2b | 48 | {\r |
49 | if (func == NULL)\r | |
50 | printf("Assertion failed: (%s), file %s, line %d.\n",\r | |
51 | failedexpr, file, line);\r | |
52 | else\r | |
681cc25c | 53 | printf("Assertion failed: (%s), file %s, function %s, line %d.\n",\r |
54 | failedexpr, file, func, line);\r | |
2aa62f2b | 55 | abort();\r |
56 | /* NOTREACHED */\r | |
57 | }\r |