From 4ff836609c1ec2aa598a129bf01499b7076aae78 Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Wed, 18 Sep 2024 21:03:48 +0300 Subject: [PATCH 1/6] [core/os] get_current_directory: Add allocator arg to targets where its missing --- core/os/os_darwin.odin | 2 +- core/os/os_freebsd.odin | 2 +- core/os/os_linux.odin | 2 +- core/os/os_netbsd.odin | 2 +- core/os/os_openbsd.odin | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 2bb6c0c59..5cef568dd 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -1095,7 +1095,7 @@ unset_env :: proc(key: string) -> Error { } @(require_results) -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { page_size := get_page_size() // NOTE(tetra): See note in os_linux.odin/get_current_directory. buf := make([dynamic]u8, page_size) for { diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index 241f42c0b..9bf8ee50f 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -840,7 +840,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) } @(require_results) -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 9132edbfe..35799c3d9 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -985,7 +985,7 @@ unset_env :: proc(key: string) -> Error { } @(require_results) -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. diff --git a/core/os/os_netbsd.odin b/core/os/os_netbsd.odin index ba9b40fc3..a311cc200 100644 --- a/core/os/os_netbsd.odin +++ b/core/os/os_netbsd.odin @@ -894,7 +894,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) } @(require_results) -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index aff78dc60..16d873588 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -806,7 +806,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) } @(require_results) -get_current_directory :: proc() -> string { +get_current_directory :: proc(allocator := context.allocator) -> string { buf := make([dynamic]u8, MAX_PATH) for { cwd := _unix_getcwd(cstring(raw_data(buf)), c.size_t(len(buf))) From 6e979a96a186606b779177b06e409b1e6a57534e Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Thu, 19 Sep 2024 00:10:53 +0300 Subject: [PATCH 2/6] Update core/os/os_darwin.odin Co-authored-by: Laytan --- core/os/os_darwin.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 5cef568dd..e00c63ccd 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -1096,6 +1096,7 @@ unset_env :: proc(key: string) -> Error { @(require_results) get_current_directory :: proc(allocator := context.allocator) -> string { + context.allocator = allocator page_size := get_page_size() // NOTE(tetra): See note in os_linux.odin/get_current_directory. buf := make([dynamic]u8, page_size) for { From 35f0dcbb92f2586a8708c8197fa4d61f17830e74 Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Thu, 19 Sep 2024 00:11:00 +0300 Subject: [PATCH 3/6] Update core/os/os_freebsd.odin Co-authored-by: Laytan --- core/os/os_freebsd.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index 9bf8ee50f..f617cf973 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -841,6 +841,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) @(require_results) get_current_directory :: proc(allocator := context.allocator) -> string { + context.allocator = allocator // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. From cbf0471c72de90ae101b6524e1d7e015bff7f4fa Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Thu, 19 Sep 2024 00:11:06 +0300 Subject: [PATCH 4/6] Update core/os/os_linux.odin Co-authored-by: Laytan --- core/os/os_linux.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/os/os_linux.odin b/core/os/os_linux.odin index 35799c3d9..8c8cd7f73 100644 --- a/core/os/os_linux.odin +++ b/core/os/os_linux.odin @@ -986,6 +986,7 @@ unset_env :: proc(key: string) -> Error { @(require_results) get_current_directory :: proc(allocator := context.allocator) -> string { + context.allocator = allocator // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. From 568705069c04376c282c21b17eb90c1253f9618f Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Thu, 19 Sep 2024 00:11:12 +0300 Subject: [PATCH 5/6] Update core/os/os_netbsd.odin Co-authored-by: Laytan --- core/os/os_netbsd.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/os/os_netbsd.odin b/core/os/os_netbsd.odin index a311cc200..493527803 100644 --- a/core/os/os_netbsd.odin +++ b/core/os/os_netbsd.odin @@ -895,6 +895,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) @(require_results) get_current_directory :: proc(allocator := context.allocator) -> string { + context.allocator = allocator // NOTE(tetra): I would use PATH_MAX here, but I was not able to find // an authoritative value for it across all systems. // The largest value I could find was 4096, so might as well use the page size. From 18fd1fefc38c8813c412de16c01c7c1edeccb1cd Mon Sep 17 00:00:00 2001 From: Yuriy Grynevych Date: Thu, 19 Sep 2024 00:11:17 +0300 Subject: [PATCH 6/6] Update core/os/os_openbsd.odin Co-authored-by: Laytan --- core/os/os_openbsd.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index 16d873588..62872d9dc 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -807,6 +807,7 @@ get_env :: proc(key: string, allocator := context.allocator) -> (value: string) @(require_results) get_current_directory :: proc(allocator := context.allocator) -> string { + context.allocator = allocator buf := make([dynamic]u8, MAX_PATH) for { cwd := _unix_getcwd(cstring(raw_data(buf)), c.size_t(len(buf)))