mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-17 22:09:26 -04:00
`process_wait` (optionally prefaced with a `process_kill`) can be used to properly close and free resources of the process. `process_terminate` was added because `process_kill` is a forceful exit, we were missing a way to request the process to terminate.
35 lines
700 B
Odin
35 lines
700 B
Odin
#+private
|
|
#+build freebsd
|
|
package os
|
|
|
|
foreign import libc "system:c"
|
|
foreign import dl "system:dl"
|
|
|
|
foreign libc {
|
|
@(link_name="sysctlbyname")
|
|
_sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> i32 ---
|
|
}
|
|
|
|
foreign dl {
|
|
@(link_name="pthread_getthreadid_np")
|
|
pthread_getthreadid_np :: proc() -> i32 ---
|
|
}
|
|
|
|
@(require_results)
|
|
_get_current_thread_id :: proc "contextless" () -> int {
|
|
return int(pthread_getthreadid_np())
|
|
}
|
|
|
|
@(require_results)
|
|
_get_processor_core_count :: proc() -> int {
|
|
count : int = 0
|
|
count_size := size_of(count)
|
|
if _sysctlbyname("hw.ncpu", &count, &count_size, nil, 0) == 0 {
|
|
if count > 0 {
|
|
return count
|
|
}
|
|
}
|
|
|
|
return 1
|
|
}
|