From 13b942efb20efe1dff01b044249e68aece2d186b Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 12 Nov 2025 14:12:09 -0600 Subject: [PATCH] doubly-linked-stack helper macros --- src/base/base.h | 146 +++++++++++++++++-------- src/base/base_resource.c | 4 +- src/base/base_win32/base_win32_job.c | 12 +- src/gpu/gpu_common.c | 6 +- src/gpu/gpu_dx12/gpu_dx12.c | 22 ++-- src/meta/meta.c | 6 +- src/meta/meta_lay.c | 20 ++-- src/proto/pp_game.c | 10 +- src/proto/pp_widgets.c | 2 +- src/sprite/sprite.c | 6 +- src/ui/ui_core.c | 18 +-- src/window/window_win32/window_win32.c | 2 +- 12 files changed, 155 insertions(+), 99 deletions(-) diff --git a/src/base/base.h b/src/base/base.h index 31154b11..969563b8 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -292,61 +292,117 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #define CheckNil(nil,p) ((p) == 0 || (p) == nil) #define SetNil(nil,p) ((p) = nil) -//- Singly linked list stack (first & next pointers) +//- Singly linked stack (first & next pointers) -#define StackPushN(f,n,next) ((n)->next=(f), (f)=(n)) -#define StackPopN(f,next) ((f)=(f)->next) -#define StackPush(f,n) StackPushN(f,n,next) -#define StackPop(f) StackPopN(f,next) +#define SllStackPushN(f,n,next) ((n)->next=(f), (f)=(n)) +#define SllStackPopN(f,next) ((f)=(f)->next) +#define SllStackPush(f,n) SllStackPushN(f,n,next) +#define SllStackPop(f) SllStackPopN(f,next) -//- Singly linked list queue (first, last, & next pointers) +//- Singly linked queue (first, last, & next pointers) -#define QueuePushNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \ - ((f)=(l)=(n),SetNil(nil,(n)->next)) : \ - ((l)->next=(n),(l)=(n),SetNil(nil,(n)->next))) +#define SllQueuePushNZ(nil,f,l,n,next) \ +( \ + CheckNil(nil,f) ? \ + ((f)=(l)=(n),SetNil(nil,(n)->next)) : \ + ((l)->next=(n),(l)=(n),SetNil(nil,(n)->next)) \ +) -#define QueuePushFrontNZ(nil,f,l,n,next) (CheckNil(nil,f) ? \ - ((f)=(l)=(n),SetNil(nil,(n)->next)) : \ - ((n)->next=(f),(f)=(n))) +#define SllQueuePushFrontNZ(nil,f,l,n,next) \ +( \ + CheckNil(nil,f) ? \ + ((f)=(l)=(n),SetNil(nil,(n)->next)) : \ + ((n)->next=(f),(f)=(n)) \ +) -#define QueuePopNZ(nil,f,l,next) ((f)==(l) ? \ - (SetNil(nil,f),SetNil(nil,l)) : \ - ((f)=(f)->next)) +#define SllQueuePopNZ(nil,f,l,next) \ +( \ + (f)==(l) ? \ + (SetNil(nil,f),SetNil(nil,l)) : \ + ((f)=(f)->next) \ +) -#define QueuePushN(f,l,n,next) QueuePushNZ(0,f,l,n,next) -#define QueuePushFrontN(f,l,n,next) QueuePushFrontNZ(0,f,l,n,next) -#define QueuePopN(f,l,next) QueuePopNZ(0,f,l,next) -#define QueuePush(f,l,n) QueuePushNZ(0,f,l,n,next) -#define QueuePushFront(f,l,n) QueuePushFrontNZ(0,f,l,n,next) -#define QueuePop(f,l) QueuePopNZ(0,f,l,next) +#define SllQueuePushN(f,l,n,next) SllQueuePushNZ(0,f,l,n,next) +#define SllQueuePush(f,l,n) SllQueuePushNZ(0,f,l,n,next) +#define SllQueuePushFrontN(f,l,n,next) SllQueuePushFrontNZ(0,f,l,n,next) +#define SllQueuePushFront(f,l,n) SllQueuePushFrontNZ(0,f,l,n,next) +#define SllQueuePopN(f,l,next) SllQueuePopNZ(0,f,l,next) +#define SllQueuePop(f,l) SllQueuePopNZ(0,f,l,next) -//- Doubly linked list (first, last, next, & prev pointers) +//- Doubly linked stack (first, next, & prev pointers) -#define DllInsertNPZ(nil,f,l,p,n,next,prev) (CheckNil(nil,f) ? \ - ((f) = (l) = (n), SetNil(nil,(n)->next), SetNil(nil,(n)->prev)) : \ - CheckNil(nil,p) ? \ - ((n)->next = (f), (f)->prev = (n), (f) = (n), SetNil(nil,(n)->prev)) : \ - ((p)==(l)) ? \ - ((l)->next = (n), (n)->prev = (l), (l) = (n), SetNil(nil, (n)->next)) : \ - (((!CheckNil(nil,p) && CheckNil(nil,(p)->next)) ? (0) : ((p)->next->prev = (n))), ((n)->next = (p)->next), ((p)->next = (n)), ((n)->prev = (p)))) +#define DllStackPushNPZ(nil,f,n,next,prev) \ +( \ + SetNil(nil,(n)->prev), \ + ((n)->next = (f)), \ + CheckNil(nil,f) ? (0) : ((f)->prev = (n)), \ + ((f) = (n)) \ +) -#define DllRemoveNPZ(nil,f,l,n,next,prev) (((n) == (f) ? (f) = (n)->next : (0)), \ - ((n) == (l) ? (l) = (l)->prev : (0)), \ - (CheckNil(nil,(n)->prev) ? (0) : \ - ((n)->prev->next = (n)->next)), \ - (CheckNil(nil,(n)->next) ? (0) : \ - ((n)->next->prev = (n)->prev))) +#define DllStackInsertNPZ(nil,f,p,n,next,prev) \ +( \ + (CheckNil(nil,f) || CheckNil(nil,p)) ? (DllStackPushNPZ(nil,(f),(n),next,prev)) : \ + ( \ + ((n)->prev = (p)), \ + ((n)->next = (p)->next), \ + ((p)->next = (n)), \ + CheckNil(nil,(p)->next) ? (0) : ((p)->next->prev = (n)) \ + ) \ +) -#define DllPushBackNPZ(nil,f,l,n,next,prev) DllInsertNPZ(nil,f,l,l,n,next,prev) -#define DllPushFrontNPZ(nil,f,l,n,next,prev) DllInsertNPZ(nil,l,f,f,n,prev,next) -#define DllInsertNP(f,l,p,n,next,prev) DllInsertNPZ(0,f,l,p,n,next,prev) -#define DllPushBackNP(f,l,n,next,prev) DllPushBackNPZ(0,f,l,n,next,prev) -#define DllPushFrontNP(f,l,n,next,prev) DllPushFrontNPZ(0,f,l,n,next,prev) -#define DllRemoveNP(f,l,n,next,prev) DllRemoveNPZ(0,f,l,n,next,prev) -#define DllInsert(f,l,p,n) DllInsertNPZ(0,f,l,p,n,next,prev) -#define DllPushBack(f,l,n) DllPushBackNPZ(0,f,l,n,next,prev) -#define DllPushFront(f,l,n) DllPushFrontNPZ(0,f,l,n,next,prev) -#define DllRemove(f,l,n) DllRemoveNPZ(0,f,l,n,next,prev) +#define DllStackRemoveNPZ(nil,f,n,next,prev) \ +( \ + ((n) == (f) ? ((f) = (n)->next) : (0)), \ + (CheckNil(nil,(n)->next) ? (0) : ((n)->next->prev = (n)->prev)), \ + (CheckNil(nil,(n)->prev) ? (0) : ((n)->prev->next = (n)->next)) \ +) + +#define DllStackPushNP(f,n,next,prev) DllStackPushNPZ(0,f,n,next,prev) +#define DllStackPush(f,n) DllStackPushNPZ(0,f,n,next,prev) +#define DllStackInsertNP(f,p,n,next,prev) DllStackInsertNPZ(0,f,p,n,next,prev) +#define DllStackInsert(f,p,n) DllStackInsertNPZ(0,f,p,n,next,prev) +#define DllStackRemoveNP(f,n,next,prev) DllStackRemoveNPZ(0,f,n,next,prev) +#define DllStackRemove(f,n) DllStackRemoveNPZ(0,f,n,next,prev) + +//- Doubly linked queue (first, last, next, & prev pointers) + +#define DllQueueInsertNPZ(nil,f,l,p,n,next,prev) \ +( \ + CheckNil(nil,f) ? \ + ((f) = (l) = (n), SetNil(nil,(n)->next), SetNil(nil,(n)->prev)) : \ + CheckNil(nil,p) ? \ + ((n)->next = (f), (f)->prev = (n), (f) = (n), SetNil(nil,(n)->prev)) : \ + ((p)==(l)) ? \ + ((l)->next = (n), (n)->prev = (l), (l) = (n), SetNil(nil, (n)->next)) : \ + (((!CheckNil(nil,p) && CheckNil(nil,(p)->next)) ? (0) : \ + ( \ + (p)->next->prev = (n))), \ + ((n)->next = (p)->next), \ + ((p)->next = (n)), \ + ((n)->prev = (p)) \ + ) \ +) + +#define DllQueueRemoveNPZ(nil,f,l,n,next,prev) \ +( \ + ((n) == (f) ? (f) = (n)->next : (0)), \ + ((n) == (l) ? (l) = (l)->prev : (0)), \ + (CheckNil(nil,(n)->prev) ? (0) : \ + ((n)->prev->next = (n)->next)), \ + (CheckNil(nil,(n)->next) ? (0) : \ + ((n)->next->prev = (n)->prev)) \ +) + +#define DllQueuePushNPZ(nil,f,l,n,next,prev) DllQueueInsertNPZ(nil,f,l,l,n,next,prev) +#define DllQueuePushNP(f,l,n,next,prev) DllQueuePushNPZ(0,f,l,n,next,prev) +#define DllQueuePush(f,l,n) DllQueuePushNPZ(0,f,l,n,next,prev) +#define DllQueuePushFrontNPZ(nil,f,l,n,next,prev) DllQueueInsertNPZ(nil,l,f,f,n,prev,next) +#define DllQueuePushFrontNP(f,l,n,next,prev) DllQueuePushFrontNPZ(0,f,l,n,next,prev) +#define DllQueuePushFront(f,l,n) DllQueuePushFrontNPZ(0,f,l,n,next,prev) +#define DllQueueInsertNP(f,l,p,n,next,prev) DllQueueInsertNPZ(0,f,l,p,n,next,prev) +#define DllQueueInsert(f,l,p,n) DllQueueInsertNPZ(0,f,l,p,n,next,prev) +#define DllQueueRemoveNP(f,l,n,next,prev) DllQueueRemoveNPZ(0,f,l,n,next,prev) +#define DllQueueRemove(f,l,n) DllQueueRemoveNPZ(0,f,l,n,next,prev) //////////////////////////////////////////////////////////// //~ Bit helper macros diff --git a/src/base/base_resource.c b/src/base/base_resource.c index d1448165..760b0370 100644 --- a/src/base/base_resource.c +++ b/src/base/base_resource.c @@ -33,8 +33,8 @@ void InitResourceSystem(u64 archive_strings_count, String *archive_strings) entry->hash = HashFnv64(Fnv64Basis, entry->name); ResourceEntryBin *bin = &g->bins[entry->hash % NumResourceEntryBins]; - QueuePushN(bin->first, bin->last, entry, next_in_bin); - QueuePushN(g->first_entry, g->last_entry, entry, next); + SllQueuePushN(bin->first, bin->last, entry, next_in_bin); + SllQueuePushN(g->first_entry, g->last_entry, entry, next); } g->entries_count += num_entries; } diff --git a/src/base/base_win32/base_win32_job.c b/src/base/base_win32/base_win32_job.c index fcf8ba39..8e00afd9 100644 --- a/src/base/base_win32/base_win32_job.c +++ b/src/base/base_win32/base_win32_job.c @@ -295,7 +295,7 @@ void W32_FiberEntryPoint(void *_) /* Free job */ LockTicketMutex(&pool->free_jobs_tm); { - StackPush(pool->first_free_job, job); + SllStackPush(pool->first_free_job, job); } UnlockTicketMutex(&pool->free_jobs_tm); } @@ -304,7 +304,7 @@ void W32_FiberEntryPoint(void *_) { LockTicketMutex(&pool->free_tasks_tm); { - StackPush(pool->first_free_task, task); + SllStackPush(pool->first_free_task, task); } UnlockTicketMutex(&pool->free_tasks_tm); } @@ -396,7 +396,7 @@ W32_ThreadDef(W32_JobWorkerEntryPoint, worker_ctx_arg) task = pool->first_task; if (task) { - QueuePop(pool->first_task, pool->last_task); + SllQueuePop(pool->first_task, pool->last_task); Atomic64FetchAdd(&pool->tasks_count.v, -1); } } @@ -510,7 +510,7 @@ void ResumeFibers(i16 fiber_ids_count, i16 *fiber_ids) /* Group task based on pool */ JobPoolId pool_id = fiber->pool; W32_TaskList *pool_tasks = &tasks_by_pool[pool_id]; - QueuePush(pool_tasks->first, pool_tasks->last, task); + SllQueuePush(pool_tasks->first, pool_tasks->last, task); ++pool_tasks->count; } } @@ -666,7 +666,7 @@ u32 CloseJob(Job *job) if (task) { tasks_array[num_tasks_allocated++] = task; - StackPop(pool->first_free_task); + SllStackPop(pool->first_free_task); } else { @@ -702,7 +702,7 @@ u32 CloseJob(Job *job) ZeroStruct(task); task->job = job; task->task_id = tasks.count++; - QueuePush(tasks.first, tasks.last, task); + SllQueuePush(tasks.first, tasks.last, task); } /* Push tasks to back of pool */ diff --git a/src/gpu/gpu_common.c b/src/gpu/gpu_common.c index e75e54b7..0b672de9 100644 --- a/src/gpu/gpu_common.c +++ b/src/gpu/gpu_common.c @@ -160,7 +160,7 @@ GPU_Resource *GPU_UploadTransientBuffer(GPU_TransientBuffer *tbuff, void *src, u if (tbuff->first_submitted && tbuff->first_submitted->fence_target <= queue_fence_value) { upload = tbuff->first_submitted; - QueuePop(tbuff->first_submitted, tbuff->last_submitted); + SllQueuePop(tbuff->first_submitted, tbuff->last_submitted); } if (!upload) { @@ -170,7 +170,7 @@ GPU_Resource *GPU_UploadTransientBuffer(GPU_TransientBuffer *tbuff, void *src, u if (upload) { g->first_free_submitted_transient_buffer = upload->next; - StackPop(g->first_free_submitted_transient_buffer); + SllStackPop(g->first_free_submitted_transient_buffer); } } Unlock(&lock); @@ -223,7 +223,7 @@ void GPU_ResetTransientBuffer(GPU_TransientBuffer *tbuff, i64 queue_fence_target if (uploaded) { uploaded->fence_target = queue_fence_target; - QueuePush(tbuff->first_submitted, tbuff->last_submitted, uploaded); + SllQueuePush(tbuff->first_submitted, tbuff->last_submitted, uploaded); tbuff->uploaded = 0; } } diff --git a/src/gpu/gpu_dx12/gpu_dx12.c b/src/gpu/gpu_dx12/gpu_dx12.c index 07d9dcde..e9e8965e 100644 --- a/src/gpu/gpu_dx12/gpu_dx12.c +++ b/src/gpu/gpu_dx12/gpu_dx12.c @@ -34,7 +34,7 @@ GPU_D12_Command *GPU_D12_PushCmd(GPU_D12_CommandList *cl) cmd = PushStructNoZero(perm, GPU_D12_Command); } ZeroStruct(cmd); - QueuePush(cl->first, cl->last, cmd); + SllQueuePush(cl->first, cl->last, cmd); ++cl->count; return cmd; } @@ -528,7 +528,7 @@ GPU_D12_Pipeline *GPU_D12_PipelineFromDesc(GPU_D12_PipelineDesc desc) pipeline->hash = hash; is_pipeline_new = 1; PushAlign(perm, CachelineSize); - StackPushN(bin->first, pipeline, next_in_bin); + SllStackPushN(bin->first, pipeline, next_in_bin); } Unlock(&lock); } @@ -618,7 +618,7 @@ GPU_D12_RawCommandList *GPU_D12_BeginRawCommandList(GPU_QueueKind queue_kind) cl = queue->first_submitted_cl; if (cl && cl->submit_fence_target <= completed) { - QueuePop(queue->first_submitted_cl, queue->last_submitted_cl); + SllQueuePop(queue->first_submitted_cl, queue->last_submitted_cl); } else { @@ -703,7 +703,7 @@ u64 GPU_D12_EndRawCommandList(GPU_D12_RawCommandList *cl) ID3D12CommandQueue_ExecuteCommandLists(queue->d3d_queue, 1, (ID3D12CommandList **)&cl->cl); ID3D12CommandQueue_Signal(queue->d3d_queue, queue->submit_fence, target); /* Append */ - QueuePush(queue->first_submitted_cl, queue->last_submitted_cl, cl); + SllQueuePush(queue->first_submitted_cl, queue->last_submitted_cl, cl); } Unlock(&lock); } @@ -831,8 +831,8 @@ GPU_Resource *GPU_AcquireResource(GPU_ResourceDesc desc) list->first = r->next_free; if (!list->first) { - DllRemove(bin->first, bin->last, list); - StackPush(bin->first_free, list); + DllQueueRemove(bin->first, bin->last, list); + SllStackPush(bin->first_free, list); list->prev = 0; } r->next_free = 0; @@ -1097,9 +1097,9 @@ void GPU_ReleaseResource(GPU_Resource *gpu_resource, GPU_ReleaseFlag flags) PushAlign(perm, CachelineSize); } list->hash = reuse_hash; - DllPushBack(bin->first, bin->last, list); + DllQueuePush(bin->first, bin->last, list); } - StackPushN(list->first, r, next_free); + SllStackPushN(list->first, r, next_free); } Unlock(&lock); } @@ -1180,7 +1180,7 @@ GPU_CommandList *GPU_BeginCommandList(GPU_QueueKind queue_kind) GPU_D12_CommandList *cl = f->first_free_command_list; if (cl) { - StackPop(f->first_free_command_list); + SllStackPop(f->first_free_command_list); ZeroStruct(cl); } else @@ -1319,7 +1319,7 @@ i64 GPU_EndCommandList(GPU_CommandList *gpu_cl) TmpBarrier *b = PushStruct(scratch.arena, TmpBarrier); resource->barrier_gen = barrier_gen; b->r = resource; - QueuePush(first_barrier, last_barrier, b); + SllQueuePush(first_barrier, last_barrier, b); ++max_barriers_count; } } @@ -1658,7 +1658,7 @@ i64 GPU_EndCommandList(GPU_CommandList *gpu_cl) } /* Free command list */ - StackPush(f->first_free_command_list, cl); + SllStackPush(f->first_free_command_list, cl); EndScratch(scratch); return fence_target; diff --git a/src/meta/meta.c b/src/meta/meta.c index f1742001..5b1da4f9 100644 --- a/src/meta/meta.c +++ b/src/meta/meta.c @@ -490,7 +490,7 @@ JobDef(Step, sig, id) ShaderEntry *e = PushStruct(arena, ShaderEntry); e->kind = shader_kind; e->name = shader_name; - QueuePush(first_shader_entry, last_shader_entry, e); + SllQueuePush(first_shader_entry, last_shader_entry, e); ++shader_entries_count; } else @@ -636,7 +636,7 @@ JobDef(Step, sig, id) EmbeddedDir *ed = PushStruct(arena, EmbeddedDir); ed->store_name = store_name; ed->dir_name = full; - QueuePush(first_dir_embed, last_dir_embed, ed); + SllQueuePush(first_dir_embed, last_dir_embed, ed); ++dir_embeds_count; } else @@ -725,7 +725,7 @@ JobDef(Step, sig, id) EntryNode *en = PushStruct(arena, EntryNode); en->entry_name = entry_name; en->file_name = file_name; - QueuePush(first_entry, last_entry, en); + SllQueuePush(first_entry, last_entry, en); ++entries_count; } } diff --git a/src/meta/meta_lay.c b/src/meta/meta_lay.c index e1bbc945..86735dad 100644 --- a/src/meta/meta_lay.c +++ b/src/meta/meta_lay.c @@ -32,7 +32,7 @@ M_Error *M_PushError(Arena *arena, M_ErrorList *l, M_Token *token, String msg) M_Error *e = PushStruct(arena, M_Error); e->msg = msg; e->token = token ? token : &M_NilToken; - QueuePush(l->first, l->last, e); + SllQueuePush(l->first, l->last, e); ++l->count; return e; } @@ -56,7 +56,7 @@ M_TokenFile *M_PushTokenFile(Arena *arena, M_TokenFileList *l, String name, Stri tf->name = name; tf->data = data; M_PushToken(arena, tf, Lit(""), M_TokenKind_Eol); - QueuePushNZ(&M_NilTokenFile, l->first, l->last, tf, next); + SllQueuePushNZ(&M_NilTokenFile, l->first, l->last, tf, next); ++l->count; return tf; } @@ -72,7 +72,7 @@ M_Token *M_PushToken(Arena *arena, M_TokenFile *file, String s, M_TokenKind kind { t->file = file; } - QueuePushNZ(&M_NilToken, file->first_token, file->last_token, t, next); + SllQueuePushNZ(&M_NilToken, file->first_token, file->last_token, t, next); ++file->tokens_count; return t; } @@ -208,7 +208,7 @@ M_Layer *M_PushLayer(Arena *arena, M_LayerList *list, M_TokenFile *file) *layer = M_NilLayer; layer->valid = 1; layer->file = file; - QueuePushNZ(&M_NilLayer, list->first, list->last, layer, next); + SllQueuePushNZ(&M_NilLayer, list->first, list->last, layer, next); ++list->count; return layer; } @@ -225,7 +225,7 @@ M_Entry *M_PushEntry(Arena *arena, M_Layer *l, M_EntryKind kind, M_Token *entry_ e->arg_tokens[i] = args[i]; } e->args_count = args_count; - QueuePushNZ(&M_NilEntry, l->first, l->last, e, next); + SllQueuePushNZ(&M_NilEntry, l->first, l->last, e, next); ++l->count; return e; } @@ -425,7 +425,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList { StackNode *n = PushStruct(scratch.arena, StackNode); n->state = state; - StackPush(stack, n); + SllStackPush(stack, n); } else { @@ -438,7 +438,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList while (stack) { StackNode *stack_node = stack; - StackPop(stack); + SllStackPop(stack); IterState *state = stack_node->state; M_Layer *layer = state->layer; @@ -483,7 +483,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList { StackNode *n = PushStruct(scratch.arena, StackNode); n->state = impl_layer_state; - StackPush(stack, n); + SllStackPush(stack, n); } } else @@ -502,7 +502,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList /* Push node exit to stack */ { stack_node->exit = 1; - StackPush(stack, stack_node); + SllStackPush(stack, stack_node); } /* Push upstream dep enters to stack */ @@ -523,7 +523,7 @@ M_Layer M_GetFlattenedEntries(Arena *arena, M_LayerList unflattened, StringList { StackNode *n = PushStruct(scratch.arena, StackNode); n->state = dep_layer_state; - StackPush(stack, n); + SllStackPush(stack, n); } } else diff --git a/src/proto/pp_game.c b/src/proto/pp_game.c index a85222fa..e23b8166 100644 --- a/src/proto/pp_game.c +++ b/src/proto/pp_game.c @@ -154,7 +154,7 @@ JobDef(PP_VisWorker, sig, job_id) shortcut->hotkey_hash = hotkey_hash; shortcut->hotkey = hotkey; shortcut->cmd_name = desc.name; - DllPushBackNP(bin->first, bin->last, shortcut, next_in_bin, prev_in_bin); + DllQueuePushNP(bin->first, bin->last, shortcut, next_in_bin, prev_in_bin); } } } @@ -252,7 +252,7 @@ JobDef(PP_VisWorker, sig, job_id) { PP_VisCmdNode *cmd_node = PushStruct(frame_arena, PP_VisCmdNode); cmd_node->cmd.name = shortcut->cmd_name; - QueuePush(first_cmd_node, last_cmd_node, cmd_node); + SllQueuePush(first_cmd_node, last_cmd_node, cmd_node); ++cmds_count; } } @@ -280,7 +280,7 @@ JobDef(PP_VisWorker, sig, job_id) { PP_VisCmdNode *cmd_node = PushStruct(frame_arena, PP_VisCmdNode); cmd_node->cmd.name = desc.name; - QueuePush(first_cmd_node, last_cmd_node, cmd_node); + SllQueuePush(first_cmd_node, last_cmd_node, cmd_node); ++cmds_count; } } @@ -362,7 +362,7 @@ JobDef(PP_VisWorker, sig, job_id) { PP_EntListNode *n = PushStruct(frame_arena, PP_EntListNode); ++spawn_ents.count; - QueuePush(spawn_ents.first, spawn_ents.last, n); + SllQueuePush(spawn_ents.first, spawn_ents.last, n); } break; } } @@ -378,7 +378,7 @@ JobDef(PP_VisWorker, sig, job_id) PP_SimCmdNode *cmd_node = PushStruct(v2s->arena, PP_SimCmdNode); cmd_node->cmd.kind = PP_SimCmdKind_Ent; cmd_node->cmd.ent = ent_node->ent; - QueuePush(v2s->first_cmd_node, v2s->last_cmd_node, cmd_node); + SllQueuePush(v2s->first_cmd_node, v2s->last_cmd_node, cmd_node); ++v2s->cmds_count; } } diff --git a/src/proto/pp_widgets.c b/src/proto/pp_widgets.c index d4afc554..481511dd 100644 --- a/src/proto/pp_widgets.c +++ b/src/proto/pp_widgets.c @@ -70,7 +70,7 @@ PP_CommandsWidgetItemReport PP_PushCommandsWidgetItem(PP_CommandsWidget *widget, PP_CommandsWidgetItem *item = PushStruct(frame_arena, PP_CommandsWidgetItem); item->key = key; item->desc = desc; - QueuePush(widget->build.first_item, widget->build.last_item, item); + SllQueuePush(widget->build.first_item, widget->build.last_item, item); ++widget->build.num_items; } diff --git a/src/sprite/sprite.c b/src/sprite/sprite.c index e92b6800..0a3d37dd 100644 --- a/src/sprite/sprite.c +++ b/src/sprite/sprite.c @@ -147,7 +147,7 @@ JobDef(SPR_LoadSheet, sig, _) /* Insert span into bin */ { SPR_SpanBin *bin = &sheet->span_bins[dst->hash % sheet->span_bins_count]; - QueuePushN(bin->first, bin->last, dst, next_in_bin); + SllQueuePushN(bin->first, bin->last, dst, next_in_bin); } ++span_index; } @@ -230,7 +230,7 @@ JobDef(SPR_LoadSheet, sig, _) /* Insert group into bin */ { SPR_SliceGroupBin *bin = &sheet->slice_group_bins[dst_group->hash % sheet->slice_group_bins_count]; - QueuePushN(bin->first, bin->last, dst_group, next_in_bin); + SllQueuePushN(bin->first, bin->last, dst_group, next_in_bin); } ++group_index; } @@ -324,7 +324,7 @@ SPR_Entry *SPR_FetchEntry(ResourceKey resource, JobPoolId pool, SPR_FetchFlag fl Arena *perm = PermArena(); entry = PushStruct(perm, SPR_Entry); entry->resource = resource; - QueuePushN(bin->first, bin->last, entry, next_in_bin); + SllQueuePushN(bin->first, bin->last, entry, next_in_bin); } } Unlock(&lock); diff --git a/src/ui/ui_core.c b/src/ui/ui_core.c index bd62ce96..6d3fbfea 100644 --- a/src/ui/ui_core.c +++ b/src/ui/ui_core.c @@ -397,7 +397,7 @@ UI_Key UI_BuildBoxEx(UI_Key key) n->cmd.floating_pos = UI_UseTop(FloatingPos); } ++g->bframe.cmds_count; - QueuePush(g->bframe.first_cmd_node, g->bframe.last_cmd_node, n); + SllQueuePush(g->bframe.first_cmd_node, g->bframe.last_cmd_node, n); return key; } @@ -752,7 +752,7 @@ i64 UI_EndFrame(UI_Frame frame) /* Remove box from old parent */ if (box->parent) { - DllRemove(box->parent->first, box->parent->last, box); + DllQueueRemove(box->parent->first, box->parent->last, box); --box->parent->count; } } @@ -761,14 +761,14 @@ i64 UI_EndFrame(UI_Frame frame) box = g->first_free_box; if (box) { - StackPop(g->first_free_box); + SllStackPop(g->first_free_box); ZeroStruct(box); } else { box = PushStruct(g->box_arena, UI_Box); } - DllPushBackNP(bin->first, bin->last, box, next_in_bin, prev_in_bin); + DllQueuePushNP(bin->first, bin->last, box, next_in_bin, prev_in_bin); } } ++g->boxes_count; @@ -791,7 +791,7 @@ i64 UI_EndFrame(UI_Frame frame) /* Insert box into parent */ if (parent) { - DllPushBack(parent->first, parent->last, box); + DllQueuePush(parent->first, parent->last, box); box->parent = parent; ++parent->count; } @@ -844,7 +844,7 @@ i64 UI_EndFrame(UI_Frame frame) { BoxNode *n = PushStruct(scratch.arena, BoxNode); n->box = g->eframe.root_box; - StackPush(first_dfs, n); + SllStackPush(first_dfs, n); } while (first_dfs) { @@ -859,7 +859,7 @@ i64 UI_EndFrame(UI_Frame frame) { BoxNode *child_n = PushStruct(scratch.arena, BoxNode); child_n->box = child; - StackPush(first_dfs, child_n); + SllStackPush(first_dfs, child_n); } } /* Push non-floating children to dfs stack */ @@ -869,7 +869,7 @@ i64 UI_EndFrame(UI_Frame frame) { BoxNode *child_n = PushStruct(scratch.arena, BoxNode); child_n->box = child; - StackPush(first_dfs, child_n); + SllStackPush(first_dfs, child_n); } } box->pre_index = pre_index++; @@ -878,7 +878,7 @@ i64 UI_EndFrame(UI_Frame frame) } else { - StackPop(first_dfs); + SllStackPop(first_dfs); box->post_index = post_index++; boxes_post[box->post_index] = box; } diff --git a/src/window/window_win32/window_win32.c b/src/window/window_win32/window_win32.c index 78cc112c..7b81d6ab 100644 --- a/src/window/window_win32/window_win32.c +++ b/src/window/window_win32/window_win32.c @@ -392,7 +392,7 @@ void WND_PushCmd_(WND_Frame frame, WND_Cmd desc) WND_W32_Window *window = WND_W32_WindowFromHandle(frame.window_handle); WND_W32_CmdNode *n = PushStruct(window->frame_arena, WND_W32_CmdNode); n->cmd = desc; - QueuePush(window->first_cmd, window->last_cmd, n); + SllQueuePush(window->first_cmd, window->last_cmd, n); if (desc.kind == WND_CmdKind_Restore) { n->cmd.restore = PushString(window->frame_arena, desc.restore);