aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-07-11 13:09:51 +0300
committerEli Zaretskii2014-07-11 13:09:51 +0300
commit5f7c30e757680f66be9ef4c399fd1d7ce5b66203 (patch)
treea7a1c1806020f496dc2948622a6e43b8b06df4cf /src
parent8f4fc468ca50120c2218f74555301d68004d8217 (diff)
downloademacs-5f7c30e757680f66be9ef4c399fd1d7ce5b66203.tar.gz
emacs-5f7c30e757680f66be9ef4c399fd1d7ce5b66203.zip
Implement memory-info for MS-DOS.
src/dosfns.c (dos_memory_info): New function. src/dosfns.h (dos_memory_info): Add prototype. src/alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info. src/vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead of doing some of its job.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/alloc.c19
-rw-r--r--src/dosfns.c42
-rw-r--r--src/dosfns.h3
-rw-r--r--src/vm-limit.c29
5 files changed, 73 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 1e0a3a92f5d..e469880a4ce 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,12 @@
12014-07-11 Eli Zaretskii <eliz@gnu.org> 12014-07-11 Eli Zaretskii <eliz@gnu.org>
2 2
3 Implement memory-info for MS-DOS.
4 * dosfns.c (dos_memory_info): New function.
5 * dosfns.h (dos_memory_info): Add prototype.
6 * alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info.
7 * vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead
8 of doing some of its job.
9
3 * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't 10 * minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't
4 reference termios structure members. 11 reference termios structure members.
5 12
diff --git a/src/alloc.c b/src/alloc.c
index 4a912703c39..77be94d73d1 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -53,6 +53,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
53#include <sys/sysinfo.h> 53#include <sys/sysinfo.h>
54#endif 54#endif
55 55
56#ifdef MSDOS
57#include "dosfns.h" /* For dos_memory_info. */
58#endif
59
56#if (defined ENABLE_CHECKING \ 60#if (defined ENABLE_CHECKING \
57 && defined HAVE_VALGRIND_VALGRIND_H \ 61 && defined HAVE_VALGRIND_VALGRIND_H \
58 && !defined USE_VALGRIND) 62 && !defined USE_VALGRIND)
@@ -6900,10 +6904,21 @@ values are zero. If the system is not supported, return nil. */)
6900 (uintmax_t) freeswap / 1024); 6904 (uintmax_t) freeswap / 1024);
6901 else 6905 else
6902 return Qnil; 6906 return Qnil;
6903#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT */ 6907#elif defined MSDOS
6908 unsigned long totalram, freeram, totalswap, freeswap;
6909
6910 if (dos_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0)
6911 return list4i ((uintmax_t) totalram / 1024,
6912 (uintmax_t) freeram / 1024,
6913 (uintmax_t) totalswap / 1024,
6914 (uintmax_t) freeswap / 1024);
6915 else
6916 return Qnil;
6917}
6918#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */
6904 /* FIXME: add more systems. */ 6919 /* FIXME: add more systems. */
6905 return Qnil; 6920 return Qnil;
6906#endif /* HAVE_LINUX_SYSINFO */ 6921#endif /* HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */
6907} 6922}
6908 6923
6909/* Debugging aids. */ 6924/* Debugging aids. */
diff --git a/src/dosfns.c b/src/dosfns.c
index baa0358d725..e557dcba022 100644
--- a/src/dosfns.c
+++ b/src/dosfns.c
@@ -641,6 +641,48 @@ system_process_attributes (Lisp_Object pid)
641 return attrs; 641 return attrs;
642} 642}
643 643
644/* Support for memory-info. */
645int
646dos_memory_info (unsigned long *totalram, unsigned long *freeram,
647 unsigned long *totalswap, unsigned long *freeswap)
648{
649 _go32_dpmi_meminfo info;
650 unsigned long mem1, mem2, freemem;
651
652 _go32_dpmi_get_free_memory_information (&info);
653 /* DPMI server of Windows NT and its descendants reports in
654 info.available_memory a much lower amount that is really
655 available, which causes bogus "past 95% of memory limit"
656 warnings. Try to overcome that via circumstantial evidence. */
657 mem1 = info.available_memory;
658 mem2 = info.available_physical_pages;
659 /* DPMI Spec: "Fields that are unavailable will hold -1." */
660 if ((long)mem1 == -1L)
661 mem1 = 0;
662 if ((long)mem2 == -1L)
663 mem2 = 0;
664 else
665 mem2 *= 4096;
666 /* Surely, the available memory is at least what we have physically
667 available, right? */
668 if (mem1 >= mem2)
669 freemem = mem1;
670 else
671 freemem = mem2;
672 *freeram = freemem;
673 *totalswap =
674 ((long)info.max_pages_in_paging_file == -1L)
675 ? 0
676 : info.max_pages_in_paging_file * 4096;
677 *totalram =
678 ((long)info.total_physical_pages == -1L)
679 ? (freemem + (unsigned long)sbrk (0) + *totalswap)
680 : info.total_physical_pages * 4096;
681 *freeswap = 0;
682 return 0;
683}
684
685
644void 686void
645dos_cleanup (void) 687dos_cleanup (void)
646{ 688{
diff --git a/src/dosfns.h b/src/dosfns.h
index 3409b2247b7..f32e6342fc9 100644
--- a/src/dosfns.h
+++ b/src/dosfns.h
@@ -22,7 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#define DOS_COUNTRY_INFO 34 /* no of bytes returned by dos int 38h */ 23#define DOS_COUNTRY_INFO 34 /* no of bytes returned by dos int 38h */
24extern unsigned char dos_country_info[DOS_COUNTRY_INFO]; 24extern unsigned char dos_country_info[DOS_COUNTRY_INFO];
25 25extern int dos_memory_info (unsigned long *, unsigned long *,
26 unsigned long *, unsigned long *);
26#ifndef HAVE_X_WINDOWS 27#ifndef HAVE_X_WINDOWS
27extern int msdos_stdcolor_idx (const char *); 28extern int msdos_stdcolor_idx (const char *);
28extern Lisp_Object msdos_stdcolor_name (int); 29extern Lisp_Object msdos_stdcolor_name (int);
diff --git a/src/vm-limit.c b/src/vm-limit.c
index f138dc28b2e..308613f7eb4 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
21#include "lisp.h" 21#include "lisp.h"
22 22
23#ifdef MSDOS 23#ifdef MSDOS
24#include <dpmi.h> 24#include "dosfns.h"
25extern int etext; 25extern int etext;
26#endif 26#endif
27 27
@@ -106,29 +106,10 @@ get_lim_data (void)
106void 106void
107get_lim_data (void) 107get_lim_data (void)
108{ 108{
109 _go32_dpmi_meminfo info; 109 unsigned long totalram, freeram, totalswap, freeswap;
110 unsigned long lim1, lim2; 110
111 111 dos_memory_info (&totalram, &freeram, &totalswap, &freeswap);
112 _go32_dpmi_get_free_memory_information (&info); 112 lim_data = freeram;
113 /* DPMI server of Windows NT and its descendants reports in
114 info.available_memory a much lower amount that is really
115 available, which causes bogus "past 95% of memory limit"
116 warnings. Try to overcome that via circumstantial evidence. */
117 lim1 = info.available_memory;
118 lim2 = info.available_physical_pages;
119 /* DPMI Spec: "Fields that are unavailable will hold -1." */
120 if ((long)lim1 == -1L)
121 lim1 = 0;
122 if ((long)lim2 == -1L)
123 lim2 = 0;
124 else
125 lim2 *= 4096;
126 /* Surely, the available memory is at least what we have physically
127 available, right? */
128 if (lim1 >= lim2)
129 lim_data = lim1;
130 else
131 lim_data = lim2;
132 /* Don't believe they will give us more that 0.5 GB. */ 113 /* Don't believe they will give us more that 0.5 GB. */
133 if (lim_data > 512U * 1024U * 1024U) 114 if (lim_data > 512U * 1024U * 1024U)
134 lim_data = 512U * 1024U * 1024U; 115 lim_data = 512U * 1024U * 1024U;