Patch 7.0.236
Problem:Linux 2.4 uses sysinfo() with a mem_unit field, which is not
backwards compatible.
Solution: Add an autoconf check for sysinfo.mem_unit. Let mch_total_mem()
return Kbyte to avoid overflow.
Files: src/auto/configure, src/configure.in, src/config.h.in,
src/option.c, src/os_unix.c
*** ../vim-7.0.235/src/auto/configure Tue Oct 17 11:50:45 2006
--- src/auto/configure Thu Apr 26 16:44:07 2007
***
*** 13685,13690
--- 13685,13746
echo "$as_me:$LINENO: result: not usable" >&5
echo "${ECHO_T}not usable" >&6
+ fi
+ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+ echo "$as_me:$LINENO: checking for sysinfo.mem_unit" >&5
+ echo $ECHO_N "checking for sysinfo.mem_unit... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h. */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h. */
+ #include
+ #include
+ int
+ main ()
+ {
+ struct sysinfo sinfo;
+ sinfo.mem_unit = 1;
+
+ ;
+ return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&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); } &&
+{ ac_try='test -z "$ac_c_werror_flag"
+|| test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+{ ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ echo "$as_me:$LINENO: result: yes" >&5
+ echo "${ECHO_T}yes" >&6; cat >>confdefs.h <<\_ACEOF
+ #define HAVE_SYSINFO_MEM_UNIT 1
+ _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 conftest.err conftest.$ac_objext conftest.$ac_ext
*** ../vim-7.0.235/src/configure.in Tue Oct 17 11:50:45 2006
--- src/configure.inThu Apr 26 16:40:18 2007
***
*** 2589,2594
--- 2589,2605
],
AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
AC_MSG_RESULT(not usable))
+
+ dnl struct sysinfo may have the mem_unit field or not
+ AC_MSG_CHECKING(for sysinfo.mem_unit)
+ AC_TRY_COMPILE(
+ [#include
+ #include ],
+ [ struct sysinfo sinfo;
+ sinfo.mem_unit = 1;
+ ],
+ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO_MEM_UNIT),
+ AC_MSG_RESULT(no))
dnl sysconf() may exist but not support what we want to use
AC_MSG_CHECKING(for sysconf)
*** ../vim-7.0.235/src/config.h.in Fri Apr 21 00:11:09 2006
--- src/config.h.in Thu Apr 26 16:40:34 2007
***
*** 176,181
--- 176,182
#undef HAVE_SYSCONF
#undef HAVE_SYSCTL
#undef HAVE_SYSINFO
+ #undef HAVE_SYSINFO_MEM_UNIT
#undef HAVE_TGETENT
#undef HAVE_TOWLOWER
#undef HAVE_TOWUPPER
*** ../vim-7.0.235/src/option.c Fri Mar 2 20:00:06 2007
--- src/option.cTue May 1 13:26:10 2007
***
*** 3030,3036
#else
# ifdef HAVE_TOTAL_MEM
/* Use amount of memory available to Vim. */
! n = (mch_total_mem(FALSE) >> 11);
# else
n = (0x7fff >> 11);
# endif
--- 3030,3036
#else
# ifdef HAVE_TOTAL_MEM
/* Use amount of memory available to Vim. */
! n = (mch_total_mem(FALSE) >> 1);
# else
n = (0x7fff >> 11);
# endif
*** ../vim-7.0.235/src/os_unix.cThu Apr 26 16:28:43 2007
--- src/os_unix.c Thu Apr 26 16:37:43 2007
***
*** 428,435
# endif
/*
! * Return total amount of memory available. Doesn't change when memory has
! * been allocated.
*/
/* ARGSUSED */
long_u
--- 428,435
# endif
/*
! * Return total amount of memory available in Kbyte.
! * Doesn't change when memory has been allocated.
*/
/* ARGSUSED */
long_u
***
*** 437,445
int special;
{
# ifdef __EMX__
! return ulimit(3, 0L); /* always 32MB? */
# else
long_umem = 0;
# ifdef HAVE_SYSCTL
int mib[2], physmem;
--- 437,446
in