[PATCH 03/12] util: Introduce l_util_pagesize
Denis Kenzior <[email protected]> Mon, 22 Jul 2024 14:04:20 -0500
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
---
ell/ell.sym | 1 +
ell/util.c | 12 ++++++++++++
ell/util.h | 2 ++
3 files changed, 15 insertions(+)
diff --git a/ell/ell.sym b/ell/ell.sym
index 9fcc3aad9a2f..bc0c6e10ebca 100644
--- a/ell/ell.sym
+++ b/ell/ell.sym
@@ -23,6 +23,7 @@ global:
l_util_hexdumpv;
l_util_debug;
l_util_get_debugfs_path;
+ l_util_pagesize;
l_memeq;
l_secure_memeq;
l_safe_atox8;
diff --git a/ell/util.c b/ell/util.c
index 549e253eefc0..45ec6c8110bc 100644
--- a/ell/util.c
+++ b/ell/util.c
@@ -15,6 +15,7 @@
#include <limits.h>
#include <stdint.h>
#include <errno.h>
+#include <unistd.h>
#include "utf8.h"
#include "util.h"
@@ -812,3 +813,14 @@ LIB_EXPORT int l_safe_atox32(const char *s, uint32_t *out_x)
return safe_atou(s, 16, out_x);
}
+
+LIB_EXPORT size_t l_util_pagesize(void)
+{
+ static size_t page_size = 0;
+
+ if (likely(page_size > 0))
+ return page_size;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ return page_size;
+}
diff --git a/ell/util.h b/ell/util.h
index f4fc4d1143e3..c56f182292fa 100644
--- a/ell/util.h
+++ b/ell/util.h
@@ -515,6 +515,8 @@ int l_safe_atox32(const char *s, uint32_t *out_u);
int l_safe_atox16(const char *s, uint16_t *out_u);
int l_safe_atox8(const char *s, uint8_t *out_u);
+size_t l_util_pagesize(void);
+
#ifdef __cplusplus
}
#endif
--
2.45.2