Changeset e06e2716 in mainline
- Timestamp:
- 2011-05-22T19:17:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9ea8fdb4
- Parents:
- 13f2461
- Location:
- uspace/lib/c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/assert.c
r13f2461 re06e2716 37 37 #include <atomic.h> 38 38 #include <stacktrace.h> 39 #include <stdint.h> 39 40 40 41 #define MSG_START "Assertion failed (" … … 45 46 static atomic_t failed_asserts; 46 47 47 void assert_abort(const char *cond, const char *file, const char *line)48 void assert_abort(const char *cond, const char *file, unsigned int line) 48 49 { 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 49 62 /* 50 63 * Send the message safely to klog. Nested asserts should not occur. … … 55 68 klog_write(file, str_size(file)); 56 69 klog_write(MSG_LINE, str_size(MSG_LINE)); 57 klog_write( line, str_size(line));70 klog_write(pd, str_size(pd)); 58 71 klog_write(MSG_END, str_size(MSG_END)); 59 72 … … 69 82 * assertions. 70 83 */ 71 printf(MSG_START "%s" MSG_FILE "%s" MSG_LINE "% s"MSG_END,84 printf(MSG_START "%s" MSG_FILE "%s" MSG_LINE "%" PRIu32 MSG_END, 72 85 cond, file, line); 73 86 stacktrace_print(); -
uspace/lib/c/generic/malloc.c
r13f2461 re06e2716 194 194 if (!(expr)) {\ 195 195 futex_up(&malloc_futex); \ 196 assert_abort(#expr, __FILE__, STR2(__LINE__)); \196 assert_abort(#expr, __FILE__, __LINE__); \ 197 197 } \ 198 198 } while (0) -
uspace/lib/c/include/assert.h
r13f2461 re06e2716 47 47 */ 48 48 49 #define STR(l) #l50 #define STR2(l) STR(l)51 52 49 #ifndef NDEBUG 53 50 … … 55 52 do { \ 56 53 if (!(expr)) \ 57 assert_abort(#expr, __FILE__, STR2(__LINE__)); \54 assert_abort(#expr, __FILE__, __LINE__); \ 58 55 } while (0) 59 56 … … 64 61 #endif /* NDEBUG */ 65 62 66 extern void assert_abort(const char *, const char *, const char *)63 extern void assert_abort(const char *, const char *, unsigned int) 67 64 __attribute__((noreturn)); 68 65
Note:
See TracChangeset
for help on using the changeset viewer.