Tor  0.4.7.0-alpha-dev
mmap.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2021, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
6 /**
7  * \file mmap.h
8  *
9  * \brief Header for mmap.c
10  **/
11 
12 #ifndef TOR_MMAP_H
13 #define TOR_MMAP_H
14 
15 #include "lib/cc/compat_compiler.h"
17 #include <stddef.h>
18 
19 #ifdef _WIN32
20 #include <windef.h>
21 #endif
22 
23 /** Represents an mmaped file. Allocated via tor_mmap_file; freed with
24  * tor_munmap_file. */
25 typedef struct tor_mmap_t {
26  const char *data; /**< Mapping of the file's contents. */
27  size_t size; /**< Size of the file. */
28 
29  /* None of the fields below should be accessed from outside compat.c */
30 #ifdef HAVE_MMAP
31  size_t mapping_size; /**< Size of the actual mapping. (This is this file
32  * size, rounded up to the nearest page.) */
33 #elif defined _WIN32
34  HANDLE mmap_handle;
35 #endif /* defined(HAVE_MMAP) || ... */
36 
37 } tor_mmap_t;
38 
39 MOCK_DECL(tor_mmap_t *, tor_mmap_file, (const char *filename));
40 MOCK_DECL(int, tor_munmap_file, (tor_mmap_t *handle));
41 
42 #endif /* !defined(TOR_MMAP_H) */
Utility macros to handle different features and behavior in different compilers.
size_t size
Definition: mmap.h:27
const char * data
Definition: mmap.h:26
Macros to implement mocking and selective exposure for the test code.
#define MOCK_DECL(rv, funcname, arglist)
Definition: testsupport.h:127