This commit is contained in:
2026-08-13 17:22:36 +02:00
committed by Marvin Friedrich
parent 5ee30664c5
commit 40cea4dedd
48 changed files with 622 additions and 211 deletions
+6
View File
@@ -2,6 +2,7 @@
#include <zinnia/rights.h>
#include <zinnia/status.h>
#include <kernel/alloc.h>
#include <kernel/mutex.h>
#include <kernel/namespace.h>
#include <stdatomic.h>
@@ -26,6 +27,7 @@ zn_status_t namespace_add_desc(struct namespace* namespace, struct namespace_des
return ZN_ERR_INTERNAL;
// Skip over handles that are already in use (e.g. hard-coded handles).
// mutex_lock(&namespace->mutex);
zn_handle_t handle;
do {
handle = atomic_fetch_add_explicit(&namespace->next_handle, 1, memory_order_acq_rel);
@@ -35,6 +37,8 @@ zn_status_t namespace_add_desc(struct namespace* namespace, struct namespace_des
zn_status_t status =
hashmap_insert(&namespace->descriptors, handle, desc, hashmap_hash_default, hashmap_eq_default);
// mutex_unlock(&namespace->mutex);
if (status != ZN_OK)
return status;
@@ -45,6 +49,8 @@ zn_status_t namespace_add_desc(struct namespace* namespace, struct namespace_des
zn_status_t namespace_add_desc_at(struct namespace* namespace, struct namespace_desc desc, zn_handle_t handle) {
if (!namespace)
return ZN_ERR_INTERNAL;
// Skip Invalid or reserved handles.
if (handle <= ZN_HANDLE_INVALID)
return ZN_ERR_BAD_HANDLE;