minor changes based on using similar defs in the pikuma ps1 course.

This commit is contained in:
2025-09-15 08:57:53 -04:00
parent fd045fa9d9
commit ae8cd03e3d

View File

@@ -50,7 +50,7 @@ enum {
#define def_enum(underlying_type, symbol) underlying_type symbol; enum symbol
#define def_struct(symbol) struct symbol symbol; struct symbol
#define def_union(symbol) union symbol symbol; union symbol
#define fn(symbol) symbol
#define def_proc(symbol) symbol
#define opt_args(symbol, ...) &(symbol){__VA_ARGS__}
#define ret_type(type) type
#define local_persist static
@@ -70,22 +70,22 @@ enum {
#define giga(n) (cast(SSIZE, n) << 30)
#define tera(n) (cast(SSIZE, n) << 40)
#define range_iter(type, iter, m_begin, op, m_end) \
tmpl(Iter_Range,type) iter = { \
#define span_iter(type, iter, m_begin, op, m_end) \
tmpl(Iter_Span,type) iter = { \
.r = {(m_begin), (m_end)}, \
.cursor = (m_begin) }; \
iter.cursor op iter.r.end; \
++ iter.cursor
#define def_range(type) \
def_struct(tmpl( Range,type)) { type begin; type end; }; \
typedef def_struct(tmpl(Iter_Range,type)) { tmpl(Range,type) r; type cursor; }
#define def_span(type) \
def_struct(tmpl( Span,type)) { type begin; type end; }; \
typedef def_struct(tmpl(Iter_Span,type)) { tmpl(Span,type) r; type cursor; }
typedef def_range(S32);
typedef def_range(U32);
typedef def_range(SSIZE);
typedef def_span(S32);
typedef def_span(U32);
typedef def_span(SSIZE);
typedef void fn(VoidFn) (void);
typedef void def_proc(VoidFn) (void);
#pragma endregion DSL
#pragma region Debug
@@ -225,7 +225,7 @@ typedef def_enum(U64, AllocatorQueryFlags) {
};
typedef struct AllocatorProc_In AllocatorProc_In;
typedef struct AllocatorProc_Out AllocatorProc_Out;
typedef void fn(AllocatorProc) (AllocatorProc_In In, AllocatorProc_Out* Out);
typedef void def_proc(AllocatorProc) (AllocatorProc_In In, AllocatorProc_Out* Out);
typedef def_struct(AllocatorSP) {
AllocatorProc* type_sig;
SSIZE slot;
@@ -1372,7 +1372,7 @@ void kt1l__populate_slice_a2(KT1L_Byte* kt, AllocatorInfo backing, KT1L_Meta m,
if (num_values == 0) { return; }
* kt = alloc_slice(backing, Byte, m.slot_size * num_values );
slice_assert(* kt);
for (range_iter(SSIZE, iter, 0, <, num_values)) {
for (span_iter(SSIZE, iter, 0, <, num_values)) {
SSIZE slot_offset = iter.cursor * m.slot_size; // slot id
Byte* slot_cursor = & kt->ptr[slot_offset]; // slots[id] type: KT1L_<Type>
U64* slot_key = (U64*)slot_cursor; // slots[id].key type: U64