From fa404e98df7ca6c0645f54c6a37c613ba3c3257d Mon Sep 17 00:00:00 2001 From: Yu Qing Date: Fri, 19 Feb 2016 14:56:38 +0800 Subject: [PATCH] add macro HAVE_USER_H --- make.sh | 8 +++++++- src/sockopt.c | 1 - src/system_info.c | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/make.sh b/make.sh index 1c6358e..7b1cacf 100755 --- a/make.sh +++ b/make.sh @@ -63,6 +63,7 @@ LIBS='-lm' uname=`uname` HAVE_VMMETER_H=0 +HAVE_USER_H=0 if [ "$uname" = "Linux" ]; then OS_NAME=OS_LINUX IOEVENT_USE=IOEVENT_USE_EPOLL @@ -77,6 +78,9 @@ elif [ "$uname" = "FreeBSD" ] || [ "$uname" = "Darwin" ]; then HAVE_VMMETER_H=1 fi + if [ -f /usr/include/sys/user.h ]; then + HAVE_USER_H=1 + fi elif [ "$uname" = "SunOS" ]; then OS_NAME=OS_SUNOS IOEVENT_USE=IOEVENT_USE_PORT @@ -115,10 +119,12 @@ cat < src/_os_define.h #define HAVE_VMMETER_H $HAVE_VMMETER_H #endif +#ifndef HAVE_USER_H +#define HAVE_USER_H $HAVE_USER_H +#endif #endif EOF - if [ -f /usr/lib/libpthread.so ] || [ -f /usr/local/lib/libpthread.so ] || [ -f /usr/lib64/libpthread.so ] || [ -f /usr/lib/libpthread.a ] || [ -f /usr/local/lib/libpthread.a ] || [ -f /usr/lib64/libpthread.a ]; then LIBS="$LIBS -lpthread" elif [ -f /usr/lib/libc_r.so ]; then diff --git a/src/sockopt.c b/src/sockopt.c index 4335ba3..4519d1b 100644 --- a/src/sockopt.c +++ b/src/sockopt.c @@ -1994,7 +1994,6 @@ int getifconfigs(FastIFConfig *if_configs, const int max_count, int *count) freeifaddrs(ifc1); - printf ("count: %d\n", *count); for (i=0; i<*count; i++) { getifmac(if_configs + i); diff --git a/src/system_info.c b/src/system_info.c index 774a7eb..4e55336 100644 --- a/src/system_info.c +++ b/src/system_info.c @@ -31,7 +31,10 @@ #ifdef OS_FREEBSD #include #include + +#if HAVE_USER_H == 1 #include +#endif #if HAVE_VMMETER_H == 1 #include @@ -765,8 +768,11 @@ int get_sysinfo(struct fast_sysinfo*info) } else { - info->freeram = vm.t_free; - info->sharedram = vm.t_rmshr; + int page_size; + + page_size = sysconf(_SC_PAGESIZE); + info->freeram = vm.t_free * page_size; + info->sharedram = vm.t_rmshr * page_size; //info->bufferram = vm. //TODO: } #endif