kernel: add c++ support

This commit is contained in:
2023-03-20 20:41:39 +00:00
parent a4d850cc03
commit 2bfb6bcd78
41 changed files with 333 additions and 38 deletions

View File

@@ -24,10 +24,10 @@ kern_status_t object_type_register(object_type_t *p)
p->ob_cache.c_name = p->ob_name;
p->ob_cache.c_obj_size = sizeof(object_t) + p->ob_size;
p->ob_cache.c_page_order = VM_PAGE_16K;
vm_cache_init(&p->ob_cache);
p->ob_flags |= OBJTYPE_INIT;
return KERN_OK;
}
@@ -46,7 +46,7 @@ object_t *object_create(object_type_t *type)
if (!(type->ob_flags & OBJTYPE_INIT)) {
return NULL;
}
vm_cache_t *cache = &type->ob_cache;
object_t *obj = vm_cache_alloc(cache, 0);
if (!obj) {
@@ -58,7 +58,7 @@ object_t *object_create(object_type_t *type)
obj->ob_magic = OBJECT_MAGIC;
obj->ob_refcount = 1;
obj->ob_handles = 0;
return obj;
}
@@ -72,7 +72,7 @@ void object_deref(object_t *obj)
{
unsigned long flags;
spin_lock_irqsave(&obj->ob_lock, &flags);
if (obj->ob_refcount == 0) {
spin_unlock_irqrestore(&obj->ob_lock, flags);
return;
@@ -85,8 +85,8 @@ void object_deref(object_t *obj)
return;
}
if (HAS_OP(obj, delete)) {
obj->ob_type->ob_ops.delete(obj);
if (HAS_OP(obj, destroy)) {
obj->ob_type->ob_ops.destroy(obj);
}
vm_cache_free(&obj->ob_type->ob_cache, obj);
@@ -120,7 +120,7 @@ object_t *object_header(void *p)
kern_status_t object_get_child_named(object_t *obj, const char *name, object_t **out)
{
kern_status_t status = KERN_UNSUPPORTED;
if (HAS_OP(obj, get_named)) {
status = obj->ob_type->ob_ops.get_named(obj, name, out);
}
@@ -131,7 +131,7 @@ kern_status_t object_get_child_named(object_t *obj, const char *name, object_t *
kern_status_t object_get_child_at(object_t *obj, size_t at, object_t **out)
{
kern_status_t status = KERN_UNSUPPORTED;
if (HAS_OP(obj, get_at)) {
status = obj->ob_type->ob_ops.get_at(obj, at, out);
}