Skip to content
This repository has been archived by the owner on May 4, 2018. It is now read-only.

Commit

Permalink
FreeBSD: Fix FreeBSD build.
Browse files Browse the repository at this point in the history
  • Loading branch information
okuoku authored and bnoordhuis committed Oct 6, 2011
1 parent 2726213 commit d1016de
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/unix/freebsd.c
Expand Up @@ -27,7 +27,9 @@
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <vm/vm_param.h> /* VM_LOADAVG */
#include <time.h>
#include <unistd.h> /* sysconf */

#undef NANOSEC
#define NANOSEC 1000000000
Expand Down Expand Up @@ -69,15 +71,15 @@ int uv_exepath(char* buffer, size_t* size) {
}

double uv_get_free_memory(void) {
vm_statistics_data_t info;
mach_msg_type_number_t count = sizeof(info) / sizeof(integer_t);
int freecount;
size_t size = sizeof(freecount);

if (host_statistics(mach_host_self(), HOST_VM_INFO,
(host_info_t)&info, &count) != KERN_SUCCESS) {
if(sysctlbyname("vm.stats.vm.v_free_count",
&freecount, &size, NULL, 0) == -1){
return -1;
}
return (double) freecount * sysconf(_SC_PAGESIZE);

return (double) info.free_count * sysconf(_SC_PAGESIZE);
}

double uv_get_total_memory(void) {
Expand Down

0 comments on commit d1016de

Please sign in to comment.