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