[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] trunk r117514: Implement memory-info for MS-DOS.
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] trunk r117514: Implement memory-info for MS-DOS. |
Date: |
Fri, 11 Jul 2014 10:10:22 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 117514
revision-id: address@hidden
parent: address@hidden
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Fri 2014-07-11 13:09:51 +0300
message:
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.
modified:
src/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1438
src/alloc.c alloc.c-20091113204419-o5vbwnq5f7feedwu-252
src/dosfns.c dosfns.c-20091113204419-o5vbwnq5f7feedwu-653
src/dosfns.h dosfns.h-20091113204419-o5vbwnq5f7feedwu-654
src/vm-limit.c vmlimit.c-20091113204419-o5vbwnq5f7feedwu-488
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2014-07-11 09:56:58 +0000
+++ b/src/ChangeLog 2014-07-11 10:09:51 +0000
@@ -1,5 +1,12 @@
2014-07-11 Eli Zaretskii <address@hidden>
+ Implement memory-info for MS-DOS.
+ * dosfns.c (dos_memory_info): New function.
+ * dosfns.h (dos_memory_info): Add prototype.
+ * alloc.c (Fmemory_info) [MSDOS]: Call dos_memory_info.
+ * vm-limit.c (get_lim_data) [MSDOS]: Call dos_memory_info, instead
+ of doing some of its job.
+
* minibuf.c (read_minibuf_noninteractive) [WINDOWSNT]: Don't
reference termios structure members.
=== modified file 'src/alloc.c'
--- a/src/alloc.c 2014-07-10 19:09:26 +0000
+++ b/src/alloc.c 2014-07-11 10:09:51 +0000
@@ -53,6 +53,10 @@
#include <sys/sysinfo.h>
#endif
+#ifdef MSDOS
+#include "dosfns.h" /* For dos_memory_info. */
+#endif
+
#if (defined ENABLE_CHECKING \
&& defined HAVE_VALGRIND_VALGRIND_H \
&& !defined USE_VALGRIND)
@@ -6900,10 +6904,21 @@
(uintmax_t) freeswap / 1024);
else
return Qnil;
-#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT */
+#elif defined MSDOS
+ unsigned long totalram, freeram, totalswap, freeswap;
+
+ if (dos_memory_info (&totalram, &freeram, &totalswap, &freeswap) == 0)
+ return list4i ((uintmax_t) totalram / 1024,
+ (uintmax_t) freeram / 1024,
+ (uintmax_t) totalswap / 1024,
+ (uintmax_t) freeswap / 1024);
+ else
+ return Qnil;
+}
+#else /* not HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */
/* FIXME: add more systems. */
return Qnil;
-#endif /* HAVE_LINUX_SYSINFO */
+#endif /* HAVE_LINUX_SYSINFO, not WINDOWSNT, not MSDOS */
}
/* Debugging aids. */
=== modified file 'src/dosfns.c'
--- a/src/dosfns.c 2014-04-03 20:46:04 +0000
+++ b/src/dosfns.c 2014-07-11 10:09:51 +0000
@@ -641,6 +641,48 @@
return attrs;
}
+/* Support for memory-info. */
+int
+dos_memory_info (unsigned long *totalram, unsigned long *freeram,
+ unsigned long *totalswap, unsigned long *freeswap)
+{
+ _go32_dpmi_meminfo info;
+ unsigned long mem1, mem2, freemem;
+
+ _go32_dpmi_get_free_memory_information (&info);
+ /* DPMI server of Windows NT and its descendants reports in
+ info.available_memory a much lower amount that is really
+ available, which causes bogus "past 95% of memory limit"
+ warnings. Try to overcome that via circumstantial evidence. */
+ mem1 = info.available_memory;
+ mem2 = info.available_physical_pages;
+ /* DPMI Spec: "Fields that are unavailable will hold -1." */
+ if ((long)mem1 == -1L)
+ mem1 = 0;
+ if ((long)mem2 == -1L)
+ mem2 = 0;
+ else
+ mem2 *= 4096;
+ /* Surely, the available memory is at least what we have physically
+ available, right? */
+ if (mem1 >= mem2)
+ freemem = mem1;
+ else
+ freemem = mem2;
+ *freeram = freemem;
+ *totalswap =
+ ((long)info.max_pages_in_paging_file == -1L)
+ ? 0
+ : info.max_pages_in_paging_file * 4096;
+ *totalram =
+ ((long)info.total_physical_pages == -1L)
+ ? (freemem + (unsigned long)sbrk (0) + *totalswap)
+ : info.total_physical_pages * 4096;
+ *freeswap = 0;
+ return 0;
+}
+
+
void
dos_cleanup (void)
{
=== modified file 'src/dosfns.h'
--- a/src/dosfns.h 2014-01-01 07:43:34 +0000
+++ b/src/dosfns.h 2014-07-11 10:09:51 +0000
@@ -22,7 +22,8 @@
#define DOS_COUNTRY_INFO 34 /* no of bytes returned by dos int 38h */
extern unsigned char dos_country_info[DOS_COUNTRY_INFO];
-
+extern int dos_memory_info (unsigned long *, unsigned long *,
+ unsigned long *, unsigned long *);
#ifndef HAVE_X_WINDOWS
extern int msdos_stdcolor_idx (const char *);
extern Lisp_Object msdos_stdcolor_name (int);
=== modified file 'src/vm-limit.c'
--- a/src/vm-limit.c 2014-04-16 15:16:35 +0000
+++ b/src/vm-limit.c 2014-07-11 10:09:51 +0000
@@ -21,7 +21,7 @@
#include "lisp.h"
#ifdef MSDOS
-#include <dpmi.h>
+#include "dosfns.h"
extern int etext;
#endif
@@ -106,29 +106,10 @@
void
get_lim_data (void)
{
- _go32_dpmi_meminfo info;
- unsigned long lim1, lim2;
+ unsigned long totalram, freeram, totalswap, freeswap;
- _go32_dpmi_get_free_memory_information (&info);
- /* DPMI server of Windows NT and its descendants reports in
- info.available_memory a much lower amount that is really
- available, which causes bogus "past 95% of memory limit"
- warnings. Try to overcome that via circumstantial evidence. */
- lim1 = info.available_memory;
- lim2 = info.available_physical_pages;
- /* DPMI Spec: "Fields that are unavailable will hold -1." */
- if ((long)lim1 == -1L)
- lim1 = 0;
- if ((long)lim2 == -1L)
- lim2 = 0;
- else
- lim2 *= 4096;
- /* Surely, the available memory is at least what we have physically
- available, right? */
- if (lim1 >= lim2)
- lim_data = lim1;
- else
- lim_data = lim2;
+ dos_memory_info (&totalram, &freeram, &totalswap, &freeswap);
+ lim_data = freeram;
/* Don't believe they will give us more that 0.5 GB. */
if (lim_data > 512U * 1024U * 1024U)
lim_data = 512U * 1024U * 1024U;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] trunk r117514: Implement memory-info for MS-DOS.,
Eli Zaretskii <=