summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorcee1 <fykcee1@gmail.com>2011-03-18 10:03:41 +0800
committerLennart Poettering <lennart@poettering.net>2011-03-28 21:42:31 +0200
commit37f85e66e8f396b6f758e063531b95531aef628e (patch)
tree4c914f49c19d6712b76fc1be5f58929a2aa9d5bc /src/util.c
parentf9276855a1d270b6c3f857cdaf2c4b49920c2228 (diff)
util: detect page size runtime.
Some architectures support multiple machine types with diffenent page sizes, and some machine types even support multiple page sizes themselves.
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 1febd073d2..fada69cf1a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -61,6 +61,20 @@
#include "exit-status.h"
#include "hashmap.h"
+size_t page_size(void) {
+ static __thread size_t pgsz = 0;
+ long r;
+
+ if (pgsz)
+ return pgsz;
+
+ assert_se((r = sysconf(_SC_PAGESIZE)) > 0);
+
+ pgsz = (size_t) r;
+
+ return pgsz;
+}
+
bool streq_ptr(const char *a, const char *b) {
/* Like streq(), but tries to make sense of NULL pointers */