aboutsummaryrefslogtreecommitdiffstats
path: root/code/base/base_lanes.h
blob: fef33df9ae24b3ec2e09eb2e535c62c31cab1928 (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
34
35
36
37
/* date = December 6th 2025 3:00 am */

#if !defined(LANES_H)
#define LANES_H

#include "base_arenas.h"

typedef u64 barrier;

typedef u64  thread_handle;

typedef struct thread_context thread_context;
struct thread_context
{
    s64 LaneCount;
    s64 LaneIndex;
    
    thread_handle Handle;
    
    u64 *SharedStorage;
    barrier Barrier;
    
    arena *Arena;
};

#define AtomicAddEvalU64(Pointer, Value) \
(__sync_fetch_and_add((Pointer), (Value), __ATOMIC_SEQ_CST) + (Value));

thread_static thread_context *ThreadContext;

#define LaneCount() (ThreadContext->LaneCount)
#define LaneIndex() (ThreadContext->LaneIndex)

internal void ThreadInit(thread_context *ContextToSelect);
internal arena *GetScratch(void);

#endif //LANES_H