Changeset e06e2716 in mainline


Ignore:
Timestamp:
2011-05-22T19:17:56Z (14 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9ea8fdb4
Parents:
13f2461
Message:

Passing stringified LINE does not conserve space very well,
pass it as integer again.

Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/assert.c

    r13f2461 re06e2716  
    3737#include <atomic.h>
    3838#include <stacktrace.h>
     39#include <stdint.h>
    3940
    4041#define MSG_START       "Assertion failed ("
     
    4546static atomic_t failed_asserts;
    4647
    47 void assert_abort(const char *cond, const char *file, const char *line)
     48void assert_abort(const char *cond, const char *file, unsigned int line)
    4849{
     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
    4962        /*
    5063         * Send the message safely to klog. Nested asserts should not occur.
     
    5568        klog_write(file, str_size(file));
    5669        klog_write(MSG_LINE, str_size(MSG_LINE));
    57         klog_write(line, str_size(line));
     70        klog_write(pd, str_size(pd));
    5871        klog_write(MSG_END, str_size(MSG_END));
    5972
     
    6982         * assertions.
    7083         */
    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,
    7285            cond, file, line);
    7386        stacktrace_print();
  • uspace/lib/c/generic/malloc.c

    r13f2461 re06e2716  
    194194                if (!(expr)) {\
    195195                        futex_up(&malloc_futex); \
    196                         assert_abort(#expr, __FILE__, STR2(__LINE__)); \
     196                        assert_abort(#expr, __FILE__, __LINE__); \
    197197                } \
    198198        } while (0)
  • uspace/lib/c/include/assert.h

    r13f2461 re06e2716  
    4747 */
    4848
    49 #define STR(l)  #l
    50 #define STR2(l) STR(l)
    51 
    5249#ifndef NDEBUG
    5350
     
    5552        do { \
    5653                if (!(expr)) \
    57                         assert_abort(#expr, __FILE__, STR2(__LINE__)); \
     54                        assert_abort(#expr, __FILE__, __LINE__); \
    5855        } while (0)
    5956
     
    6461#endif /* NDEBUG */
    6562
    66 extern void assert_abort(const char *, const char *, const char *)
     63extern void assert_abort(const char *, const char *, unsigned int)
    6764    __attribute__((noreturn));
    6865
Note: See TracChangeset for help on using the changeset viewer.