kernel: port sandbox components

This commit is contained in:
2023-02-03 20:51:23 +00:00
parent 40f83922da
commit 247bb2b530
14 changed files with 16 additions and 85 deletions

View File

@@ -1,6 +1,6 @@
#include <socks/queue.h>
#include <stdlib.h>
#include <assert.h>
#include <socks/compiler.h>
#include <stddef.h>
#include <socks/vm.h>
#define FREELIST_END ((unsigned int)-1)
@@ -103,7 +103,7 @@ static vm_slab_t *alloc_slab(vm_cache_t *cache, vm_flags_t flags)
return slab_hdr;
}
static void destroy_slab(vm_slab_t *slab)
static void __used destroy_slab(vm_slab_t *slab)
{
}
@@ -149,11 +149,9 @@ void *vm_cache_alloc(vm_cache_t *cache, vm_flags_t flags)
if (!queue_empty(&cache->c_slabs_partial)) {
/* prefer using up partially-full slabs before taking a fresh one */
queue_entry_t *slab_entry = queue_pop_front(&cache->c_slabs_partial);
assert(slab_entry);
slab = QUEUE_CONTAINER(vm_slab_t, s_list, slab_entry);
} else if (!queue_empty(&cache->c_slabs_empty)) {
queue_entry_t *slab_entry = queue_pop_front(&cache->c_slabs_empty);
assert(slab_entry);
slab = QUEUE_CONTAINER(vm_slab_t, s_list, slab_entry);
} else {
/* we've run out of slabs. create a new one */