Skip to content

Commit

Permalink
Merging branch/2023-03-04/getpagesize-vs-sysconf for GitHub pull requ…
Browse files Browse the repository at this point in the history
…est #188 <#188>.
  • Loading branch information
rptb1 committed Mar 23, 2023
2 parents 5fba2a8 + 2191f3c commit 179341b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 5 additions & 4 deletions code/vmix.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <signal.h> /* sig_atomic_t */
#include <sys/mman.h> /* see .feature.li in config.h */
#include <sys/types.h> /* mmap, munmap */
#include <unistd.h> /* getpagesize */
#include <unistd.h> /* sysconf, _SC_PAGESIZE */

SRCID(vmix, "$Id$");

Expand All @@ -59,10 +59,11 @@ SRCID(vmix, "$Id$");

Size PageSize(void)
{
int pageSize;
long pageSize;

/* Find out the operating system page size */
pageSize = getpagesize();
/* Find out the operating system page size
(see design.mps.vm.impl.ix.page.size) */
pageSize = sysconf(_SC_PAGESIZE);

/* Check the page size will fit in a Size. */
AVER((unsigned long)pageSize <= (unsigned long)(Size)-1);
Expand Down
8 changes: 7 additions & 1 deletion design/vm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,13 @@ Unix implementation

_`.impl.ix`: In ``vmix.c``.

_`.impl.ix.page.size`: The page size is given by ``getpagesize()``.
_`.impl.ix.page.size`: The page size is given by
``sysconf(_SC_PAGESIZE)``. We avoid ``getpagesize()``, which is a
legacy function in Posix:

Applications should use the sysconf() function instead.

— `The Single UNIX ® Specification, Version 2 <https://pubs.opengroup.org/onlinepubs/7908799/xsh/getpagesize.html>`__

_`.impl.ix.param`: Decodes no keyword arguments.

Expand Down

0 comments on commit 179341b

Please sign in to comment.