Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated for version 7.0-236

  • Loading branch information...
commit 6868c77bc327e4c0b1bc0ac3696054d6c82fc9a0 1 parent a107458
vimboss authored
View
56 src/auto/configure
@@ -13688,6 +13688,62 @@ 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 <sys/types.h>
+#include <sys/sysinfo.h>
+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
+
echo "$as_me:$LINENO: checking for sysconf" >&5
echo $ECHO_N "checking for sysconf... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
View
1  src/config.h.in
@@ -176,6 +176,7 @@
#undef HAVE_SYSCONF
#undef HAVE_SYSCTL
#undef HAVE_SYSINFO
+#undef HAVE_SYSINFO_MEM_UNIT
#undef HAVE_TGETENT
#undef HAVE_TOWLOWER
#undef HAVE_TOWUPPER
View
11 src/configure.in
@@ -2590,6 +2590,17 @@ AC_TRY_COMPILE(
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 <sys/types.h>
+#include <sys/sysinfo.h>],
+[ 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)
AC_TRY_COMPILE(
View
2  src/option.c
@@ -3030,7 +3030,7 @@ set_init_1()
#else
# ifdef HAVE_TOTAL_MEM
/* Use amount of memory available to Vim. */
- n = (mch_total_mem(FALSE) >> 11);
+ n = (mch_total_mem(FALSE) >> 1);
# else
n = (0x7fffffff >> 11);
# endif
View
38 src/os_unix.c
@@ -428,8 +428,8 @@ mch_char_avail()
# endif
/*
- * Return total amount of memory available. Doesn't change when memory has
- * been allocated.
+ * Return total amount of memory available in Kbyte.
+ * Doesn't change when memory has been allocated.
*/
/* ARGSUSED */
long_u
@@ -437,9 +437,10 @@ mch_total_mem(special)
int special;
{
# ifdef __EMX__
- return ulimit(3, 0L); /* always 32MB? */
+ return ulimit(3, 0L) >> 10; /* always 32MB? */
# else
long_u mem = 0;
+ long_u shiftright = 10; /* how much to shift "mem" right for Kbyte */
# ifdef HAVE_SYSCTL
int mib[2], physmem;
@@ -460,7 +461,19 @@ mch_total_mem(special)
/* Linux way of getting amount of RAM available */
if (sysinfo(&sinfo) == 0)
+ {
+# ifdef HAVE_SYSINFO_MEM_UNIT
+ /* avoid overflow as much as possible */
+ while (shiftright > 0 && (sinfo.mem_unit & 1) == 0)
+ {
+ sinfo.mem_unit = sinfo.mem_unit >> 1;
+ --shiftright;
+ }
+ mem = sinfo.totalram * sinfo.mem_unit;
+# else
mem = sinfo.totalram;
+# endif
+ }
}
# endif
@@ -473,7 +486,15 @@ mch_total_mem(special)
pagesize = sysconf(_SC_PAGESIZE);
pagecount = sysconf(_SC_PHYS_PAGES);
if (pagesize > 0 && pagecount > 0)
+ {
+ /* avoid overflow as much as possible */
+ while (shiftright > 0 && (pagesize & 1) == 0)
+ {
+ pagesize = pagesize >> 1;
+ --shiftright;
+ }
mem = (long_u)pagesize * pagecount;
+ }
}
# endif
@@ -488,15 +509,18 @@ mch_total_mem(special)
# ifdef RLIM_INFINITY
&& rlp.rlim_cur != RLIM_INFINITY
# endif
- && (long_u)rlp.rlim_cur < mem
+ && ((long_u)rlp.rlim_cur >> 10) < (mem >> shiftright)
)
- return (long_u)rlp.rlim_cur;
+ {
+ mem = (long_u)rlp.rlim_cur;
+ shiftright = 10;
+ }
}
# endif
if (mem > 0)
- return mem;
- return (long_u)0x7fffffff;
+ return mem >> shiftright;
+ return (long_u)0x1fffff;
# endif
}
#endif
View
2  src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 236,
+/**/
235,
/**/
234,
Please sign in to comment.
Something went wrong with that request. Please try again.