summaryrefslogtreecommitdiffstats
path: root/src/posix/system_posix.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-10-23 13:41:27 -0400
committerDavid Robillard <d@drobilla.net>2022-10-23 14:57:45 -0400
commitd8b960be46007f9c09356e526d3c2dcff4b186a5 (patch)
treecd40db8d5634e74f8795922b7ab19fc8c6507648 /src/posix/system_posix.c
parentc886d489576cd0bc33d7d22d81981c794067946f (diff)
downloadzix-d8b960be46007f9c09356e526d3c2dcff4b186a5.tar.gz
zix-d8b960be46007f9c09356e526d3c2dcff4b186a5.tar.bz2
zix-d8b960be46007f9c09356e526d3c2dcff4b186a5.zip
Add filesystem API
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
+}