summaryrefslogtreecommitdiff
path: root/prism/compiler/filesystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'prism/compiler/filesystem.h')
-rw-r--r--prism/compiler/filesystem.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/prism/compiler/filesystem.h b/prism/compiler/filesystem.h
new file mode 100644
index 0000000000..f988909db8
--- /dev/null
+++ b/prism/compiler/filesystem.h
@@ -0,0 +1,32 @@
+/**
+ * @file compiler/filesystem.h
+ *
+ * Platform detection for mmap and filesystem support.
+ */
+#ifndef PRISM_COMPILER_FILESYSTEM_H
+#define PRISM_COMPILER_FILESYSTEM_H
+
+/**
+ * In general, libc for embedded systems does not support memory-mapped files.
+ * If the target platform is POSIX or Windows, we can map a file in memory and
+ * read it in a more efficient manner.
+ */
+#ifdef _WIN32
+# define PRISM_HAS_MMAP
+#else
+# include <unistd.h>
+# ifdef _POSIX_MAPPED_FILES
+# define PRISM_HAS_MMAP
+# endif
+#endif
+
+/**
+ * If PRISM_HAS_NO_FILESYSTEM is defined, then we want to exclude all filesystem
+ * related code from the library. All filesystem related code should be guarded
+ * by PRISM_HAS_FILESYSTEM.
+ */
+#ifndef PRISM_HAS_NO_FILESYSTEM
+# define PRISM_HAS_FILESYSTEM
+#endif
+
+#endif