Add OS/2-specific code to physmem.h.

Also move DJGPP-specific code near the code meant
for other DOS-like systems.
This commit is contained in:
Lasse Collin 2009-09-05 18:39:21 +03:00
parent 7aca7b3174
commit 429910b2ba
1 changed files with 21 additions and 11 deletions

View File

@ -22,6 +22,13 @@
# endif # endif
# include <windows.h> # include <windows.h>
#elif defined(__OS2__)
# define INCL_DOSMISC
# include <os2.h>
#elif defined(__DJGPP__)
# include <dpmi.h>
#elif defined(HAVE_PHYSMEM_SYSCONF) #elif defined(HAVE_PHYSMEM_SYSCONF)
# include <unistd.h> # include <unistd.h>
@ -35,9 +42,6 @@
#elif defined(HAVE_PHYSMEM_SYSINFO) #elif defined(HAVE_PHYSMEM_SYSINFO)
# include <sys/sysinfo.h> # include <sys/sysinfo.h>
#elif defined(__DJGPP__)
# include <dpmi.h>
#endif #endif
@ -79,6 +83,20 @@ physmem(void)
ret = meminfo.dwTotalPhys; ret = meminfo.dwTotalPhys;
} }
#elif defined(__OS2__)
unsigned long mem;
if (DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,
&mem, sizeof(mem)) == 0)
ret = mem;
#elif defined(__DJGPP__)
__dpmi_free_mem_info meminfo;
if (__dpmi_get_free_memory_information(&meminfo) == 0
&& meminfo.total_number_of_physical_pages
!= (unsigned long)(-1))
ret = (uint64_t)(meminfo.total_number_of_physical_pages)
* 4096;
#elif defined(HAVE_PHYSMEM_SYSCONF) #elif defined(HAVE_PHYSMEM_SYSCONF)
const long pagesize = sysconf(_SC_PAGESIZE); const long pagesize = sysconf(_SC_PAGESIZE);
const long pages = sysconf(_SC_PHYS_PAGES); const long pages = sysconf(_SC_PHYS_PAGES);
@ -118,14 +136,6 @@ physmem(void)
struct sysinfo si; struct sysinfo si;
if (sysinfo(&si) == 0) if (sysinfo(&si) == 0)
ret = (uint64_t)(si.totalram) * si.mem_unit; ret = (uint64_t)(si.totalram) * si.mem_unit;
#elif defined(__DJGPP__)
__dpmi_free_mem_info meminfo;
if (__dpmi_get_free_memory_information(&meminfo) == 0
&& meminfo.total_number_of_physical_pages
!= (unsigned long)(-1))
ret = (uint64_t)(meminfo.total_number_of_physical_pages)
* 4096;
#endif #endif
return ret; return ret;