summaryrefslogtreecommitdiff
path: root/src/arch/generic/lib.h
diff options
context:
space:
mode:
authorAmmar Faizi <ammarfaizi2@gnuweeb.org>2022-02-11 22:57:52 +0700
committerJens Axboe <axboe@kernel.dk>2022-02-11 09:36:16 -0700
commitc099b832a97dc1880b89734ef6a5420497a1be0f (patch)
tree678c09c507aa88dd6e5aff6b086739ac76cb103b /src/arch/generic/lib.h
parent8347a3d9553a2f31affddacb7bd9eaa14f2e7ed7 (diff)
downloadliburing-c099b832a97dc1880b89734ef6a5420497a1be0f.tar.gz
liburing-c099b832a97dc1880b89734ef6a5420497a1be0f.tar.bz2
lib.h: Split off lib header for arch specific and generic
1) Clean up #ifdef/#endif for get_page_size(). 2) Always use arch specific code for x86-64 to reduce libc usage. 3) For other archs, we will use src/arch/generic/lib.h header that contains libc wrapper. At this point, on x86-64, we only use libc for memset(), malloc() and free(). Cc: Nugra <richiisei@gmail.com> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Link: https://lore.kernel.org/r/20220211155753.143698-4-ammarfaizi2@gnuweeb.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'src/arch/generic/lib.h')
-rw-r--r--src/arch/generic/lib.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/arch/generic/lib.h b/src/arch/generic/lib.h
new file mode 100644
index 0000000..737e795
--- /dev/null
+++ b/src/arch/generic/lib.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef __INTERNAL__LIBURING_LIB_H
+ #error "This file should be included from src/lib.h (liburing)"
+#endif
+
+#ifndef LIBURING_ARCH_GENERIC_LIB_H
+#define LIBURING_ARCH_GENERIC_LIB_H
+
+static inline long get_page_size(void)
+{
+ long page_size;
+
+ page_size = sysconf(_SC_PAGESIZE);
+ if (page_size < 0)
+ page_size = 4096;
+
+ return page_size;
+}
+
+#endif /* #ifndef LIBURING_ARCH_GENERIC_LIB_H */