Use expression-bodied members in more places (dotnet/coreclr#26500)
[mono-project.git] / mono / utils / mono-mmap.h
blob25ce4ecafc2a990b6e814d56c0be41ceeeb7ed40
1 /**
2 * \file
3 */
5 #ifndef __MONO_UTILS_MMAP_H__
6 #define __MONO_UTILS_MMAP_H__
8 #include <glib.h>
9 #include <mono/utils/mono-publib.h>
11 enum {
12 /* protection */
13 MONO_MMAP_NONE = 0,
14 MONO_MMAP_READ = 1 << 0,
15 MONO_MMAP_WRITE = 1 << 1,
16 MONO_MMAP_EXEC = 1 << 2,
17 /* make the OS discard the dirty data and fill with 0 */
18 MONO_MMAP_DISCARD = 1 << 3,
19 /* other flags (add commit, sync) */
20 MONO_MMAP_PRIVATE = 1 << 4,
21 MONO_MMAP_SHARED = 1 << 5,
22 MONO_MMAP_ANON = 1 << 6,
23 MONO_MMAP_FIXED = 1 << 7,
24 MONO_MMAP_32BIT = 1 << 8,
25 MONO_MMAP_JIT = 1 << 9
28 typedef enum {
29 MONO_MEM_ACCOUNT_CODE,
30 MONO_MEM_ACCOUNT_HAZARD_POINTERS,
31 MONO_MEM_ACCOUNT_DOMAIN,
32 MONO_MEM_ACCOUNT_SGEN_INTERNAL,
33 MONO_MEM_ACCOUNT_SGEN_NURSERY,
34 MONO_MEM_ACCOUNT_SGEN_LOS,
35 MONO_MEM_ACCOUNT_SGEN_MARKSWEEP,
36 MONO_MEM_ACCOUNT_SGEN_CARD_TABLE,
37 MONO_MEM_ACCOUNT_SGEN_SHADOW_CARD_TABLE,
38 MONO_MEM_ACCOUNT_SGEN_DEBUGGING,
39 MONO_MEM_ACCOUNT_SGEN_BINARY_PROTOCOL,
40 MONO_MEM_ACCOUNT_EXCEPTIONS,
41 MONO_MEM_ACCOUNT_PROFILER,
42 MONO_MEM_ACCOUNT_OTHER,
43 MONO_MEM_ACCOUNT_MAX
44 } MonoMemAccountType;
47 * A simple interface to fopen/fstat/fileno
49 typedef struct _MonoFileMap MonoFileMap;
51 MONO_API MonoFileMap *mono_file_map_open (const char* name);
52 MONO_API guint64 mono_file_map_size (MonoFileMap *fmap);
53 MONO_API int mono_file_map_fd (MonoFileMap *fmap);
54 MONO_API int mono_file_map_close (MonoFileMap *fmap);
56 MONO_API void mono_setmmapjit (int flag);
57 MONO_API int mono_pagesize (void);
58 MONO_API int mono_valloc_granule (void);
59 MONO_API void* mono_valloc (void *addr, size_t length, int flags, MonoMemAccountType type);
60 MONO_API void* mono_valloc_aligned (size_t length, size_t alignment, int flags, MonoMemAccountType type);
61 MONO_API int mono_vfree (void *addr, size_t length, MonoMemAccountType type);
62 MONO_API void* mono_file_map (size_t length, int flags, int fd, guint64 offset, void **ret_handle);
64 // Last two parameters are optional.
65 // This is mono_file_map but with optionally returning an error message.
66 // See https://github.com/mono/mono/issues/8225.
67 MONO_API
68 void*
69 mono_file_map_error (size_t length, int flags, int fd, guint64 offset, void **ret_handle, const char *filepath, char **error_message);
70 MONO_API int mono_file_unmap (void *addr, void *handle);
71 #ifndef HOST_WIN32
72 MONO_API void* mono_file_map_fileio (size_t length, int flags, int fd, guint64 offset, void **ret_handle);
73 MONO_API int mono_file_unmap_fileio (void *addr, void *handle);
74 #endif
75 MONO_API int mono_mprotect (void *addr, size_t length, int flags);
77 MONO_API const char* mono_mem_account_type_name (MonoMemAccountType type);
78 MONO_API void mono_mem_account_register_counters (void);
80 MONO_API void* mono_shared_area (void);
81 MONO_API void mono_shared_area_remove (void);
82 MONO_API void* mono_shared_area_for_pid (void *pid);
83 MONO_API void mono_shared_area_unload (void *area);
84 MONO_API int mono_shared_area_instances (void **array, int count);
87 * On systems where we have to load code into memory instead of mmaping
88 * we allow for the allocator to be set. This function is only
89 * defined on those platforms.
91 typedef void *(*mono_file_map_alloc_fn) (size_t length);
92 typedef void (*mono_file_map_release_fn) (void *addr);
94 MONO_API void mono_file_map_set_allocator (mono_file_map_alloc_fn alloc, mono_file_map_release_fn release);
96 #endif /* __MONO_UTILS_MMAP_H__ */