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