mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2025-01-14 16:50:58 +00:00
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.
This commit is contained in:
parent
8f4fc468ca
commit
5f7c30e757
@ -1,5 +1,12 @@
|
||||
2014-07-11 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
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.
|
||||
|
||||
|
19
src/alloc.c
19
src/alloc.c
@ -53,6 +53,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
#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 @@ values are zero. If the system is not supported, return nil. */)
|
||||
(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. */
|
||||
|
42
src/dosfns.c
42
src/dosfns.c
@ -640,6 +640,48 @@ system_process_attributes (Lisp_Object pid)
|
||||
|
||||
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)
|
||||
|
@ -22,7 +22,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#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);
|
||||
|
@ -21,7 +21,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
|
||||
#include "lisp.h"
|
||||
|
||||
#ifdef MSDOS
|
||||
#include <dpmi.h>
|
||||
#include "dosfns.h"
|
||||
extern int etext;
|
||||
#endif
|
||||
|
||||
@ -106,29 +106,10 @@ get_lim_data (void)
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user