Changeset 4bea22a in mainline


Ignore:
Timestamp:
2018-07-05T21:41:20Z (6 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
69e5838
Parents:
40340461
git-author:
Dzejrou <dzejrou@…> (2018-03-28 14:26:30)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:20)
Message:

cpp: added constructor/destructor guards for local static variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/src/internal/runtime.cpp

    r40340461 r4bea22a  
    3131#include <internal/abi.hpp>
    3232#include <exception>
     33#include <mutex>
    3334
    3435namespace __cxxabiv1
     
    119120    }
    120121
     122    using guard_t = std::uint64_t;
     123    std::mutex static_guard_mtx{};
     124
     125    extern "C" int __cxa_guard_acquire(guard_t* guard)
     126    {
     127        static_guard_mtx.lock();
     128
     129        return !*((std::uint8_t*)guard);
     130    }
     131
     132    extern "C" void __cxa_guard_release(guard_t* guard)
     133    {
     134        *((std::uint8_t*)guard) = 1;
     135
     136        static_guard_mtx.unlock();
     137    }
     138
     139    extern "C" void __cxa_guard_abort(guard_t* guard)
     140    {
     141        static_guard_mtx.unlock();
     142    }
     143
    121144    __fundamental_type_info::~__fundamental_type_info()
    122145    { /* DUMMY BODY */ }
Note: See TracChangeset for help on using the changeset viewer.