home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.264 < prev    next >
Encoding:
Internet Message Format  |  2002-02-21  |  11.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.264
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.264
  11. Problem:    The amount of virtual memory is used to initialize 'maxmemtot',
  12.         which may be much more than the amount of physical memory,
  13.         resulting in a lot of swapping.
  14. Solution:   Get the amount of physical memory with sysctl(), sysconf() or
  15.         sysinfo() when possible.
  16. Files:        src/auto/configure, src/configure.in, src/config.h.in,
  17.         src/os_unix.c, src/os_unix.h
  18.  
  19.  
  20. *** ../vim60.263/src/auto/configure    Fri Feb  1 20:29:26 2002
  21. --- src/auto/configure    Mon Feb  4 19:21:35 2002
  22. ***************
  23. *** 4698,4718 ****
  24.       sys/stream.h sys/ptem.h termios.h libc.h sys/statfs.h \
  25.       poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
  26.       libgen.h util/debug.h util/msg18n.h frame.h \
  27. !     sys/acl.h sys/access.h
  28.   do
  29.   ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  30.   echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
  31. ! echo "configure:4682: checking for $ac_hdr" >&5
  32.   if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
  33.     echo $ac_n "(cached) $ac_c" 1>&6
  34.   else
  35.     cat > conftest.$ac_ext <<EOF
  36. ! #line 4687 "configure"
  37.   #include "confdefs.h"
  38.   #include <$ac_hdr>
  39.   EOF
  40.   ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  41. ! { (eval echo configure:4692: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  42.   ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  43.   if test -z "$ac_err"; then
  44.     rm -rf conftest*
  45. --- 4698,4718 ----
  46.       sys/stream.h sys/ptem.h termios.h libc.h sys/statfs.h \
  47.       poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
  48.       libgen.h util/debug.h util/msg18n.h frame.h \
  49. !     sys/acl.h sys/access.h sys/sysctl.h sys/sysinfo.h
  50.   do
  51.   ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
  52.   echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
  53. ! echo "configure:4706: checking for $ac_hdr" >&5
  54.   if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
  55.     echo $ac_n "(cached) $ac_c" 1>&6
  56.   else
  57.     cat > conftest.$ac_ext <<EOF
  58. ! #line 4711 "configure"
  59.   #include "confdefs.h"
  60.   #include <$ac_hdr>
  61.   EOF
  62.   ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
  63. ! { (eval echo configure:4716: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
  64.   ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
  65.   if test -z "$ac_err"; then
  66.     rm -rf conftest*
  67. ***************
  68. *** 6249,6257 ****
  69.   fi
  70.   rm -f conftest*
  71.   
  72.   
  73.   echo $ac_n "checking size of int""... $ac_c" 1>&6
  74. ! echo "configure:6195: checking size of int" >&5
  75.   if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
  76.     echo $ac_n "(cached) $ac_c" 1>&6
  77.   else
  78. --- 6249,6345 ----
  79.   fi
  80.   rm -f conftest*
  81.   
  82. + echo $ac_n "checking for sysctl""... $ac_c" 1>&6
  83. + echo "configure:6254: checking for sysctl" >&5
  84. + cat > conftest.$ac_ext <<EOF
  85. + #line 6256 "configure"
  86. + #include "confdefs.h"
  87. + #include <sys/types.h>
  88. + #include <sys/sysctl.h>
  89. + int main() {
  90. +     int mib[2], r;
  91. +     size_t len;
  92. +     mib[0] = CTL_HW;
  93. +     mib[1] = HW_USERMEM;
  94. +     len = sizeof(r);
  95. +     (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
  96. +     
  97. + ; return 0; }
  98. + EOF
  99. + if { (eval echo configure:6271: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  100. +   rm -rf conftest*
  101. +   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
  102. + #define HAVE_SYSCTL 1
  103. + EOF
  104. + else
  105. +   echo "configure: failed program was:" >&5
  106. +   cat conftest.$ac_ext >&5
  107. +   rm -rf conftest*
  108. +   echo "$ac_t""not usable" 1>&6
  109. + fi
  110. + rm -f conftest*
  111. + echo $ac_n "checking for sysinfo""... $ac_c" 1>&6
  112. + echo "configure:6286: checking for sysinfo" >&5
  113. + cat > conftest.$ac_ext <<EOF
  114. + #line 6288 "configure"
  115. + #include "confdefs.h"
  116. + #include <sys/types.h>
  117. + #include <sys/sysinfo.h>
  118. + int main() {
  119. +     struct sysinfo sinfo;
  120. +     int t;
  121. +     (void)sysinfo(&sinfo);
  122. +     t = sinfo.totalram;
  123. +     
  124. + ; return 0; }
  125. + EOF
  126. + if { (eval echo configure:6301: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  127. +   rm -rf conftest*
  128. +   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
  129. + #define HAVE_SYSINFO 1
  130. + EOF
  131. + else
  132. +   echo "configure: failed program was:" >&5
  133. +   cat conftest.$ac_ext >&5
  134. +   rm -rf conftest*
  135. +   echo "$ac_t""not usable" 1>&6
  136. + fi
  137. + rm -f conftest*
  138. + echo $ac_n "checking for sysconf""... $ac_c" 1>&6
  139. + echo "configure:6316: checking for sysconf" >&5
  140. + cat > conftest.$ac_ext <<EOF
  141. + #line 6318 "configure"
  142. + #include "confdefs.h"
  143. + #include <unistd.h>
  144. + int main() {
  145. +     (void)sysconf(_SC_PAGESIZE);
  146. +     (void)sysconf(_SC_PHYS_PAGES);
  147. +     
  148. + ; return 0; }
  149. + EOF
  150. + if { (eval echo configure:6327: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
  151. +   rm -rf conftest*
  152. +   echo "$ac_t""yes" 1>&6; cat >> confdefs.h <<\EOF
  153. + #define HAVE_SYSCONF 1
  154. + EOF
  155. + else
  156. +   echo "configure: failed program was:" >&5
  157. +   cat conftest.$ac_ext >&5
  158. +   rm -rf conftest*
  159. +   echo "$ac_t""not usable" 1>&6
  160. + fi
  161. + rm -f conftest*
  162.   
  163.   echo $ac_n "checking size of int""... $ac_c" 1>&6
  164. ! echo "configure:6343: checking size of int" >&5
  165.   if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
  166.     echo $ac_n "(cached) $ac_c" 1>&6
  167.   else
  168. *** ../vim60.263/src/configure.in    Fri Feb  1 20:29:26 2002
  169. --- src/configure.in    Mon Feb  4 19:20:25 2002
  170. ***************
  171. *** 1382,1388 ****
  172.       sys/stream.h sys/ptem.h termios.h libc.h sys/statfs.h \
  173.       poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
  174.       libgen.h util/debug.h util/msg18n.h frame.h \
  175. !     sys/acl.h sys/access.h)
  176.   
  177.   dnl Check if strings.h and string.h can both be included when defined.
  178.   AC_MSG_CHECKING([if strings.h can be included after string.h])
  179. --- 1382,1388 ----
  180.       sys/stream.h sys/ptem.h termios.h libc.h sys/statfs.h \
  181.       poll.h sys/poll.h pwd.h utime.h sys/param.h libintl.h \
  182.       libgen.h util/debug.h util/msg18n.h frame.h \
  183. !     sys/acl.h sys/access.h sys/sysctl.h sys/sysinfo.h)
  184.   
  185.   dnl Check if strings.h and string.h can both be included when defined.
  186.   AC_MSG_CHECKING([if strings.h can be included after string.h])
  187. ***************
  188. *** 1842,1847 ****
  189. --- 1842,1887 ----
  190.   AC_TRY_LINK([#include <stdio.h>], [rename("this", "that")],
  191.       AC_MSG_RESULT(yes); AC_DEFINE(HAVE_RENAME),
  192.       AC_MSG_RESULT(no))
  193. + dnl sysctl() may exist but not the arguments we use
  194. + AC_MSG_CHECKING(for sysctl)
  195. + AC_TRY_COMPILE(
  196. + [#include <sys/types.h>
  197. + #include <sys/sysctl.h>],
  198. + [    int mib[2], r;
  199. +     size_t len;
  200. +     mib[0] = CTL_HW;
  201. +     mib[1] = HW_USERMEM;
  202. +     len = sizeof(r);
  203. +     (void)sysctl(mib, 2, &r, &len, (void *)0, (size_t)0);
  204. +     ],
  205. +     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL),
  206. +     AC_MSG_RESULT(not usable))
  207. + dnl sysinfo() may exist but not be Linux compatible
  208. + AC_MSG_CHECKING(for sysinfo)
  209. + AC_TRY_COMPILE(
  210. + [#include <sys/types.h>
  211. + #include <sys/sysinfo.h>],
  212. + [    struct sysinfo sinfo;
  213. +     int t;
  214. +     (void)sysinfo(&sinfo);
  215. +     t = sinfo.totalram;
  216. +     ],
  217. +     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSINFO),
  218. +     AC_MSG_RESULT(not usable))
  219. + dnl sysconf() may exist but not support what we want to use
  220. + AC_MSG_CHECKING(for sysconf)
  221. + AC_TRY_COMPILE(
  222. + [#include <unistd.h>],
  223. + [    (void)sysconf(_SC_PAGESIZE);
  224. +     (void)sysconf(_SC_PHYS_PAGES);
  225. +     ],
  226. +     AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCONF),
  227. +     AC_MSG_RESULT(not usable))
  228.   
  229.   dnl Our own version of AC_CHECK_SIZEOF(int); fixes a bug when sizeof() can't
  230.   dnl be printed with "%d", and avoids a warning for cross-compiling.
  231. *** ../vim60.263/src/config.h.in    Tue Jan 22 15:38:17 2002
  232. --- src/config.h.in    Mon Feb  4 14:51:51 2002
  233. ***************
  234. *** 176,181 ****
  235. --- 176,184 ----
  236.   #undef HAVE_STRPBRK
  237.   #undef HAVE_STRTOL
  238.   #undef HAVE_ST_BLKSIZE
  239. + #undef HAVE_SYSCONF
  240. + #undef HAVE_SYSCTL
  241. + #undef HAVE_SYSINFO
  242.   #undef HAVE_TGETENT
  243.   #undef HAVE_USLEEP
  244.   #undef HAVE_UTIME
  245. ***************
  246. *** 202,209 ****
  247.   #undef HAVE_SGTTY_H
  248.   #undef HAVE_STRINGS_H
  249.   #undef HAVE_STROPTS_H
  250. - #undef HAVE_SYS_ACL_H
  251.   #undef HAVE_SYS_ACCESS_H
  252.   #undef HAVE_SYS_DIR_H
  253.   #undef HAVE_SYS_IOCTL_H
  254.   #undef HAVE_SYS_NDIR_H
  255. --- 205,212 ----
  256.   #undef HAVE_SGTTY_H
  257.   #undef HAVE_STRINGS_H
  258.   #undef HAVE_STROPTS_H
  259.   #undef HAVE_SYS_ACCESS_H
  260. + #undef HAVE_SYS_ACL_H
  261.   #undef HAVE_SYS_DIR_H
  262.   #undef HAVE_SYS_IOCTL_H
  263.   #undef HAVE_SYS_NDIR_H
  264. ***************
  265. *** 214,219 ****
  266. --- 217,224 ----
  267.   #undef HAVE_SYS_SELECT_H
  268.   #undef HAVE_SYS_STATFS_H
  269.   #undef HAVE_SYS_STREAM_H
  270. + #undef HAVE_SYS_SYSCTL_H
  271. + #undef HAVE_SYS_SYSINFO_H
  272.   #undef HAVE_SYS_SYSTEMINFO_H
  273.   #undef HAVE_SYS_TIME_H
  274.   #undef HAVE_SYS_UTSNAME_H
  275. *** ../vim60.263/src/os_unix.c    Thu Feb 21 19:20:14 2002
  276. --- src/os_unix.c    Thu Feb 21 19:07:10 2002
  277. ***************
  278. *** 412,417 ****
  279. --- 412,423 ----
  280.   # ifdef HAVE_SYS_RESOURCE_H
  281.   #  include <sys/resource.h>
  282.   # endif
  283. + # ifdef HAVE_SYS_SYSCTL_H
  284. + #  include <sys/sysctl.h>
  285. + # endif
  286. + # ifdef HAVE_SYS_SYSINFO_H
  287. + #  include <sys/sysinfo.h>
  288. + # endif
  289.   
  290.   /*
  291.    * Return total amount of memory available.  Doesn't change when memory has
  292. ***************
  293. *** 425,439 ****
  294.   # ifdef __EMX__
  295.       return ulimit(3, 0L);   /* always 32MB? */
  296.   # else
  297. !     struct rlimit    rlp;
  298.   
  299. !     if (getrlimit(RLIMIT_DATA, &rlp) == 0
  300. !         && rlp.rlim_cur < ((rlim_t)1 << (sizeof(long_u) * 8 - 1))
  301. ! #  ifdef RLIM_INFINITY
  302. !         && rlp.rlim_cur != RLIM_INFINITY
  303.   #  endif
  304. !         )
  305. !     return (long_u)rlp.rlim_cur;
  306.       return (long_u)0x7fffffff;
  307.   # endif
  308.   }
  309. --- 431,493 ----
  310.   # ifdef __EMX__
  311.       return ulimit(3, 0L);   /* always 32MB? */
  312.   # else
  313. !     long_u    mem = 0;
  314.   
  315. ! #  ifdef HAVE_SYSCTL
  316. !     int        mib[2], physmem;
  317. !     size_t    len;
  318. !     /* BSD way of getting the amount of RAM available. */
  319. !     mib[0] = CTL_HW;
  320. !     mib[1] = HW_USERMEM;
  321. !     len = sizeof(physmem);
  322. !     if (sysctl(mib, 2, &physmem, &len, NULL, 0) == 0)
  323. !     mem = (long_u)physmem;
  324.   #  endif
  325. ! #  if defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)
  326. !     if (mem == 0)
  327. !     {
  328. !     struct sysinfo sinfo;
  329. !     /* Linux way of getting amount of RAM available */
  330. !     if (sysinfo(&sinfo) == 0)
  331. !         mem = sinfo.totalram;
  332. !     }
  333. ! #  endif
  334. ! #  ifdef HAVE_SYSCONF
  335. !     if (mem == 0)
  336. !     {
  337. !     long        pagesize, pagecount;
  338. !     /* Solaris way of getting amount of RAM available */
  339. !     pagesize = sysconf(_SC_PAGESIZE);
  340. !     pagecount = sysconf(_SC_PHYS_PAGES);
  341. !     if (pagesize > 0 && pagecount > 0)
  342. !         mem = (long_u)pagesize * pagecount;
  343. !     }
  344. ! #  endif
  345. !     /* Return the minimum of the physical memory and the user limit, because
  346. !      * using more than the user limit may cause Vim to be terminated. */
  347. ! #  if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)
  348. !     {
  349. !     struct rlimit    rlp;
  350. !     if (getrlimit(RLIMIT_DATA, &rlp) == 0
  351. !         && rlp.rlim_cur < ((rlim_t)1 << (sizeof(long_u) * 8 - 1))
  352. ! #   ifdef RLIM_INFINITY
  353. !         && rlp.rlim_cur != RLIM_INFINITY
  354. ! #   endif
  355. !         && (long_u)rlp.rlim_cur < mem
  356. !        )
  357. !         return (long_u)rlp.rlim_cur;
  358. !     }
  359. ! #  endif
  360. !     if (mem > 0)
  361. !     return mem;
  362.       return (long_u)0x7fffffff;
  363.   # endif
  364.   }
  365. *** ../vim60.263/src/os_unix.h    Sun Sep 30 10:50:44 2001
  366. --- src/os_unix.h    Mon Feb  4 15:03:27 2002
  367. ***************
  368. *** 190,196 ****
  369.   # undef __ARGS
  370.   #endif
  371.   
  372. ! #if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)
  373.   # define HAVE_TOTAL_MEM
  374.   #endif
  375.   
  376. --- 190,198 ----
  377.   # undef __ARGS
  378.   #endif
  379.   
  380. ! #if (defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_GETRLIMIT)) \
  381. !     || (defined(HAVE_SYS_SYSINFO_H) && defined(HAVE_SYSINFO)) \
  382. !     || defined(HAVE_SYSCTL) || defined(HAVE_SYSCONF)
  383.   # define HAVE_TOTAL_MEM
  384.   #endif
  385.   
  386. *** ../vim60.263/src/version.c    Fri Feb 22 19:48:33 2002
  387. --- src/version.c    Fri Feb 22 19:48:58 2002
  388. ***************
  389. *** 608,609 ****
  390. --- 608,611 ----
  391.   {   /* Add new patch number below this line */
  392. + /**/
  393. +     264,
  394.   /**/
  395.  
  396. -- 
  397. hundred-and-one symptoms of being an internet addict:
  398. 2. You kiss your girlfriend's home page.
  399.  
  400.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  401. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  402. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  403.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  404.