summaryrefslogtreecommitdiffstats
path: root/src/posix/system_posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/posix/system_posix.c')
-rw-r--r--src/posix/system_posix.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/posix/system_posix.c b/src/posix/system_posix.c
new file mode 100644
index 0000000..4c37315
--- /dev/null
+++ b/src/posix/system_posix.c
@@ -0,0 +1,26 @@
+// Copyright 2007-2022 David Robillard <d@drobilla.net>
+// SPDX-License-Identifier: ISC
+
+#include "../system.h"
+#include "../zix_config.h"
+
+#include <unistd.h>
+
+#include <stdint.h>
+
+#if defined(PAGE_SIZE)
+# define ZIX_DEFAULT_PAGE_SIZE PAGE_SIZE
+#else
+# define ZIX_DEFAULT_PAGE_SIZE 4096U
+#endif
+
+uint32_t
+zix_system_page_size(void)
+{
+#if USE_SYSCONF
+ const long r = sysconf(_SC_PAGE_SIZE);
+ return r > 0L ? (uint32_t)r : ZIX_DEFAULT_PAGE_SIZE;
+#else
+ return (uint32_t)ZIX_DEFAULT_PAGE_SIZE;
+#endif
+}