Changeset 1610aa35 in mainline for uspace/lib/cpp/src/exception.cpp


Ignore:
Timestamp:
2018-07-05T21:41:23Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
17c41c3
Parents:
68cfab1
git-author:
Dzejrou <dzejrou@…> (2018-05-08 16:23:51)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
Message:

cpp: added <exception>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/src/exception.cpp

    r68cfab1 r1610aa35  
    3232namespace std
    3333{
     34    const char* exception::what() const noexcept
     35    {
     36        return "std::exception";
     37    }
     38
     39    const char* bad_exception::what() const noexcept
     40    {
     41        return "std::bad_exception";
     42    }
     43
     44    namespace aux
     45    {
     46        terminate_handler term_handler{nullptr};
     47        unexpected_handler unex_handler{nullptr};
     48    }
     49
     50    terminate_handler get_terminate() noexcept
     51    {
     52        return aux::term_handler;
     53    }
     54
     55    terminate_handler set_terminate(terminate_handler h) noexcept
     56    {
     57        auto res = aux::term_handler;
     58        aux::term_handler = h;
     59
     60        return res;
     61    }
     62
    3463    [[noreturn]] void terminate() noexcept
    3564    {
     65        if (aux::term_handler)
     66            aux::term_handler();
     67
    3668        abort();
    3769    }
    3870
    39     const char* exception::what() const
     71    bool uncaught_exception() noexcept
    4072    {
    41         return "std::exception";
     73        /**
     74         * Note: The implementation of these two
     75         *       functions currently uses our mock
     76         *       exception handling system.
     77         */
     78        return aux::exception_thrown;
     79    }
     80
     81    int uncaught_exceptins() noexcept
     82    {
     83        return aux::exception_thrown ? 1 : 0;
     84    }
     85
     86    unexpected_handler get_unexpected() noexcept
     87    {
     88        return aux::unex_handler;
     89    }
     90
     91    unexpected_handler set_unexpected(unexpected_handler h) noexcept
     92    {
     93        auto res = aux::unex_handler;
     94        aux::unex_handler = h;
     95
     96        return res;
     97    }
     98
     99    [[noreturn]] void unexpected()
     100    {
     101        if (aux::unex_handler)
     102            aux::unex_handler();
     103
     104        terminate();
     105    }
     106
     107    exception_ptr current_exception() noexcept
     108    {
     109        return exception_ptr{};
     110    }
     111
     112    [[noreturn]] void rethrow_exception(exception_ptr)
     113    {
     114        terminate();
     115    }
     116
     117    [[noreturn]] void nested_exception::throw_nested() const
     118    {
     119        terminate();
     120    }
     121
     122    exception_ptr nested_exception::nested_ptr() const noexcept
     123    {
     124        return ptr_;
    42125    }
    43126}
Note: See TracChangeset for help on using the changeset viewer.