From b625c597e7b48a98547153c645bdd4d29dccfdbb Mon Sep 17 00:00:00 2001 From: "J.W. Jagersma" Date: Fri, 18 Mar 2022 15:47:41 +0100 Subject: [PATCH] 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. --- src/os.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/os.cc b/src/os.cc index faa84c49..75656ded 100644 --- a/src/os.cc +++ b/src/os.cc @@ -51,6 +51,10 @@ # include #endif +#ifdef DJGPP +# include +#endif + #ifdef fileno # undef fileno #endif @@ -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"));