diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | configure.ac | 16 | ||||
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/files.el | 19 | ||||
| -rw-r--r-- | src/ChangeLog | 2 | ||||
| -rw-r--r-- | src/alloc.c | 33 |
6 files changed, 78 insertions, 2 deletions
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-07-10 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * configure.ac: Check whether sys/sysinfo.h provides | ||
| 4 | Linux 'sysinfo' function and 'struct sysinfo' type. | ||
| 5 | |||
| 1 | 2014-06-28 Glenn Morris <rgm@gnu.org> | 6 | 2014-06-28 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * configure.ac (lwlib_deps_frag, oldxmenu_deps_frag): New output files. | 8 | * configure.ac (lwlib_deps_frag, oldxmenu_deps_frag): New output files. |
diff --git a/configure.ac b/configure.ac index 04c75e30df8..fc7a87a075a 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -1510,6 +1510,7 @@ fi | |||
| 1510 | dnl checks for header files | 1510 | dnl checks for header files |
| 1511 | AC_CHECK_HEADERS_ONCE( | 1511 | AC_CHECK_HEADERS_ONCE( |
| 1512 | sys/systeminfo.h | 1512 | sys/systeminfo.h |
| 1513 | sys/sysinfo.h | ||
| 1513 | coff.h pty.h | 1514 | coff.h pty.h |
| 1514 | sys/resource.h | 1515 | sys/resource.h |
| 1515 | sys/utsname.h pwd.h utmp.h util.h) | 1516 | sys/utsname.h pwd.h utmp.h util.h) |
| @@ -1525,6 +1526,21 @@ if test $emacs_cv_personality_linux32 = yes; then | |||
| 1525 | [Define to 1 if personality LINUX32 can be set.]) | 1526 | [Define to 1 if personality LINUX32 can be set.]) |
| 1526 | fi | 1527 | fi |
| 1527 | 1528 | ||
| 1529 | if test "$ac_cv_header_sys_sysinfo_h" = yes; then | ||
| 1530 | AC_MSG_CHECKING([if Linux sysinfo may be used]) | ||
| 1531 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]], | ||
| 1532 | [[struct sysinfo si; sysinfo (&si)]])], | ||
| 1533 | emacs_cv_linux_sysinfo=yes, emacs_cv_linux_sysinfo=no) | ||
| 1534 | AC_MSG_RESULT($emacs_cv_linux_sysinfo) | ||
| 1535 | if test $emacs_cv_linux_sysinfo = yes; then | ||
| 1536 | AC_DEFINE([HAVE_LINUX_SYSINFO], 1, [Define to 1 if you have Linux sysinfo function.]) | ||
| 1537 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/sysinfo.h>]], | ||
| 1538 | [[struct sysinfo si; return si.mem_unit]])], | ||
| 1539 | AC_DEFINE(LINUX_SYSINFO_UNIT, 1, | ||
| 1540 | [Define to 1 if Linux sysinfo sizes are in multiples of mem_unit bytes.])) | ||
| 1541 | fi | ||
| 1542 | fi | ||
| 1543 | |||
| 1528 | dnl On Solaris 8 there's a compilation warning for term.h because | 1544 | dnl On Solaris 8 there's a compilation warning for term.h because |
| 1529 | dnl it doesn't define `bool'. | 1545 | dnl it doesn't define `bool'. |
| 1530 | AC_CHECK_HEADERS(term.h, , , -) | 1546 | AC_CHECK_HEADERS(term.h, , , -) |
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d14a3a8584b..ffb1eee945e 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2014-07-10 Dmitry Antipov <dmantipov@yandex.ru> | ||
| 2 | |||
| 3 | * files.el (warn-maybe-out-of-memory): New function. | ||
| 4 | (find-file-noselect): Use it. | ||
| 5 | |||
| 1 | 2014-07-09 Sam Steingold <sds@gnu.org> | 6 | 2014-07-09 Sam Steingold <sds@gnu.org> |
| 2 | 7 | ||
| 3 | * progmodes/cperl-mode.el (cperl-block-p): Treat the perl keyword | 8 | * progmodes/cperl-mode.el (cperl-block-p): Treat the perl keyword |
diff --git a/lisp/files.el b/lisp/files.el index 27d3ec7464e..63bdf636b63 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -1796,6 +1796,22 @@ OP-TYPE specifies the file operation being performed (for message to user)." | |||
| 1796 | (file-size-human-readable size) op-type)))) | 1796 | (file-size-human-readable size) op-type)))) |
| 1797 | (error "Aborted"))) | 1797 | (error "Aborted"))) |
| 1798 | 1798 | ||
| 1799 | (defun warn-maybe-out-of-memory (size) | ||
| 1800 | "Warn if an attempt to open file of SIZE bytes may run out of memory." | ||
| 1801 | (let ((meminfo (memory-info))) | ||
| 1802 | (when (consp meminfo) | ||
| 1803 | (let ((total-free-memory (+ (nth 1 meminfo) (nth 3 meminfo)))) | ||
| 1804 | (when (and (not (zerop size)) | ||
| 1805 | (> (/ size 1024) total-free-memory)) | ||
| 1806 | (warn | ||
| 1807 | "You are trying to open file which size (%s) | ||
| 1808 | exceeds an amount of available free memory (%s). If that | ||
| 1809 | fails, try to open it with `find-file-literally' (but note | ||
| 1810 | that some characters may be displayed incorrectly)." | ||
| 1811 | (file-size-human-readable size) | ||
| 1812 | (file-size-human-readable | ||
| 1813 | (* (float total-free-memory) 1024)))))))) | ||
| 1814 | |||
| 1799 | (defun find-file-noselect (filename &optional nowarn rawfile wildcards) | 1815 | (defun find-file-noselect (filename &optional nowarn rawfile wildcards) |
| 1800 | "Read file FILENAME into a buffer and return the buffer. | 1816 | "Read file FILENAME into a buffer and return the buffer. |
| 1801 | If a buffer exists visiting FILENAME, return that one, but | 1817 | If a buffer exists visiting FILENAME, return that one, but |
| @@ -1848,7 +1864,8 @@ the various files." | |||
| 1848 | (setq buf other)))) | 1864 | (setq buf other)))) |
| 1849 | ;; Check to see if the file looks uncommonly large. | 1865 | ;; Check to see if the file looks uncommonly large. |
| 1850 | (when (not (or buf nowarn)) | 1866 | (when (not (or buf nowarn)) |
| 1851 | (abort-if-file-too-large (nth 7 attributes) "open" filename)) | 1867 | (abort-if-file-too-large (nth 7 attributes) "open" filename) |
| 1868 | (warn-maybe-out-of-memory (nth 7 attributes))) | ||
| 1852 | (if buf | 1869 | (if buf |
| 1853 | ;; We are using an existing buffer. | 1870 | ;; We are using an existing buffer. |
| 1854 | (let (nonexistent) | 1871 | (let (nonexistent) |
diff --git a/src/ChangeLog b/src/ChangeLog index 541697c5567..87a8f1c7814 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | (decode_coding_big5, decode_coding_charset, decode_coding) | 9 | (decode_coding_big5, decode_coding_charset, decode_coding) |
| 10 | (encode_coding): Adjust users. | 10 | (encode_coding): Adjust users. |
| 11 | 11 | ||
| 12 | * alloc.c (Fmemory_info): New function. | ||
| 13 | |||
| 12 | 2014-07-09 Paul Eggert <eggert@cs.ucla.edu> | 14 | 2014-07-09 Paul Eggert <eggert@cs.ucla.edu> |
| 13 | 15 | ||
| 14 | * syntax.c (back_comment): Use more-natural location for label. | 16 | * syntax.c (back_comment): Use more-natural location for label. |
diff --git a/src/alloc.c b/src/alloc.c index 6eb2e756ed1..c535e836397 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -49,6 +49,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 49 | #include <verify.h> | 49 | #include <verify.h> |
| 50 | #include <execinfo.h> /* For backtrace. */ | 50 | #include <execinfo.h> /* For backtrace. */ |
| 51 | 51 | ||
| 52 | #ifdef HAVE_LINUX_SYSINFO | ||
| 53 | #include <sys/sysinfo.h> | ||
| 54 | #endif | ||
| 55 | |||
| 52 | #if (defined ENABLE_CHECKING \ | 56 | #if (defined ENABLE_CHECKING \ |
| 53 | && defined HAVE_VALGRIND_VALGRIND_H \ | 57 | && defined HAVE_VALGRIND_VALGRIND_H \ |
| 54 | && !defined USE_VALGRIND) | 58 | && !defined USE_VALGRIND) |
| @@ -6865,7 +6869,33 @@ gc_sweep (void) | |||
| 6865 | check_string_bytes (!noninteractive); | 6869 | check_string_bytes (!noninteractive); |
| 6866 | } | 6870 | } |
| 6867 | 6871 | ||
| 6868 | 6872 | DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0, | |
| 6873 | doc: /* Return a list of (TOTAL-RAM FREE-RAM TOTAL-SWAP FREE-SWAP). | ||
| 6874 | All values are in Kbytes. If there is no swap space, last two | ||
| 6875 | values are zero. If the system is not supported, return nil. */) | ||
| 6876 | (void) | ||
| 6877 | { | ||
| 6878 | #ifdef HAVE_LINUX_SYSINFO | ||
| 6879 | struct sysinfo si; | ||
| 6880 | uintmax_t units; | ||
| 6881 | |||
| 6882 | if (sysinfo (&si)) | ||
| 6883 | emacs_abort (); | ||
| 6884 | #ifdef LINUX_SYSINFO_UNIT | ||
| 6885 | units = si.mem_unit; | ||
| 6886 | #else | ||
| 6887 | units = 1; | ||
| 6888 | #endif | ||
| 6889 | return list4i ((uintmax_t) si.totalram * units / 1024, | ||
| 6890 | (uintmax_t) si.freeram * units / 1024, | ||
| 6891 | (uintmax_t) si.totalswap * units / 1024, | ||
| 6892 | (uintmax_t) si.freeswap * units / 1024); | ||
| 6893 | #else /* not HAVE_LINUX_SYSINFO */ | ||
| 6894 | /* FIXME: add more systems. */ | ||
| 6895 | return Qnil; | ||
| 6896 | #endif /* HAVE_LINUX_SYSINFO */ | ||
| 6897 | } | ||
| 6898 | |||
| 6869 | /* Debugging aids. */ | 6899 | /* Debugging aids. */ |
| 6870 | 6900 | ||
| 6871 | DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, | 6901 | DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, |
| @@ -7204,6 +7234,7 @@ The time is in seconds as a floating point value. */); | |||
| 7204 | defsubr (&Spurecopy); | 7234 | defsubr (&Spurecopy); |
| 7205 | defsubr (&Sgarbage_collect); | 7235 | defsubr (&Sgarbage_collect); |
| 7206 | defsubr (&Smemory_limit); | 7236 | defsubr (&Smemory_limit); |
| 7237 | defsubr (&Smemory_info); | ||
| 7207 | defsubr (&Smemory_use_counts); | 7238 | defsubr (&Smemory_use_counts); |
| 7208 | defsubr (&Ssuspicious_object); | 7239 | defsubr (&Ssuspicious_object); |
| 7209 | 7240 | ||