MOS Source Code
Loading...
Searching...
No Matches
cpp_support.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#include <cxxabi.h>
4#include <mos/assert.hpp>
5#include <mos/string.hpp>
6#include <mos_stdlib.hpp>
7
8void *__dso_handle = (void *) 0xcdcdcdcdcdcdcdcd; // this pointer should never get dereferenced
9
10void operator delete(void *)
11{
12 mos_panic("unused operator delete called");
13}
14
15void operator delete(void *ptr, size_t) noexcept
16{
18}
19
20extern "C" int __cxa_atexit(void (*destructor)(void *), void *arg, void *dso)
21{
22 MOS_UNUSED(destructor);
23 MOS_UNUSED(arg);
24 MOS_UNUSED(dso);
25 return 0;
26}
27
28extern "C" void abort()
29{
30 mos_panic("Aborted");
31}
32
33// static scoped variable constructor support
34
35extern "C" int abi::__cxa_guard_acquire(abi::__guard *g)
36{
37 // TODO: stub functions, implement 64-bit mutexes/futex-word
38 __atomic_thread_fence(__ATOMIC_ACQUIRE);
39 long val;
40 __atomic_load(g, &val, __ATOMIC_RELAXED);
41 return !val;
42}
43
44// this function is called when a constructor finishes
45extern "C" void abi::__cxa_guard_release(abi::__guard *g)
46{
47 long zero = 0;
48 __atomic_store(g, &zero, __ATOMIC_RELEASE);
49 __atomic_thread_fence(__ATOMIC_RELEASE);
50}
51
52// this function is called when a constructor throws an exception
53extern "C" void abi::__cxa_guard_abort(abi::__guard *)
54{
55}
void * __dso_handle
int __cxa_atexit(void(*destructor)(void *), void *arg, void *dso)
MOSAPI void do_kfree(const void *ptr)
void abort()
#define MOS_UNUSED(x)
Definition mos_global.h:65
#define mos_panic(fmt,...)
Definition panic.hpp:51
uint32_t size_t
Definition pb_syshdr.h:42
mos::shared_ptr< T > ptr