mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-13 04:51:25 -07:00
sync primitive fixes
This commit is contained in:
@@ -110,10 +110,6 @@
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
#define MemoryIsZeroStruct(p) memory_is_zero(p, sizeof(*p))
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
typedef struct
|
||||
{
|
||||
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)
|
||||
{
|
||||
String8 result = string;
|
||||
B32 starts_with_quote = str8_match_lit("\"", string, StringMatchFlag_RightSideSloppy);
|
||||
if (starts_with_quote) {
|
||||
if (str8_ends_with_lit(string, "\"", 0)) {
|
||||
result = str8_skip(result, 1);
|
||||
result = str8_chop(result, 1);
|
||||
} else {
|
||||
lnk_error_cmd_switch(error_code, obj, cmd_switch, "detected unmatched \" in \"%S\"", string);
|
||||
}
|
||||
|
||||
B32 starts_with_quote = str8_match(str8_substr(string, rng_1u64(0,1)), str8_lit("\""), 0);
|
||||
B32 ends_with_quote = 0;
|
||||
if (string.size > 2) {
|
||||
ends_with_quote = str8_match(str8_substr(string, rng_1u64(string.size-1,string.size)), str8_lit("\""), 0);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -4201,7 +4201,7 @@ lnk_src_file_hash_table_lookup_slot(LNK_SourceFileBucket **buckets,
|
||||
if (buckets[bucket_idx] == 0) {
|
||||
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];
|
||||
}
|
||||
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...
|
||||
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?
|
||||
int cmp = u64_compar(&curr_bucket->obj_idx, &new_bucket->obj_idx);
|
||||
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);
|
||||
|
||||
// alloc semaphores
|
||||
OS_Handle main_semaphore = {0};
|
||||
OS_Handle task_semaphore = {0};
|
||||
OS_Handle exec_semaphore = {0};
|
||||
Semaphore main_semaphore = {0};
|
||||
Semaphore task_semaphore = {0};
|
||||
Semaphore exec_semaphore = {0};
|
||||
if (worker_count > 1) {
|
||||
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
||||
if (is_shared) {
|
||||
@@ -111,7 +111,7 @@ tp_release(TP_Context *pool)
|
||||
{
|
||||
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) {
|
||||
for (U64 i = 0; i < pool->worker_count; ++i) {
|
||||
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);
|
||||
|
||||
// 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) {
|
||||
os_semaphore_drop(pool->exec_semaphore);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ typedef struct TP_Worker
|
||||
typedef struct TP_Context
|
||||
{
|
||||
B32 is_live;
|
||||
OS_Handle exec_semaphore;
|
||||
OS_Handle task_semaphore;
|
||||
OS_Handle main_semaphore;
|
||||
Semaphore exec_semaphore;
|
||||
Semaphore task_semaphore;
|
||||
Semaphore main_semaphore;
|
||||
|
||||
U32 worker_count;
|
||||
TP_Worker *worker_arr;
|
||||
|
||||
Reference in New Issue
Block a user