Files
jsix/src/kernel/cpprt.cpp
F in Chat for Tabs 8f529046a9 [project] Lose the battle between tabs & spaces
I'm a tabs guy. I like tabs, it's an elegant way to represent
indentation instead of brute-forcing it. But I have to admit that the
world seems to be going towards spaces, and tooling tends not to play
nice with tabs. So here we go, changing the whole repo to spaces since
I'm getting tired of all the inconsistent formatting.
2021-08-01 17:46:16 -07:00

38 lines
734 B
C++

#include "kutil/assert.h"
using __exit_func = void (*)(void *);
extern "C" {
void *__dso_handle __attribute__ ((__weak__));
int __cxa_atexit(__exit_func, void *, void *);
void __cxa_pure_virtual();
}
struct __exit_func_entry
{
__exit_func func;
void *obj;
void *dso;
};
static int __num_exit_funcs = 0;
static const int __max_exit_funcs = 64;
__exit_func_entry __exit_funcs[__max_exit_funcs];
int
__cxa_atexit(__exit_func f, void *o, void *dso)
{
int i = __num_exit_funcs++;
if (i >= __max_exit_funcs) return -1;
__exit_funcs[i].func = f;
__exit_funcs[i].obj = o;
__exit_funcs[i].dso = dso;
return 0;
}
void __cxa_pure_virtual()
{
kassert(0, "Pure virtual function call");
}