ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

pagesize.c (484B)


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