[xbuild] Pick the correct base path for target frameworks.
[mono.git] / mono / utils / mono-mmap.h
1 #ifndef __MONO_UTILS_MMAP_H__
2 #define __MONO_UTILS_MMAP_H__
3
4 #include <glib.h>
5
6 enum {
7         /* protection */
8         MONO_MMAP_NONE = 0,
9         MONO_MMAP_READ    = 1 << 0,
10         MONO_MMAP_WRITE   = 1 << 1,
11         MONO_MMAP_EXEC    = 1 << 2,
12         /* make the OS discard the dirty data and fill with 0 */
13         MONO_MMAP_DISCARD = 1 << 3,
14         /* other flags (add commit, sync) */
15         MONO_MMAP_PRIVATE = 1 << 4,
16         MONO_MMAP_SHARED  = 1 << 5,
17         MONO_MMAP_ANON    = 1 << 6,
18         MONO_MMAP_FIXED   = 1 << 7,
19         MONO_MMAP_32BIT   = 1 << 8
20 };
21
22 /*
23  * A simple interface to fopen/fstat/fileno
24  */
25 typedef struct _MonoFileMap MonoFileMap;
26
27 MonoFileMap *mono_file_map_open  (const char* name);
28 guint64      mono_file_map_size  (MonoFileMap *fmap);
29 int          mono_file_map_fd    (MonoFileMap *fmap);
30 int          mono_file_map_close (MonoFileMap *fmap);
31
32 int   mono_pagesize   (void);
33 void* mono_valloc     (void *addr, size_t length, int flags);
34 void* mono_valloc_aligned (size_t length, size_t alignment, int flags);
35 int   mono_vfree      (void *addr, size_t length);
36 void* mono_file_map   (size_t length, int flags, int fd, guint64 offset, void **ret_handle);
37 int   mono_file_unmap (void *addr, void *handle);
38 int   mono_mprotect   (void *addr, size_t length, int flags);
39
40 void* mono_shared_area         (void);
41 void  mono_shared_area_remove  (void);
42 void* mono_shared_area_for_pid (void *pid);
43 void  mono_shared_area_unload  (void *area);
44 int   mono_shared_area_instances (void **array, int count);
45
46 /*
47  * On systems where we have to load code into memory instead of mmaping
48  * we allow for the allocator to be set.   This function is only
49  * defined on those platforms.
50  */
51 typedef void *(*mono_file_map_alloc_fn)   (size_t length);
52 typedef void  (*mono_file_map_release_fn) (void *addr);
53
54 void mono_file_map_set_allocator (mono_file_map_alloc_fn alloc, mono_file_map_release_fn release);
55                                   
56 #endif /* __MONO_UTILS_MMAP_H__ */
57