mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 21:10:30 +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
|
||||
|
||||
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_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
|
||||
|
||||
stdin: Handle = 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//+build linux, darwin, freebsd, openbsd
|
||||
//+build linux, darwin, freebsd, openbsd, netbsd
|
||||
package filepath
|
||||
|
||||
when ODIN_OS == .Darwin {
|
||||
@@ -61,7 +61,7 @@ when ODIN_OS == .Darwin {
|
||||
foreign libc {
|
||||
@(link_name="__error") __error :: proc() -> ^i32 ---
|
||||
}
|
||||
} else when ODIN_OS == .OpenBSD {
|
||||
} else when ODIN_OS == .OpenBSD || ODIN_OS == .NetBSD {
|
||||
@(private)
|
||||
foreign libc {
|
||||
@(link_name="__errno") __error :: proc() -> ^i32 ---
|
||||
|
||||
@@ -13,8 +13,8 @@ SIG_BLOCK :: 1
|
||||
SIG_UNBLOCK :: 2
|
||||
SIG_SETMASK :: 3
|
||||
|
||||
siginfo_t :: struct { si_pad: [128]c.char }
|
||||
sigset_t :: struct { bits: [4]u32 }
|
||||
siginfo_t :: struct { _: [128]u8 }
|
||||
sigset_t :: struct { _: [4]u32 }
|
||||
|
||||
foreign libc {
|
||||
@(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.
|
||||
//
|
||||
_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)
|
||||
|
||||
when ODIN_OS != .Darwin {
|
||||
@@ -109,7 +109,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
|
||||
assert(res == 0)
|
||||
|
||||
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)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user