diff options
author | cee1 <fykcee1@gmail.com> | 2011-03-18 10:03:41 +0800 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-03-28 21:42:31 +0200 |
commit | 37f85e66e8f396b6f758e063531b95531aef628e (patch) | |
tree | 4c914f49c19d6712b76fc1be5f58929a2aa9d5bc /src/util.c | |
parent | f9276855a1d270b6c3f857cdaf2c4b49920c2228 (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.c | 14 |
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 */ |