tor  0.4.2.1-alpha-dev
map_anon.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-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_MAP_ANON_H
12 #define TOR_MAP_ANON_H
13 
14 #include "lib/malloc/malloc.h"
15 #include <stddef.h>
16 
23 #define ANONMAP_PRIVATE (1u<<0)
24 
32 #define ANONMAP_NOINHERIT (1u<<1)
33 
34 typedef enum {
45 
46 /* Here we define the NOINHERIT_CAN_FAIL macro if and only if
47  * it's possible that ANONMAP_NOINHERIT might yield inheritable memory.
48  */
49 #ifdef _WIN32
50 /* Windows can't fork, so NOINHERIT is never needed. */
51 #elif defined(HAVE_MINHERIT)
52 /* minherit() will always have a working MAP_INHERIT_NONE or MAP_INHERIT_ZERO.
53  * NOINHERIT should always work.
54  */
55 #elif defined(HAVE_MADVISE)
56 /* madvise() sometimes has neither MADV_DONTFORK and MADV_WIPEONFORK.
57  * We need to be ready for the possibility it failed.
58  *
59  * (Linux added DONTFORK in 2.6.16 and WIPEONFORK in 4.14. If we someday
60  * require 2.6.16 or later, we can assume that DONTFORK will work.)
61  */
62 #define NOINHERIT_CAN_FAIL
63 #else
64 #define NOINHERIT_CAN_FAIL
65 #endif /* defined(_WIN32) || ... */
66 
67 void *tor_mmap_anonymous(size_t sz, unsigned flags,
68  inherit_res_t *inherit_result_out);
69 void tor_munmap_anonymous(void *mapping, size_t sz);
70 
71 #endif /* !defined(TOR_MAP_ANON_H) */
void tor_munmap_anonymous(void *mapping, size_t sz)
Definition: map_anon.c:257
void * tor_mmap_anonymous(size_t sz, unsigned flags, inherit_res_t *inherit_result_out)
Definition: map_anon.c:203
Headers for util_malloc.c.
inherit_res_t
Definition: map_anon.h:34