You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fcmp/include/map.h

31 lines
720 B

#ifndef _MAP_H
#define _MAP_H
#ifdef __cplusplus
extern "C" {
#define restrict __restrict__
#endif
#include <stddef.h>
typedef struct mmap {
int fd;
void* ptr;
size_t len;
} mmap_t;
int open_and_map(const char* file, mmap_t* restrict ptr);
int unmap_and_close(mmap_t map);
int set_preload_map(mmap_t* restrict map);
/// Undo a previous call to `set_preload_map()`.
/// *freeing* (1 - yes, 0, no) - If the next operation on the map will be `unmap_and_close()`, advise the kernel to drop the mapped pages whenever it wants. Do not specify this if you will use the map again after this call.
int unset_preload_map(mmap_t* restrict map, int freeing);
#ifdef _cplusplus
}
#undef restrict
#endif
#endif /* _MAP_H */