aboutsummaryrefslogtreecommitdiff
path: root/include/kpl/object.h
blob: 0f54a5eb948b48425ef8b43bc6db8b1a8464adbf (plain)
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
/*
 * KPL specific objects
 */

#pragma once

// for atomic linked list queue
// size in bytes, index on the kpl_threads array
#define KPL_OBJECT_HEADER(STRUCT_NAME) \
    struct STRUCT_NAME *_Atomic queue_next; \
    int32_t obj_size, thread_id

typedef struct _kpl_object {
    KPL_OBJECT_HEADER(_kpl_object);
} kpl_object; // all kpl objects allocated by the kpl allocator extend this header

typedef struct {
    kpl_object *_Atomic head, *tail; // head is modified with atomic exchange
    struct {
        kpl_object *_Atomic queue_next;
    } dummy; // head and tail are never null will always point to this
} kpl_object_queue; // atomic linked list queue any thread can add, only owner thread can remove

typedef struct _kpl_task kpl_task;

typedef struct _kpl_env kpl_env;

typedef void kpl_task_fn(kpl_task *task, kpl_env *env);

typedef struct _kpl_task {
    KPL_OBJECT_HEADER(_kpl_task);
    // TODO
} kpl_task;