diff options
Diffstat (limited to 'src/alloc.c')
| -rw-r--r-- | src/alloc.c | 33 |
1 files changed, 32 insertions, 1 deletions
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 | ||