add macro HAVE_VMMETER_H

pull/10/head
Yu Qing 2016-02-18 16:52:56 +08:00
parent 9f8acd52e9
commit f4313d4669
3 changed files with 18 additions and 2 deletions

10
make.sh
View File

@ -62,6 +62,7 @@ fi
LIBS='-lm'
uname=`uname`
HAVE_VMMETER_H=0
if [ "$uname" = "Linux" ]; then
OS_NAME=OS_LINUX
IOEVENT_USE=IOEVENT_USE_EPOLL
@ -71,6 +72,11 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then
if [ "$uname" = "Darwin" ]; then
CFLAGS="$CFLAGS -DDARWIN"
fi
if [ -f /usr/include/sys/vmmeter.h ]; then
HAVE_VMMETER_H=1
fi
elif [ "$uname" = "SunOS" ]; then
OS_NAME=OS_SUNOS
IOEVENT_USE=IOEVENT_USE_PORT
@ -105,6 +111,10 @@ cat <<EOF > src/_os_define.h
#define $IOEVENT_USE 1
#endif
#ifndef HAVE_VMMETER_H
#define HAVE_VMMETER_H $HAVE_VMMETER_H
#endif
#endif
EOF

View File

@ -44,8 +44,6 @@
#include <sys/sysctl.h>
#include <sys/uio.h>
#include <net/if_dl.h>
#include <netinet/if_ether.h>
#include <net/route.h>
#endif
#endif

View File

@ -31,7 +31,11 @@
#ifdef OS_FREEBSD
#include <sys/sysctl.h>
#include <sys/ucred.h>
#if HAVE_VMMETER_H == 1
#include <sys/vmmeter.h>
#endif
#endif
#endif
@ -681,7 +685,9 @@ int get_sysinfo(struct fast_sysinfo*info)
int mib[4];
size_t size;
struct loadavg loads;
#if HAVE_VMMETER_H == 1
struct vmtotal vm;
#endif
struct xsw_usage sw_usage;
memset(info, 0, sizeof(struct fast_sysinfo));
@ -723,6 +729,7 @@ int get_sysinfo(struct fast_sysinfo*info)
get_sys_total_mem_size((int64_t *)&info->totalram);
#if HAVE_VMMETER_H == 1
mib[0] = CTL_VM;
mib[1] = VM_METER;
size = sizeof(vm);
@ -739,6 +746,7 @@ int get_sysinfo(struct fast_sysinfo*info)
info->sharedram = vm.t_rmshr;
//info->bufferram = vm. //TODO:
}
#endif
mib[0] = CTL_VM;
mib[1] = VM_SWAPUSAGE;