1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

Revert "runtime: cleanup free_memory comptime conditional (#18968)"

This reverts commit 571469a6ac.
This commit is contained in:
Delyan Angelov 2023-07-26 09:01:37 +03:00
parent 571469a6ac
commit e03c0329c1
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 17 additions and 11 deletions

View File

@ -19,13 +19,16 @@ 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 {
mut hs := C.vm_statistics64_data_t{} $if macos {
mut vmsz := u32(C.HOST_VM_INFO64_COUNT) mut hs := C.vm_statistics64_data_t{}
mut hps := u32(0) mut vmsz := u32(C.HOST_VM_INFO64_COUNT)
mut host := C.mach_host_self() mut hps := u32(0)
unsafe { mut host := C.mach_host_self()
C.host_statistics64(host, C.HOST_VM_INFO64, &int(&hs), &vmsz) unsafe {
C.host_page_size(host, &C.vm_size_t(&hps)) C.host_statistics64(host, C.HOST_VM_INFO64, &int(&hs), &vmsz)
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
} }

View File

@ -1,7 +1,10 @@
module runtime module runtime
fn free_memory_impl() usize { fn free_memory_impl() usize {
page_size := usize(C.sysconf(C._SC_PAGESIZE)) $if linux {
av_phys_pages := usize(C.sysconf(C._SC_AVPHYS_PAGES)) page_size := usize(C.sysconf(C._SC_PAGESIZE))
return page_size * av_phys_pages av_phys_pages := usize(C.sysconf(C._SC_AVPHYS_PAGES))
return page_size * av_phys_pages
}
return 1
} }