Skip to content

Commit

Permalink
Implement getpagesize() for djgpp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jwt27 committed Mar 21, 2022
1 parent 8271e43 commit 910adb5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/os.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
# include <windows.h>
#endif

#ifdef DJGPP
# include <dpmi.h>
#endif

#ifdef fileno
# undef fileno
#endif
Expand Down Expand Up @@ -354,6 +358,11 @@ long getpagesize() {
SYSTEM_INFO si;
GetSystemInfo(&si);
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
long size = FMT_POSIX_CALL(sysconf(_SC_PAGESIZE));
if (size < 0) FMT_THROW(system_error(errno, "cannot get memory page size"));
Expand Down

0 comments on commit 910adb5

Please sign in to comment.