mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Updated core lib and did cleanup
Updated core with some path related functions and did some minor code cleanup. Most of the standard library function is just a matter of copy what is there for the other BSDs.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
//+build freebsd, netbsd
|
||||||
package os
|
package os
|
||||||
|
|
||||||
import "core:mem"
|
import "core:mem"
|
||||||
@@ -483,6 +483,13 @@ is_dir_path :: proc(path: string, follow_links: bool = true) -> bool {
|
|||||||
is_file :: proc {is_file_path, is_file_handle}
|
is_file :: proc {is_file_path, is_file_handle}
|
||||||
is_dir :: proc {is_dir_path, is_dir_handle}
|
is_dir :: proc {is_dir_path, is_dir_handle}
|
||||||
|
|
||||||
|
exists :: proc(path: string) -> bool {
|
||||||
|
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
|
||||||
|
cpath := strings.clone_to_cstring(path, context.temp_allocator)
|
||||||
|
res := _unix_access(cpath, O_RDONLY)
|
||||||
|
return res == 0
|
||||||
|
}
|
||||||
|
|
||||||
// NOTE(bill): Uses startup to initialize it
|
// NOTE(bill): Uses startup to initialize it
|
||||||
|
|
||||||
stdin: Handle = 0
|
stdin: Handle = 0
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
//+build linux, darwin, freebsd, openbsd
|
//+build linux, darwin, freebsd, openbsd, netbsd
|
||||||
package filepath
|
package filepath
|
||||||
|
|
||||||
when ODIN_OS == .Darwin {
|
when ODIN_OS == .Darwin {
|
||||||
@@ -61,7 +61,7 @@ when ODIN_OS == .Darwin {
|
|||||||
foreign libc {
|
foreign libc {
|
||||||
@(link_name="__error") __error :: proc() -> ^i32 ---
|
@(link_name="__error") __error :: proc() -> ^i32 ---
|
||||||
}
|
}
|
||||||
} else when ODIN_OS == .OpenBSD {
|
} else when ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
|
||||||
@(private)
|
@(private)
|
||||||
foreign libc {
|
foreign libc {
|
||||||
@(link_name="__errno") __error :: proc() -> ^i32 ---
|
@(link_name="__errno") __error :: proc() -> ^i32 ---
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ SIG_BLOCK :: 1
|
|||||||
SIG_UNBLOCK :: 2
|
SIG_UNBLOCK :: 2
|
||||||
SIG_SETMASK :: 3
|
SIG_SETMASK :: 3
|
||||||
|
|
||||||
siginfo_t :: struct { si_pad: [128]c.char }
|
siginfo_t :: struct { _: [128]u8 }
|
||||||
sigset_t :: struct { bits: [4]u32 }
|
sigset_t :: struct { _: [4]u32 }
|
||||||
|
|
||||||
foreign libc {
|
foreign libc {
|
||||||
@(link_name="__sigemptyset14") sigemptyset :: proc(set: ^sigset_t) -> c.int ---
|
@(link_name="__sigemptyset14") sigemptyset :: proc(set: ^sigset_t) -> c.int ---
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ Thread_Os_Specific :: struct #align(16) {
|
|||||||
// It then waits for `start` to be called.
|
// It then waits for `start` to be called.
|
||||||
//
|
//
|
||||||
_create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
_create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||||
__linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
|
__unix_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
|
||||||
t := (^Thread)(t)
|
t := (^Thread)(t)
|
||||||
|
|
||||||
when ODIN_OS != .Darwin {
|
when ODIN_OS != .Darwin {
|
||||||
@@ -109,7 +109,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
|||||||
assert(res == 0)
|
assert(res == 0)
|
||||||
|
|
||||||
thread.procedure = procedure
|
thread.procedure = procedure
|
||||||
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
|
if unix.pthread_create(&thread.unix_thread, &attrs, __unix_thread_entry_proc, thread) != 0 {
|
||||||
free(thread, thread.creation_allocator)
|
free(thread, thread.creation_allocator)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user