mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
sync primitive fixes
This commit is contained in:
@@ -110,10 +110,6 @@
|
|||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
#define MemoryIsZeroStruct(p) memory_is_zero(p, sizeof(*p))
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
U64 major;
|
U64 major;
|
||||||
|
|||||||
+13
-8
@@ -333,15 +333,20 @@ internal String8
|
|||||||
lnk_error_check_and_strip_quotes(LNK_ErrorCode error_code, LNK_Obj *obj, LNK_CmdSwitchType cmd_switch, String8 string)
|
lnk_error_check_and_strip_quotes(LNK_ErrorCode error_code, LNK_Obj *obj, LNK_CmdSwitchType cmd_switch, String8 string)
|
||||||
{
|
{
|
||||||
String8 result = string;
|
String8 result = string;
|
||||||
B32 starts_with_quote = str8_match_lit("\"", string, StringMatchFlag_RightSideSloppy);
|
|
||||||
if (starts_with_quote) {
|
B32 starts_with_quote = str8_match(str8_substr(string, rng_1u64(0,1)), str8_lit("\""), 0);
|
||||||
if (str8_ends_with_lit(string, "\"", 0)) {
|
B32 ends_with_quote = 0;
|
||||||
result = str8_skip(result, 1);
|
if (string.size > 2) {
|
||||||
result = str8_chop(result, 1);
|
ends_with_quote = str8_match(str8_substr(string, rng_1u64(string.size-1,string.size)), str8_lit("\""), 0);
|
||||||
} else {
|
|
||||||
lnk_error_cmd_switch(error_code, obj, cmd_switch, "detected unmatched \" in \"%S\"", string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (starts_with_quote && ends_with_quote) {
|
||||||
|
result = str8_skip(result, 1);
|
||||||
|
result = str8_chop(result, 1);
|
||||||
|
} else if (starts_with_quote && !ends_with_quote) {
|
||||||
|
lnk_error_cmd_switch(error_code, obj, cmd_switch, "detected unmatched \" in \"%S\"", string);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4201,7 +4201,7 @@ lnk_src_file_hash_table_lookup_slot(LNK_SourceFileBucket **buckets,
|
|||||||
if (buckets[bucket_idx] == 0) {
|
if (buckets[bucket_idx] == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (rdib_source_file_match(buckets[bucket_idx]->src_file, &temp, operating_system_from_context())) {
|
if (rdib_source_file_match(buckets[bucket_idx]->src_file, &temp, OperatingSystem_CURRENT)) {
|
||||||
return buckets[bucket_idx];
|
return buckets[bucket_idx];
|
||||||
}
|
}
|
||||||
bucket_idx = (bucket_idx + 1) % cap;
|
bucket_idx = (bucket_idx + 1) % cap;
|
||||||
@@ -4233,7 +4233,7 @@ lnk_src_file_insert_or_update(LNK_SourceFileBucket **buckets, U64 cap, U64 hash,
|
|||||||
|
|
||||||
// another thread took the bucket...
|
// another thread took the bucket...
|
||||||
goto retry;
|
goto retry;
|
||||||
} else if (rdib_source_file_match(curr_bucket->src_file, new_bucket->src_file, operating_system_from_context())) {
|
} else if (rdib_source_file_match(curr_bucket->src_file, new_bucket->src_file, OperatingSystem_CURRENT)) {
|
||||||
// do we need to update value in the bucket?
|
// do we need to update value in the bucket?
|
||||||
int cmp = u64_compar(&curr_bucket->obj_idx, &new_bucket->obj_idx);
|
int cmp = u64_compar(&curr_bucket->obj_idx, &new_bucket->obj_idx);
|
||||||
if (cmp <= 0) {
|
if (cmp <= 0) {
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ tp_alloc(Arena *arena, U32 worker_count, U32 max_worker_count, String8 name)
|
|||||||
B32 is_shared = (name.size > 0);
|
B32 is_shared = (name.size > 0);
|
||||||
|
|
||||||
// alloc semaphores
|
// alloc semaphores
|
||||||
OS_Handle main_semaphore = {0};
|
Semaphore main_semaphore = {0};
|
||||||
OS_Handle task_semaphore = {0};
|
Semaphore task_semaphore = {0};
|
||||||
OS_Handle exec_semaphore = {0};
|
Semaphore exec_semaphore = {0};
|
||||||
if (worker_count > 1) {
|
if (worker_count > 1) {
|
||||||
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
||||||
if (is_shared) {
|
if (is_shared) {
|
||||||
@@ -111,7 +111,7 @@ tp_release(TP_Context *pool)
|
|||||||
{
|
{
|
||||||
pool->is_live = 0;
|
pool->is_live = 0;
|
||||||
|
|
||||||
B32 is_shared = !os_handle_match(pool->exec_semaphore, os_handle_zero());
|
B32 is_shared = pool->exec_semaphore.u64[0] != 0;
|
||||||
if (is_shared) {
|
if (is_shared) {
|
||||||
for (U64 i = 0; i < pool->worker_count; ++i) {
|
for (U64 i = 0; i < pool->worker_count; ++i) {
|
||||||
os_semaphore_drop(pool->exec_semaphore);
|
os_semaphore_drop(pool->exec_semaphore);
|
||||||
@@ -209,7 +209,7 @@ tp_for_parallel(TP_Context *pool, TP_Arena *task_arena, U64 task_count, TP_TaskF
|
|||||||
U64 drop_count = Min(task_count, pool->worker_count);
|
U64 drop_count = Min(task_count, pool->worker_count);
|
||||||
|
|
||||||
// if we are in shared mode ping local semaphore
|
// if we are in shared mode ping local semaphore
|
||||||
if (!os_handle_match(pool->exec_semaphore, os_handle_zero())) {
|
if (pool->exec_semaphore.u64[0] != 0) {
|
||||||
for (U64 worker_idx = 0; worker_idx < drop_count; worker_idx +=1) {
|
for (U64 worker_idx = 0; worker_idx < drop_count; worker_idx +=1) {
|
||||||
os_semaphore_drop(pool->exec_semaphore);
|
os_semaphore_drop(pool->exec_semaphore);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ typedef struct TP_Worker
|
|||||||
typedef struct TP_Context
|
typedef struct TP_Context
|
||||||
{
|
{
|
||||||
B32 is_live;
|
B32 is_live;
|
||||||
OS_Handle exec_semaphore;
|
Semaphore exec_semaphore;
|
||||||
OS_Handle task_semaphore;
|
Semaphore task_semaphore;
|
||||||
OS_Handle main_semaphore;
|
Semaphore main_semaphore;
|
||||||
|
|
||||||
U32 worker_count;
|
U32 worker_count;
|
||||||
TP_Worker *worker_arr;
|
TP_Worker *worker_arr;
|
||||||
|
|||||||
Reference in New Issue
Block a user