Implement getpagesize() for djgpp

This is the "correct" way to find the page size on DPMI.  In practice
though, this could be hardcoded to return 4096 and no one would ever
notice the difference.
This commit is contained in:
J.W. Jagersma 2022-03-18 15:47:41 +01:00
parent 8271e43e5e
commit b625c597e7
No known key found for this signature in database
GPG Key ID: 438BF81BA7510C54

View File

@ -51,6 +51,10 @@
# include <windows.h> # include <windows.h>
#endif #endif
#ifdef DJGPP
# include <dpmi.h>
#endif
#ifdef fileno #ifdef fileno
# undef fileno # undef fileno
#endif #endif
@ -354,6 +358,11 @@ long getpagesize() {
SYSTEM_INFO si; SYSTEM_INFO si;
GetSystemInfo(&si); GetSystemInfo(&si);
return si.dwPageSize; return si.dwPageSize;
# elif defined(DJGPP)
unsigned long size;
if (__dpmi_get_page_size(&size) != 0)
FMT_THROW(system_error(ENOSYS, "cannot get memory page size"));
return size;
# else # else
long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE)); long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));
if (size < 0) FMT_THROW(system_error(errno, "cannot get memory page size")); if (size < 0) FMT_THROW(system_error(errno, "cannot get memory page size"));