aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fs/mmap.h
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-27 14:45:17 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-27 14:45:17 -0400
commit000de2f2ac4f740be8351673691371d78a5da7e9 (patch)
tree1212f745111239dd7713c956ae60b081edfe912a /src/lib/fs/mmap.h
parent21136037182f55b5aef3730853e65fa2c7ebd722 (diff)
parent3d606dddb9a104466906069bd21acbdfb1270b58 (diff)
downloadtor-000de2f2ac4f740be8351673691371d78a5da7e9.tar.gz
tor-000de2f2ac4f740be8351673691371d78a5da7e9.zip
Merge branch 'fs_refactor'
Diffstat (limited to 'src/lib/fs/mmap.h')
-rw-r--r--src/lib/fs/mmap.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/lib/fs/mmap.h b/src/lib/fs/mmap.h
new file mode 100644
index 0000000000..b0585775f5
--- /dev/null
+++ b/src/lib/fs/mmap.h
@@ -0,0 +1,35 @@
+/* Copyright (c) 2003-2004, Roger Dingledine
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2018, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_MMAP_H
+#define TOR_MMAP_H
+
+#include "lib/cc/compat_compiler.h"
+#include <stddef.h>
+
+#ifdef _WIN32
+#include <windef.h>
+#endif
+
+/** Represents an mmaped file. Allocated via tor_mmap_file; freed with
+ * tor_munmap_file. */
+typedef struct tor_mmap_t {
+ const char *data; /**< Mapping of the file's contents. */
+ size_t size; /**< Size of the file. */
+
+ /* None of the fields below should be accessed from outside compat.c */
+#ifdef HAVE_MMAP
+ size_t mapping_size; /**< Size of the actual mapping. (This is this file
+ * size, rounded up to the nearest page.) */
+#elif defined _WIN32
+ HANDLE mmap_handle;
+#endif /* defined(HAVE_MMAP) || ... */
+
+} tor_mmap_t;
+
+tor_mmap_t *tor_mmap_file(const char *filename) ATTR_NONNULL((1));
+int tor_munmap_file(tor_mmap_t *handle) ATTR_NONNULL((1));
+
+#endif