mirror of
https://github.com/Ed94/metadesk.git
synced 2026-08-06 15:48:47 +00:00
[examples] fix indexing bug in multi threaded example; make the intrinsic work with clang too
This commit is contained in:
@@ -13,8 +13,10 @@
|
|||||||
|
|
||||||
//~ multi-threaded parse setup ////////////////////////////////////////////////
|
//~ multi-threaded parse setup ////////////////////////////////////////////////
|
||||||
|
|
||||||
#if MD_COMPILER_CL
|
// for this intrinsic we're assume pre-increment behavior
|
||||||
# define atomic_inc_u64(p) InterlockedIncrement64((LONG64*)p)
|
|
||||||
|
#if MD_OS_WINDOWS
|
||||||
|
# define atomic_inc_then_eval_u64(p) InterlockedIncrement64((LONG64*)p)
|
||||||
#else
|
#else
|
||||||
# error Not implemented for this compiler
|
# error Not implemented for this compiler
|
||||||
#endif
|
#endif
|
||||||
@@ -42,7 +44,7 @@ parse_worker_loop(ThreadData *thread_data)
|
|||||||
TaskData *task = thread_data->task;
|
TaskData *task = thread_data->task;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
MD_u64 task_index = atomic_inc_u64(&task->task_counter);
|
MD_u64 task_index = atomic_inc_then_eval_u64(&task->task_counter) - 1;
|
||||||
if (task_index >= task->task_max)
|
if (task_index >= task->task_max)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -53,7 +55,7 @@ parse_worker_loop(ThreadData *thread_data)
|
|||||||
MD_PushNewReference(thread_data->arena, thread_data->list, parse.node);
|
MD_PushNewReference(thread_data->arena, thread_data->list, parse.node);
|
||||||
}
|
}
|
||||||
|
|
||||||
atomic_inc_u64(&task->thread_counter);
|
atomic_inc_then_eval_u64(&task->thread_counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MD_OS_WINDOWS
|
#if MD_OS_WINDOWS
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ baz: foo_again
|
|||||||
// undelimited sets may not contain unlabeled delimited sets
|
// undelimited sets may not contain unlabeled delimited sets
|
||||||
// the following forms one undelimited set followed by a delimited set
|
// the following forms one undelimited set followed by a delimited set
|
||||||
// the delimited set is a sibling to foo, not a child to foo.
|
// the delimited set is a sibling to foo, not a child to foo.
|
||||||
|
// this also emits a warning because it's weird.
|
||||||
foo: bar (baz)
|
foo: bar (baz)
|
||||||
|
|
||||||
// undelimited sets *may* however contain labeled delimited sets
|
// undelimited sets *may* however contain labeled delimited sets
|
||||||
|
|||||||
Reference in New Issue
Block a user