[hackers] [ubase] Add pagesize(1) || sin

From: <git_AT_suckless.org>
Date: Tue, 29 Oct 2013 16:37:46 +0100

commit 97975ff092c1d7e4fc2d8dfec69641a236925d6e
Author: sin <sin_AT_2f30.org>
Date: Tue Oct 29 15:36:18 2013 +0000

    Add pagesize(1)
    
    This program is useful in constructing portable shell scripts.

diff --git a/Makefile b/Makefile
index cc09ded..753b227 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -32,6 +32,7 @@ SRC = \
         mkswap.c \
         mount.c \
         mountpoint.c \
+ pagesize.c \
         pidof.c \
         pivot_root.c \
         ps.c \
diff --git a/pagesize.c b/pagesize.c
new file mode 100644
index 0000000..ef70628
--- /dev/null
+++ b/pagesize.c
_AT_@ -0,0 +1,31 @@
+/* See LICENSE file for copyright and license details. */
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "util.h"
+
+static void
+usage(void)
+{
+ eprintf("usage: %s
", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+ long pagesz;
+
+ ARGBEGIN {
+ default:
+ usage();
+ } ARGEND;
+
+ pagesz = sysconf(_SC_PAGESIZE);
+ if (pagesz < 0) {
+ pagesz = sysconf(_SC_PAGE_SIZE);
+ if (pagesz < 0)
+ enprintf(EXIT_FAILURE, "can't determine pagesize
");
+ }
+ printf("%ld
", pagesz);
+ return EXIT_SUCCESS;
+}
Received on Tue Oct 29 2013 - 16:37:46 CET

This archive was generated by hypermail 2.3.0 : Tue Oct 29 2013 - 16:48:17 CET