aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-07-10 16:33:35 +0400
committerDmitry Antipov2014-07-10 16:33:35 +0400
commit9242810cd3bb14056dde937fc9ad39fc49261dfd (patch)
treeabd85cf5087ecbb123c3a511d78244fc9d069482 /src
parent80fb41cd90467782f4cfb21074aaa4f95308985e (diff)
downloademacs-9242810cd3bb14056dde937fc9ad39fc49261dfd.tar.gz
emacs-9242810cd3bb14056dde937fc9ad39fc49261dfd.zip
* configure.ac: Check whether sys/sysinfo.h provides
Linux 'sysinfo' function and 'struct sysinfo' type. * src/alloc.c (Fmemory_info): New function. * lisp/files.el (warn-maybe-out-of-memory): New function. (find-file-noselect): Use it.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog2
-rw-r--r--src/alloc.c33
2 files changed, 34 insertions, 1 deletions
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
122014-07-09 Paul Eggert <eggert@cs.ucla.edu> 142014-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 6872DEFUN ("memory-info", Fmemory_info, Smemory_info, 0, 0, 0,
6873 doc: /* Return a list of (TOTAL-RAM FREE-RAM TOTAL-SWAP FREE-SWAP).
6874All values are in Kbytes. If there is no swap space, last two
6875values 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
6871DEFUN ("memory-limit", Fmemory_limit, Smemory_limit, 0, 0, 0, 6901DEFUN ("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