Continuing moving things out of kutil. The assert as implemented could only ever work in the kernel, so remaining kutil uses of kassert have been moved to including standard C assert instead. Along the way, kassert was broken out into panic::panic and kassert, and the panic.serial namespace was renamed panicking.
38 lines
728 B
C++
38 lines
728 B
C++
#include "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");
|
|
}
|