blob: 45ca0317854116d0ded707d898761024e92f7a52 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#+private
#+build netbsd
package os
import "core:c"
foreign import libc "system:c"
@(private)
foreign libc {
_lwp_self :: proc() -> i32 ---
@(link_name="sysctlbyname")
_sysctlbyname :: proc(path: cstring, oldp: rawptr, oldlenp: rawptr, newp: rawptr, newlen: int) -> c.int ---
}
@(require_results)
_get_current_thread_id :: proc "contextless" () -> int {
return int(_lwp_self())
}
_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
}
|