master xplshn/aruu / cmd / pseudo / pagesize.c
 1/* See LICENSE file for copyright and license details. */
 2
 3#include <stdio.h>
 4#include <stdlib.h>
 5#include <unistd.h>
 6
 7#include "util.h"
 8
 9static void
10usage(void)
11{
12  eprintf("usage: %s\n", argv0);
13}
14
15// ?man pagesize: print system page size
16// ?man display the size of a page in memory
17int
18main(int argc, char *argv[])
19{
20  long pagesz;
21
22  ARGBEGIN
23  {
24    default:
25      usage();
26  }
27  ARGEND;
28
29  pagesz = sysconf(_SC_PAGESIZE);
30  if (pagesz <= 0) {
31    pagesz = sysconf(_SC_PAGE_SIZE);
32    if (pagesz <= 0)
33      eprintf("can't determine pagesize\n");
34  }
35  printf("%ld\n", pagesz);
36  return 0;
37}