Changeset d8de5d3 in mainline for uspace/lib/c/generic/assert.c
- Timestamp:
- 2011-05-23T13:31:54Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 540cb1b, 773f188
- Parents:
- 207533f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/assert.c
r207533f rd8de5d3 39 39 #include <stdint.h> 40 40 41 #define MSG_START "Assertion failed (" 42 #define MSG_FILE ") in file \"" 43 #define MSG_LINE "\", line " 44 #define MSG_END ".\n" 45 46 static atomic_t failed_asserts; 41 static atomic_t failed_asserts = {0}; 47 42 48 43 void assert_abort(const char *cond, const char *file, unsigned int line) 49 44 { 50 char lstr[11];51 char *pd = &lstr[10];52 uint32_t ln = (uint32_t) line;53 54 /*55 * Convert ln to a zero-terminated string.56 */57 *pd-- = 0;58 for (; ln; ln /= 10)59 *pd-- = '0' + ln % 10;60 pd++;61 62 45 /* 63 46 * Send the message safely to klog. Nested asserts should not occur. 64 47 */ 65 klog_write(MSG_START, str_size(MSG_START)); 66 klog_write(cond, str_size(cond)); 67 klog_write(MSG_FILE, str_size(MSG_FILE)); 68 klog_write(file, str_size(file)); 69 klog_write(MSG_LINE, str_size(MSG_LINE)); 70 klog_write(pd, str_size(pd)); 71 klog_write(MSG_END, str_size(MSG_END)); 72 48 klog_printf("Assertion failed (%s) in file \"%s\", line %u.\n", 49 cond, file, line); 50 73 51 /* 74 52 * Check if this is a nested or parallel assert. … … 82 60 * assertions. 83 61 */ 84 printf( MSG_START "%s" MSG_FILE "%s" MSG_LINE "%u" MSG_END,62 printf("Assertion failed (%s) in file \"%s\", line %u.\n", 85 63 cond, file, line); 86 64 stacktrace_print(); 87 65 88 66 abort(); 89 67 }
Note:
See TracChangeset
for help on using the changeset viewer.