Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/odin-lang/Odin
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerBill committed Sep 19, 2024
2 parents 2449071 + 0ca5e70 commit 5441620
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 6 deletions.
7 changes: 6 additions & 1 deletion core/os/os2/allocators.odin
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ global_default_temp_allocator_index: uint

@(require_results)
temp_allocator :: proc() -> runtime.Allocator {
arena := &global_default_temp_allocator_arenas[global_default_temp_allocator_index]
if arena.backing_allocator.procedure == nil {
arena.backing_allocator = heap_allocator()
}

return runtime.Allocator{
procedure = temp_allocator_proc,
data = &global_default_temp_allocator_arenas[global_default_temp_allocator_index],
data = arena,
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/os/os_darwin.odin
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ unset_env :: proc(key: string) -> Error {
}

@(require_results)
get_current_directory :: proc() -> string {
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 {
Expand Down
3 changes: 2 additions & 1 deletion core/os/os_freebsd.odin
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,8 @@ 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 {
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.
Expand Down
3 changes: 2 additions & 1 deletion core/os/os_linux.odin
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,8 @@ unset_env :: proc(key: string) -> Error {
}

@(require_results)
get_current_directory :: proc() -> string {
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.
Expand Down
3 changes: 2 additions & 1 deletion core/os/os_netbsd.odin
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,8 @@ 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 {
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.
Expand Down
3 changes: 2 additions & 1 deletion core/os/os_openbsd.odin
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,8 @@ 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 {
context.allocator = allocator
buf := make([dynamic]u8, MAX_PATH)
for {
cwd := _unix_getcwd(cstring(raw_data(buf)), c.size_t(len(buf)))
Expand Down

0 comments on commit 5441620

Please sign in to comment.