mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
runtime: cleanup free_memory comptime conditional (#18968)
This commit is contained in:
parent
5ecbfb7bf1
commit
571469a6ac
@ -19,7 +19,6 @@ fn C.host_page_size(host C.host_t, out_page_size &C.vm_size_t) int
|
|||||||
fn C.host_statistics64(host C.host_t, flavor int, host_info_out &int, host_info_outCnt &u32) int
|
fn C.host_statistics64(host C.host_t, flavor int, host_info_out &int, host_info_outCnt &u32) int
|
||||||
|
|
||||||
fn free_memory_impl() usize {
|
fn free_memory_impl() usize {
|
||||||
$if macos {
|
|
||||||
mut hs := C.vm_statistics64_data_t{}
|
mut hs := C.vm_statistics64_data_t{}
|
||||||
mut vmsz := u32(C.HOST_VM_INFO64_COUNT)
|
mut vmsz := u32(C.HOST_VM_INFO64_COUNT)
|
||||||
mut hps := u32(0)
|
mut hps := u32(0)
|
||||||
@ -29,6 +28,4 @@ fn free_memory_impl() usize {
|
|||||||
C.host_page_size(host, &C.vm_size_t(&hps))
|
C.host_page_size(host, &C.vm_size_t(&hps))
|
||||||
}
|
}
|
||||||
return usize(u64(hs.free_count) * u64(hps))
|
return usize(u64(hs.free_count) * u64(hps))
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
module runtime
|
module runtime
|
||||||
|
|
||||||
fn free_memory_impl() usize {
|
fn free_memory_impl() usize {
|
||||||
$if linux {
|
|
||||||
page_size := usize(C.sysconf(C._SC_PAGESIZE))
|
page_size := usize(C.sysconf(C._SC_PAGESIZE))
|
||||||
av_phys_pages := usize(C.sysconf(C._SC_AVPHYS_PAGES))
|
av_phys_pages := usize(C.sysconf(C._SC_AVPHYS_PAGES))
|
||||||
return page_size * av_phys_pages
|
return page_size * av_phys_pages
|
||||||
}
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user