Index: configure
===================================================================
--- configure	(revision 129044)
+++ configure	(working copy)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 127017 .
+# From configure.ac Revision: 127767 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.6.
 #
@@ -31189,6 +31189,76 @@
     fi
 
 
+    if test "x${PBX_SYSINFO_MEMUNIT}" != "x1" -a "${USE_SYSINFO_MEMUNIT}" != "no"; then
+	{ echo "$as_me:$LINENO: checking if \"struct sysinfo si; si.mem_unit;\" compiles using sys/sysinfo.h" >&5
+echo $ECHO_N "checking if \"struct sysinfo si; si.mem_unit;\" compiles using sys/sysinfo.h... $ECHO_C" >&6; }
+	saved_cppflags="${CPPFLAGS}"
+	if test "x${SYSINFO_MEMUNIT_DIR}" != "x"; then
+	    SYSINFO_MEMUNIT_INCLUDE="-I${SYSINFO_MEMUNIT_DIR}/include"
+	fi
+	CPPFLAGS="${CPPFLAGS} ${SYSINFO_MEMUNIT_INCLUDE}"
+
+	cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/sysinfo.h>
+int
+main ()
+{
+ struct sysinfo si; si.mem_unit;;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+     { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+		PBX_SYSINFO_MEMUNIT=1
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYSINFO_MEMUNIT 1
+_ACEOF
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_SYSINFO_MEMUNIT_VERSION
+_ACEOF
+
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	       { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+	CPPFLAGS="${saved_cppflags}"
+    fi
+
+
 GSM_INTERNAL="yes"
 
 GSM_SYSTEM="yes"
Index: configure.ac
===================================================================
--- configure.ac	(revision 129044)
+++ configure.ac	(working copy)
@@ -603,6 +603,7 @@
 AST_EXT_LIB_CHECK([CEIL], [m], [ceil])
 
 AST_C_COMPILE_CHECK([GETIFADDRS], [struct ifaddrs *p; getifaddrs(&p)], [ifaddrs.h])
+AST_C_COMPILE_CHECK([SYSINFO_MEMUNIT], [struct sysinfo si; si.mem_unit;], [sys/sysinfo.h])
 
 GSM_INTERNAL="yes"
 AC_SUBST(GSM_INTERNAL)
Index: include/asterisk/autoconfig.h.in
===================================================================
--- include/asterisk/autoconfig.h.in	(revision 129044)
+++ include/asterisk/autoconfig.h.in	(working copy)
@@ -892,6 +892,12 @@
 /* Define to 1 if your system has sysinfo support */
 #undef HAVE_SYSINFO
 
+/* Define if your system has the SYSINFO_MEMUNIT headers. */
+#undef HAVE_SYSINFO_MEMUNIT
+
+/* Define SYSINFO_MEMUNIT headers version */
+#undef HAVE_SYSINFO_MEMUNIT_VERSION
+
 /* Define to 1 if you have the <syslog.h> header file. */
 #undef HAVE_SYSLOG_H
 
Index: main/asterisk.c
===================================================================
--- main/asterisk.c	(revision 129044)
+++ main/asterisk.c	(working copy)
@@ -484,6 +484,16 @@
 }
 
 #if defined(HAVE_SYSINFO)
+/*!
+ * This defines a SYSINFO_BYTES macro that ensures we
+ * get the correct number of bytes for sysinfo on kernels
+ * < 2.3.23 on i386 or < 2.3.48 for all other archs
+ */
+#  ifdef HAVE_SYSINFO_MEMUNIT
+#    define SYSINFO_BYTES(a) ((sys_info.a * sys_info.mem_unit) >> 10)
+#  else
+#    define SYSINFO_BYTES(a) (a >> 10)
+#  endif
 /*! \brief Give an overview of system statistics */
 static char *handle_show_sysinfo(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
@@ -502,17 +512,19 @@
 		ast_cli(a->fd, "FAILED to retrieve system information\n\n");
 		return CLI_FAILURE;
 	}
+
 	ast_cli(a->fd, "\nSystem Statistics\n");
 	ast_cli(a->fd, "-----------------\n");
 	ast_cli(a->fd, "  System Uptime:             %ld hours\n", sys_info.uptime/3600);
-	ast_cli(a->fd, "  Total RAM:                 %ld KiB\n", (sys_info.totalram / sys_info.mem_unit)/1024);
-	ast_cli(a->fd, "  Free RAM:                  %ld KiB\n", (sys_info.freeram / sys_info.mem_unit)/1024);
-	ast_cli(a->fd, "  Buffer RAM:                %ld KiB\n", (sys_info.bufferram / sys_info.mem_unit)/1024);
-	ast_cli(a->fd, "  Total Swap Space:          %ld KiB\n", (sys_info.totalswap / sys_info.mem_unit)/1024);
-	ast_cli(a->fd, "  Free Swap Space:           %ld KiB\n\n", (sys_info.freeswap / sys_info.mem_unit)/1024);
+	ast_cli(a->fd, "  Total RAM:                 %ld KiB\n", SYSINFO_BYTES(totalram));
+	ast_cli(a->fd, "  Free RAM:                  %ld KiB\n", SYSINFO_BYTES(freeram));
+	ast_cli(a->fd, "  Buffer RAM:                %ld KiB\n", SYSINFO_BYTES(bufferram));
+	ast_cli(a->fd, "  Total Swap Space:          %ld KiB\n", SYSINFO_BYTES(totalswap));
+	ast_cli(a->fd, "  Free Swap Space:           %ld KiB\n\n", SYSINFO_BYTES(freeswap));
 	ast_cli(a->fd, "  Number of Processes:       %d \n\n", sys_info.procs);
 	return CLI_SUCCESS;
 }
+#undef SYSINFO_BYTES
 #endif
 
 struct profile_entry {
