Changeset 9d47440 in mainline for uspace/lib/c/generic/assert.c
- Timestamp:
- 2011-05-21T16:23:17Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0ff03f3
- Parents:
- 8d308b9 (diff), 13f2461 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/assert.c
r8d308b9 r9d47440 33 33 #include <assert.h> 34 34 #include <stdio.h> 35 #include <io/klog.h> 35 36 #include <stdlib.h> 37 #include <atomic.h> 36 38 #include <stacktrace.h> 37 39 38 void assert_abort(const char *cond, const char *file, unsigned int line) 40 #define MSG_START "Assertion failed (" 41 #define MSG_FILE ") in file \"" 42 #define MSG_LINE "\", line " 43 #define MSG_END ".\n" 44 45 static atomic_t failed_asserts; 46 47 void assert_abort(const char *cond, const char *file, const char *line) 39 48 { 40 printf("Assertion failed (%s) in file \"%s\", line %u.\n", 49 /* 50 * Send the message safely to klog. Nested asserts should not occur. 51 */ 52 klog_write(MSG_START, str_size(MSG_START)); 53 klog_write(cond, str_size(cond)); 54 klog_write(MSG_FILE, str_size(MSG_FILE)); 55 klog_write(file, str_size(file)); 56 klog_write(MSG_LINE, str_size(MSG_LINE)); 57 klog_write(line, str_size(line)); 58 klog_write(MSG_END, str_size(MSG_END)); 59 60 /* 61 * Check if this is a nested or parallel assert. 62 */ 63 if (atomic_postinc(&failed_asserts)) 64 abort(); 65 66 /* 67 * Attempt to print the message to standard output and display 68 * the stack trace. These operations can theoretically trigger nested 69 * assertions. 70 */ 71 printf(MSG_START "%s" MSG_FILE "%s" MSG_LINE "%s" MSG_END, 41 72 cond, file, line); 42 73 stacktrace_print(); 74 43 75 abort(); 44 76 }
Note:
See TracChangeset
for help on using the changeset viewer.