mirror of
https://github.com/vlang/v.git
synced 2025-09-08 14:51:53 -04:00
This commit is contained in:
parent
1d700bef99
commit
7549020d1f
22
vlib/runtime/free_memory_impl_freebsd.c.v
Normal file
22
vlib/runtime/free_memory_impl_freebsd.c.v
Normal file
@ -0,0 +1,22 @@
|
||||
module runtime
|
||||
|
||||
fn C.sysctlnametomib(name charptr, mib &int, len &usize) int
|
||||
|
||||
fn free_memory_impl() usize {
|
||||
$if cross ? {
|
||||
return 1
|
||||
}
|
||||
$if !cross ? {
|
||||
$if freebsd {
|
||||
page_size := usize(C.sysconf(C._SC_PAGESIZE))
|
||||
mut mib := [4]int{}
|
||||
mut len := usize(4)
|
||||
unsafe { C.sysctlnametomib(c'vm.stats.vm.v_free_count', &mib[0], &len) }
|
||||
mut free_pages := int(0)
|
||||
bufsize := usize(4)
|
||||
unsafe { C.sysctl(&mib[0], mib.len, &free_pages, &bufsize, 0, 0) }
|
||||
return page_size * usize(free_pages)
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user