summaryrefslogtreecommitdiffstats
path: root/mem/slab.h
blob: 074d278d6bbf01c37f7bb983e04ba655782fe381 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef JOVE_MEMORY_SLAB_H
#define JOVE_MEMORY_SLAB_H 1

#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>

#define SLABCACHE_NAME_LIMIT 32
struct SlabCache
{
    char name[SLABCACHE_NAME_LIMIT];

    struct SlabDescriptor *list_free;
    struct SlabDescriptor *list_partial;
    struct SlabDescriptor *list_full;

    size_t obj_size;
    size_t slab_pages;
};

struct SlabDescriptor
{
    struct SlabDescriptor *prev;
    struct SlabDescriptor *next;
    void *slab_base;
    void *obj_base;

    size_t free_count;
    int free_index;
    uintptr_t free[];
};

#endif