mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-09-24 02:00:05 +00:00
eliminate os_core, move into base; eliminate regs, move into arch abstraction layer, define x64 regs in x64 layer; move win32 backend for os core (now base) functionality to top-level win32 layer
This commit is contained in:
+12
-12
@@ -136,7 +136,7 @@ lnk_make_default_cmd_line(Arena *arena, LNK_CmdLine user_cmd_line)
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_PdbAltPath, "%%_RAD_PDB_PATH%%");
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_PdbPageSize, "%u", KB(4));
|
||||
if (!lnk_cmd_line_has_switch(user_cmd_line, LNK_CmdSwitch_Brepro)) {
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_TimeStamp, "%u", os_get_process_start_time_unix());
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_TimeStamp, "%u", get_process_start_time_unix());
|
||||
}
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_TypeHashAlg, "BLAKE3");
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_Age, "%u", 1);
|
||||
@@ -150,7 +150,7 @@ lnk_make_default_cmd_line(Arena *arena, LNK_CmdLine user_cmd_line)
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_OsVer, "6.0");
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_PageSize, "%u", KB(4));
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_PathStyle, "system");
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_Workers, "%u", os_get_system_info()->logical_processor_count);
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_Workers, "%u", get_system_info()->logical_processor_count);
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_DebugAltPath, "%%_RAD_RDI_PATH%%");
|
||||
lnk_cmd_line_push_option_if_not_presentf(arena, &cmd_line, LNK_CmdSwitch_Rad_MemoryMapFiles, "");
|
||||
if (BUILD_DEBUG) {
|
||||
@@ -374,7 +374,7 @@ lnk_merge_manifest_files(String8 mt_path, String8 out_name, String8List manifest
|
||||
str8_list_pushf(scratch.arena, &cmd_line, "-nologo");
|
||||
|
||||
// register input manifest files on command line
|
||||
String8 work_dir = os_get_current_path(scratch.arena);
|
||||
String8 work_dir = get_current_path(scratch.arena);
|
||||
for (String8Node *man_node = manifest_path_list.first;
|
||||
man_node != 0;
|
||||
man_node = man_node->next) {
|
||||
@@ -390,15 +390,15 @@ lnk_merge_manifest_files(String8 mt_path, String8 out_name, String8List manifest
|
||||
}
|
||||
|
||||
// launch mt.exe with our command line
|
||||
OS_ProcessLaunchParams launch_opts = {0};
|
||||
ProcessLaunchParams launch_opts = {0};
|
||||
launch_opts.cmd_line = cmd_line;
|
||||
launch_opts.inherit_env = 1;
|
||||
launch_opts.consoleless = 0;
|
||||
OS_Handle mt_handle = os_process_launch(&launch_opts);
|
||||
if (os_handle_match(mt_handle, os_handle_zero())) {
|
||||
Process mt_handle = process_launch(&launch_opts);
|
||||
if (process_match(mt_handle, process_zero())) {
|
||||
lnk_error(LNK_Error_Mt, "unable to start process: %S", mt_path);
|
||||
} else {
|
||||
os_process_join(mt_handle, max_U64, 0);
|
||||
process_join(mt_handle, max_U64, 0);
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
@@ -447,8 +447,8 @@ lnk_manifest_from_inputs(Arena *arena,
|
||||
}
|
||||
|
||||
// cleanup disk
|
||||
os_delete_file_at_path(linker_manifest_path);
|
||||
os_delete_file_at_path(merged_manifest_path);
|
||||
delete_file_at_path(linker_manifest_path);
|
||||
delete_file_at_path(merged_manifest_path);
|
||||
|
||||
ProfEnd();
|
||||
} else {
|
||||
@@ -804,7 +804,7 @@ lnk_make_res_obj(Arena *arena,
|
||||
}
|
||||
|
||||
// convert res to obj
|
||||
OS_ProcessInfo *process_info = os_get_process_info();
|
||||
ProcessInfo *process_info = get_process_info();
|
||||
String8List exe_path_strs = {0};
|
||||
str8_list_push(scratch.arena, &exe_path_strs, process_info->binary_path);
|
||||
String8 exe_path = str8_list_first(&exe_path_strs);
|
||||
@@ -1032,7 +1032,7 @@ lnk_inputer_push_obj_thin(LNK_Inputer *inputer, LNK_LibMemberRef *link_member, S
|
||||
{
|
||||
lnk_log(LNK_Log_InputObj, "Input Obj: %S", path);
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
String8 full_path = os_full_path_from_path(scratch.arena, path);
|
||||
String8 full_path = full_path_from_path(scratch.arena, path);
|
||||
LNK_Input *input = lnk_inputer_push_thin(inputer->arena, &inputer->new_objs, inputer->objs_ht, full_path);
|
||||
input->link_member = link_member;
|
||||
scratch_end(scratch);
|
||||
@@ -1059,7 +1059,7 @@ lnk_input_from_path(HashTable *load_ht, String8 path)
|
||||
LNK_Input *input = hash_table_search_path_raw(load_ht, path);
|
||||
if (input == 0) {
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String8 full_path = os_full_path_from_path(scratch.arena, path);
|
||||
String8 full_path = full_path_from_path(scratch.arena, path);
|
||||
input = hash_table_search_path_raw(load_ht, full_path);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
+17
-17
@@ -1115,7 +1115,7 @@ lnk_unwrap_rsp(Arena *arena, String8List arg_list)
|
||||
// remove "@"
|
||||
String8 name = str8_skip(curr->string, 1);
|
||||
|
||||
if (os_file_path_exists(name)) {
|
||||
if (file_path_exists(name)) {
|
||||
// read rsp from disk
|
||||
String8 file = lnk_read_data_from_file_path(scratch.arena, 0, name);
|
||||
|
||||
@@ -1469,8 +1469,8 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
case LNK_CmdSwitch_LibPath: {
|
||||
String8List lib_dir_list = str8_list_copy(config->arena, &value_strings);
|
||||
for (String8Node *dir_n = lib_dir_list.first; dir_n != 0; dir_n = dir_n->next) {
|
||||
if (!os_folder_path_exists(dir_n->string)) {
|
||||
String8 full_path = os_full_path_from_path(scratch.arena, dir_n->string);
|
||||
if (!folder_path_exists(dir_n->string)) {
|
||||
String8 full_path = full_path_from_path(scratch.arena, dir_n->string);
|
||||
lnk_error_cmd_switch(LNK_Warning_Cmdl, obj, cmd_switch, "path doesn't exist %S", full_path);
|
||||
}
|
||||
}
|
||||
@@ -1827,7 +1827,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
|
||||
case LNK_CmdSwitch_Rad_BuildInfo: {
|
||||
lnk_print_build_info();
|
||||
os_abort(0);
|
||||
abort_self(0);
|
||||
} break;
|
||||
|
||||
case LNK_CmdSwitch_Rad_CheckUnusedDelayLoadDll: {
|
||||
@@ -1881,7 +1881,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
if (str8_match_lit("imageblake3", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
config->guid_type = Lnk_DebugInfoGuid_ImageBlake3;
|
||||
} else if (str8_match_lit("random", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
config->guid = os_make_guid();
|
||||
config->guid = make_guid();
|
||||
} else {
|
||||
Guid guid;
|
||||
if (try_guid_from_string(value_strings.first->string, &guid)) {
|
||||
@@ -1897,7 +1897,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
|
||||
case LNK_CmdSwitch_Rad_LargePages: {
|
||||
if (value_strings.node_count == 0) {
|
||||
OS_ProcessInfo *process_info = os_get_process_info();
|
||||
ProcessInfo *process_info = get_process_info();
|
||||
if (process_info->large_pages_allowed) {
|
||||
arena_default_flags |= ArenaFlag_LargePages;
|
||||
} else {
|
||||
@@ -1914,7 +1914,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
}
|
||||
} else if (value_strings.node_count == 1) {
|
||||
if (str8_match_lit("quiet", value_strings.first->string, StringMatchFlag_CaseInsensitive)) {
|
||||
OS_ProcessInfo *process_info = os_get_process_info();
|
||||
ProcessInfo *process_info = get_process_info();
|
||||
if (process_info->large_pages_allowed) {
|
||||
arena_default_flags |= ArenaFlag_LargePages;
|
||||
}
|
||||
@@ -2031,7 +2031,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
} break;
|
||||
|
||||
case LNK_CmdSwitch_Rad_SharedThreadPoolMaxWorkers: {
|
||||
OS_SystemInfo *sysinfo = os_get_system_info();
|
||||
SystemInfo *sysinfo = get_system_info();
|
||||
if (value_strings.node_count == 0) {
|
||||
config->max_worker_count = sysinfo->logical_processor_count;
|
||||
} else {
|
||||
@@ -2101,7 +2101,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
|
||||
case LNK_CmdSwitch_Rad_Version: {
|
||||
lnk_fprintf(stdout, "%s\n", BUILD_TITLE_STRING_LITERAL);
|
||||
os_abort(0);
|
||||
abort_self(0);
|
||||
} break;
|
||||
|
||||
case LNK_CmdSwitch_Rad_Workers: {
|
||||
@@ -2113,7 +2113,7 @@ lnk_apply_cmd_option_to_config(LNK_Config *config, String8 cmd_name, String8List
|
||||
|
||||
case LNK_CmdSwitch_Help: {
|
||||
lnk_print_help();
|
||||
os_abort(0);
|
||||
abort_self(0);
|
||||
} break;
|
||||
}
|
||||
|
||||
@@ -2130,7 +2130,7 @@ lnk_config_from_cmd_line(String8List raw_cmd_line, LNK_CmdLine cmd_line)
|
||||
LNK_Config *config = push_array(arena, LNK_Config, 1);
|
||||
config->arena = arena;
|
||||
config->raw_cmd_line = str8_list_copy(arena, &raw_cmd_line);
|
||||
config->work_dir = os_get_current_path(arena);
|
||||
config->work_dir = get_current_path(arena);
|
||||
config->build_imp_lib = 1;
|
||||
config->build_exp = 1;
|
||||
config->heap_reserve = MB(1);
|
||||
@@ -2304,17 +2304,17 @@ lnk_config_from_cmd_line(String8List raw_cmd_line, LNK_CmdLine cmd_line)
|
||||
}
|
||||
|
||||
// convert to full paths
|
||||
config->out_path = os_full_path_from_path(arena, config->out_path);
|
||||
config->pdb_name = os_full_path_from_path(arena, config->pdb_name);
|
||||
config->rad_debug_name = os_full_path_from_path(arena, config->rad_debug_name);
|
||||
config->imp_lib_name = os_full_path_from_path(arena, config->imp_lib_name);
|
||||
config->manifest_name = os_full_path_from_path(arena, config->manifest_name);
|
||||
config->out_path = full_path_from_path(arena, config->out_path);
|
||||
config->pdb_name = full_path_from_path(arena, config->pdb_name);
|
||||
config->rad_debug_name = full_path_from_path(arena, config->rad_debug_name);
|
||||
config->imp_lib_name = full_path_from_path(arena, config->imp_lib_name);
|
||||
config->manifest_name = full_path_from_path(arena, config->manifest_name);
|
||||
|
||||
// collect env vars
|
||||
HashTable *env_vars = hash_table_init(scratch.arena, 512);
|
||||
{
|
||||
#if OS_WINDOWS
|
||||
OS_ProcessInfo *process_info = os_get_process_info();
|
||||
ProcessInfo *process_info = get_process_info();
|
||||
for (String8Node *node = process_info->environment.first; node != 0; node = node->next) {
|
||||
String8List list = str8_split_by_string_chars(scratch.arena, node->string, str8_lit("="), 0);
|
||||
|
||||
|
||||
@@ -479,7 +479,7 @@ lnk_make_code_view_input(TP_Context *tp, TP_Arena *tp_arena, LNK_Config *config,
|
||||
ProfBegin("Set up PCH");
|
||||
{
|
||||
// hash_table<obj_path, obj_idx>
|
||||
String8 work_dir = os_get_current_path(scratch.arena);
|
||||
String8 work_dir = get_current_path(scratch.arena);
|
||||
HashTable *debug_p_ht = hash_table_init(scratch.arena, obj_count);
|
||||
for EachIndex(i, input.debug_p_indices.count) {
|
||||
U64 obj_idx = input.debug_p_indices.v[i];
|
||||
|
||||
+25
-25
@@ -1,41 +1,41 @@
|
||||
shared_function int
|
||||
lnk_open_file_read(char *path, uint64_t path_size, void *handle_buffer, uint64_t handle_buffer_max)
|
||||
{
|
||||
OS_Handle handle = os_file_open(OS_AccessFlag_Read|OS_AccessFlag_ShareRead, str8((U8*)path, path_size));
|
||||
File handle = file_open(AccessFlag_Read|AccessFlag_ShareRead, str8((U8*)path, path_size));
|
||||
Assert(sizeof(handle) <= handle_buffer_max);
|
||||
MemoryCopy(handle_buffer, &handle, sizeof(handle));
|
||||
return !os_handle_match(handle, os_handle_zero());
|
||||
return !file_match(handle, file_zero());
|
||||
}
|
||||
|
||||
shared_function int
|
||||
lnk_open_file_write(char *path, uint64_t path_size, void *handle_buffer, uint64_t handle_buffer_max)
|
||||
{
|
||||
OS_Handle handle = os_file_open(OS_AccessFlag_Write, str8((U8*)path, path_size));
|
||||
File handle = file_open(AccessFlag_Write, str8((U8*)path, path_size));
|
||||
Assert(sizeof(handle) <= handle_buffer_max);
|
||||
MemoryCopy(handle_buffer, &handle, sizeof(handle));
|
||||
return !os_handle_match(handle, os_handle_zero());
|
||||
return !file_match(handle, file_zero());
|
||||
}
|
||||
|
||||
shared_function void
|
||||
lnk_close_file(void *raw_handle)
|
||||
{
|
||||
OS_Handle handle = *(OS_Handle *)raw_handle;
|
||||
os_file_close(handle);
|
||||
File handle = *(File *)raw_handle;
|
||||
file_close(handle);
|
||||
}
|
||||
|
||||
shared_function uint64_t
|
||||
lnk_size_from_file(void *raw_handle)
|
||||
{
|
||||
OS_Handle handle = *(OS_Handle *)raw_handle;
|
||||
FileProperties props = os_properties_from_file(handle);
|
||||
File handle = *(File *)raw_handle;
|
||||
FileProperties props = properties_from_file(handle);
|
||||
return props.size;
|
||||
}
|
||||
|
||||
shared_function uint64_t
|
||||
lnk_read_file(void *raw_handle, void *buffer, uint64_t buffer_max)
|
||||
{
|
||||
OS_Handle handle = *(OS_Handle *)raw_handle;
|
||||
U64 read_size = os_file_read(handle, rng_1u64(0, buffer_max), buffer);
|
||||
File handle = *(File *)raw_handle;
|
||||
U64 read_size = file_read(handle, rng_1u64(0, buffer_max), buffer);
|
||||
Assert(read_size == buffer_max);
|
||||
return read_size;
|
||||
}
|
||||
@@ -43,8 +43,8 @@ lnk_read_file(void *raw_handle, void *buffer, uint64_t buffer_max)
|
||||
shared_function uint64_t
|
||||
lnk_write_file(void *raw_handle, uint64_t offset, void *buffer, uint64_t buffer_size)
|
||||
{
|
||||
OS_Handle handle = *(OS_Handle*)raw_handle;
|
||||
U64 write_size = os_file_write(handle, r1u64(offset, offset + buffer_size), buffer);
|
||||
File handle = *(File*)raw_handle;
|
||||
U64 write_size = file_write(handle, r1u64(offset, offset + buffer_size), buffer);
|
||||
return write_size;
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ lnk_find_first_file(Arena *arena, String8List dir_list, String8 path)
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
String8 result = {0};
|
||||
if (os_file_path_exists(path)) {
|
||||
if (file_path_exists(path)) {
|
||||
PathStyle path_style = path_style_from_str8(path);
|
||||
if (path_style == PathStyle_Relative) {
|
||||
String8 current_path = os_get_current_path(scratch.arena);
|
||||
String8 current_path = get_current_path(scratch.arena);
|
||||
String8List l = {0};
|
||||
str8_list_push(scratch.arena, &l, current_path);
|
||||
str8_list_push(scratch.arena, &l, path);
|
||||
@@ -69,7 +69,7 @@ lnk_find_first_file(Arena *arena, String8List dir_list, String8 path)
|
||||
String8 file_name = str8_skip_last_slash(path);
|
||||
for EachNode(n, String8Node, dir_list.first) {
|
||||
String8 full_path = push_str8f(scratch.arena, "%S/%S", n->string, file_name);
|
||||
if (os_file_path_exists(full_path)) {
|
||||
if (file_path_exists(full_path)) {
|
||||
result = push_str8_copy(arena, full_path);
|
||||
break;
|
||||
}
|
||||
@@ -80,10 +80,10 @@ lnk_find_first_file(Arena *arena, String8List dir_list, String8 path)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal OS_Handle
|
||||
internal File
|
||||
lnk_file_open_with_rename_permissions(String8 path)
|
||||
{
|
||||
OS_Handle file_handle = os_handle_zero();
|
||||
File file_handle = file_zero();
|
||||
#if OS_WINDOWS
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
|
||||
@@ -109,7 +109,7 @@ lnk_file_open_with_rename_permissions(String8 path)
|
||||
}
|
||||
|
||||
internal B32
|
||||
lnk_file_set_delete_on_close(OS_Handle handle, B32 delete_file)
|
||||
lnk_file_set_delete_on_close(File handle, B32 delete_file)
|
||||
{
|
||||
#if OS_WINDOWS
|
||||
FILE_DISPOSITION_INFO file_disposition = {0};
|
||||
@@ -122,7 +122,7 @@ lnk_file_set_delete_on_close(OS_Handle handle, B32 delete_file)
|
||||
}
|
||||
|
||||
internal B32
|
||||
lnk_file_rename(OS_Handle handle, String8 new_name)
|
||||
lnk_file_rename(File handle, String8 new_name)
|
||||
{
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
#if OS_WINDOWS
|
||||
@@ -167,7 +167,7 @@ THREAD_POOL_TASK_FUNC(lnk_data_size_from_file_path_task)
|
||||
LNK_DiskReader *task = raw_task;
|
||||
String8 path = task->path_arr.v[task_id];
|
||||
|
||||
OS_Handle handle = {0};
|
||||
File handle = {0};
|
||||
U64 size = 0;
|
||||
|
||||
int is_open = lnk_open_file_read((char*)path.str, path.size, &handle, sizeof(handle));
|
||||
@@ -184,7 +184,7 @@ THREAD_POOL_TASK_FUNC(lnk_data_from_file_path_task)
|
||||
{
|
||||
LNK_DiskReader *task = raw_task;
|
||||
|
||||
OS_Handle handle = task->handle_arr[task_id];
|
||||
File handle = task->handle_arr[task_id];
|
||||
U64 buffer_size = task->size_arr[task_id];
|
||||
U8 *buffer = task->buffer + task->off_arr[task_id];
|
||||
|
||||
@@ -239,7 +239,7 @@ lnk_read_data_from_file_path_parallel(TP_Context *tp, Arena *arena, LNK_IO_Flags
|
||||
Temp scratch = scratch_begin(&arena,1);
|
||||
|
||||
reader.path_arr = path_arr;
|
||||
reader.handle_arr = push_array_no_zero(scratch.arena, OS_Handle, path_arr.count);
|
||||
reader.handle_arr = push_array_no_zero(scratch.arena, File, path_arr.count);
|
||||
reader.size_arr = push_array_no_zero(scratch.arena, U64, path_arr.count);
|
||||
|
||||
// open handles and get sizes
|
||||
@@ -284,7 +284,7 @@ lnk_write_data_list_to_file_path(String8 path, String8 temp_path, String8List da
|
||||
ProfBeginV("Write %M to %S", data.total_size, path);
|
||||
|
||||
B32 open_with_rename = (temp_path.size > 0);
|
||||
OS_Handle file_handle = {0};
|
||||
File file_handle = {0};
|
||||
String8 open_file_path = {0};
|
||||
if (open_with_rename) {
|
||||
file_handle = lnk_file_open_with_rename_permissions(temp_path);
|
||||
@@ -299,9 +299,9 @@ lnk_write_data_list_to_file_path(String8 path, String8 temp_path, String8List da
|
||||
open_file_path = path;
|
||||
}
|
||||
|
||||
if (!os_handle_match(file_handle, os_handle_zero())) {
|
||||
if (!file_match(file_handle, file_zero())) {
|
||||
// try to reserve up front file size
|
||||
if (!os_file_reserve_size(file_handle, data.total_size)) {
|
||||
if (!file_reserve_size(file_handle, data.total_size)) {
|
||||
lnk_log(LNK_Log_IO_Write, "Failed to pre-allocate file %S with size %M", open_file_path, data.total_size);
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -11,7 +11,7 @@ typedef struct
|
||||
LNK_IO_Flags io_flags;
|
||||
String8Array path_arr;
|
||||
String8Array data_arr;
|
||||
OS_Handle *handle_arr;
|
||||
File *handle_arr;
|
||||
U64 *size_arr;
|
||||
U64 *off_arr;
|
||||
U8 *buffer;
|
||||
@@ -28,9 +28,9 @@ shared_function uint64_t lnk_write_file(void *raw_handle, uint64_t offset, void
|
||||
|
||||
// --- IO Functions ------------------------------------------------------------
|
||||
|
||||
internal OS_Handle lnk_file_open_with_rename_permissions(String8 path);
|
||||
internal B32 lnk_file_set_delete_on_close(OS_Handle handle, B32 delete_file);
|
||||
internal B32 lnk_file_rename(OS_Handle handle, String8 new_name);
|
||||
internal File lnk_file_open_with_rename_permissions(String8 path);
|
||||
internal B32 lnk_file_set_delete_on_close(File handle, B32 delete_file);
|
||||
internal B32 lnk_file_rename(File handle, String8 new_name);
|
||||
|
||||
internal String8 lnk_read_data_from_file_path(Arena *arena, LNK_IO_Flags io_flags, String8 path);
|
||||
internal String8Array lnk_read_data_from_file_path_parallel(TP_Context *tp, Arena *arena, LNK_IO_Flags io_flags, String8Array path_arr);
|
||||
|
||||
@@ -6,13 +6,13 @@ global LNK_Timer g_timers[LNK_Timer_Count];
|
||||
internal void
|
||||
lnk_timer_begin(LNK_TimerType timer)
|
||||
{
|
||||
g_timers[timer].begin = os_now_microseconds();
|
||||
g_timers[timer].begin = now_time_us();
|
||||
}
|
||||
|
||||
internal void
|
||||
lnk_timer_end(LNK_TimerType timer)
|
||||
{
|
||||
g_timers[timer].end = os_now_microseconds();
|
||||
g_timers[timer].end = now_time_us();
|
||||
}
|
||||
|
||||
internal String8
|
||||
|
||||
@@ -1613,7 +1613,7 @@ pdb_add_src(PDB_InfoContext *info, MSF_Context *msf, String8 file_path, String8
|
||||
if (comp == PDB_SrcComp_NULL) {
|
||||
// process path so it passes VS validity checks
|
||||
String8 virt_path = file_path;
|
||||
String8 work_dir = os_get_current_path(scratch.arena);
|
||||
String8 work_dir = get_current_path(scratch.arena);
|
||||
virt_path = path_absolute_dst_from_relative_dst_src(scratch.arena, virt_path, work_dir);
|
||||
virt_path = lower_from_str8(scratch.arena, virt_path);
|
||||
virt_path = path_convert_slashes(scratch.arena, virt_path, PathStyle_UnixAbsolute);
|
||||
|
||||
@@ -23,7 +23,7 @@ tp_run_tasks(TP_Context *pool, TP_Worker *worker)
|
||||
// on last task ping main thread
|
||||
U64 task_done = ins_atomic_u64_inc_eval(&pool->task_done);
|
||||
if (task_done == task_count) {
|
||||
os_semaphore_drop(pool->main_semaphore);
|
||||
semaphore_drop(pool->main_semaphore);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ tp_worker_main(void *raw_worker)
|
||||
TP_Worker *worker = raw_worker;
|
||||
TP_Context *pool = worker->pool;
|
||||
for (; pool->is_live; ) {
|
||||
if (os_semaphore_take(pool->task_semaphore, max_U64)) {
|
||||
if (semaphore_take(pool->task_semaphore, max_U64)) {
|
||||
tp_run_tasks(pool, worker);
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,8 @@ tp_worker_main_shared(void *raw_worker)
|
||||
TP_Worker *worker = raw_worker;
|
||||
TP_Context *pool = worker->pool;
|
||||
for (; pool->is_live; ) {
|
||||
if (os_semaphore_take(pool->exec_semaphore, max_U64)) {
|
||||
if (os_semaphore_take(pool->task_semaphore, max_U64)) {
|
||||
if (semaphore_take(pool->exec_semaphore, max_U64)) {
|
||||
if (semaphore_take(pool->task_semaphore, max_U64)) {
|
||||
tp_run_tasks(pool, worker);
|
||||
}
|
||||
}
|
||||
@@ -67,13 +67,13 @@ tp_alloc(Arena *arena, U32 worker_count, U32 max_worker_count, String8 name)
|
||||
Semaphore task_semaphore = {0};
|
||||
Semaphore exec_semaphore = {0};
|
||||
if (worker_count > 1) {
|
||||
main_semaphore = os_semaphore_alloc(0, 1, str8_zero());
|
||||
main_semaphore = semaphore_alloc(0, 1, str8_zero());
|
||||
if (is_shared) {
|
||||
AssertAlways(worker_count <= max_worker_count);
|
||||
task_semaphore = os_semaphore_alloc(0, max_worker_count, name);
|
||||
exec_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
||||
task_semaphore = semaphore_alloc(0, max_worker_count, name);
|
||||
exec_semaphore = semaphore_alloc(0, worker_count, str8_zero());
|
||||
} else {
|
||||
task_semaphore = os_semaphore_alloc(0, worker_count, str8_zero());
|
||||
task_semaphore = semaphore_alloc(0, worker_count, str8_zero());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,20 +213,20 @@ tp_for_parallel(TP_Context *pool, TP_Arena *task_arena, U64 task_count, TP_TaskF
|
||||
// if we are in shared mode ping local semaphore
|
||||
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);
|
||||
semaphore_drop(pool->exec_semaphore);
|
||||
}
|
||||
}
|
||||
|
||||
// ping shared semaphore
|
||||
for (U64 worker_idx = 0; worker_idx < drop_count; worker_idx += 1) {
|
||||
os_semaphore_drop(pool->task_semaphore);
|
||||
semaphore_drop(pool->task_semaphore);
|
||||
}
|
||||
|
||||
// run tasks on main worker
|
||||
tp_run_tasks(pool, &pool->worker_arr[0]);
|
||||
|
||||
// wait for workers to finish tasks
|
||||
os_semaphore_take(pool->main_semaphore, max_U64);
|
||||
semaphore_take(pool->main_semaphore, max_U64);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user