Changeset 82d56184 in mainline for uspace/lib/c/generic/assert.c


Ignore:
Timestamp:
2011-06-01T21:05:19Z (13 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5cac9cd
Parents:
682cfceb (diff), 5d1b3aa (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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

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

    r682cfceb r82d56184  
    3333#include <assert.h>
    3434#include <stdio.h>
     35#include <io/klog.h>
    3536#include <stdlib.h>
     37#include <atomic.h>
    3638#include <stacktrace.h>
     39#include <stdint.h>
     40
     41static atomic_t failed_asserts = {0};
    3742
    3843void assert_abort(const char *cond, const char *file, unsigned int line)
    3944{
     45        /*
     46         * Send the message safely to klog. Nested asserts should not occur.
     47         */
     48        klog_printf("Assertion failed (%s) in file \"%s\", line %u.\n",
     49            cond, file, line);
     50       
     51        /*
     52         * Check if this is a nested or parallel assert.
     53         */
     54        if (atomic_postinc(&failed_asserts))
     55                abort();
     56       
     57        /*
     58         * Attempt to print the message to standard output and display
     59         * the stack trace. These operations can theoretically trigger nested
     60         * assertions.
     61         */
    4062        printf("Assertion failed (%s) in file \"%s\", line %u.\n",
    4163            cond, file, line);
    4264        stacktrace_print();
     65       
    4366        abort();
    4467}
Note: See TracChangeset for help on using the changeset viewer.