2022-10-08 10:06:09 +00:00
|
|
|
#ifndef _SYS_MMAN_H
|
|
|
|
#define _SYS_MMAN_H
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2022-10-12 13:56:03 +00:00
|
|
|
#include <sys/types.h> // for off_t
|
2022-10-08 10:06:09 +00:00
|
|
|
|
2022-10-12 10:06:45 +00:00
|
|
|
/* Address returned by mmap when it fails. */
|
2022-10-08 10:06:09 +00:00
|
|
|
#define MAP_FAILED (void*)-1
|
|
|
|
|
2022-10-15 10:57:14 +00:00
|
|
|
#define PROT_NONE 0
|
|
|
|
#define PROT_READ 1
|
|
|
|
#define PROT_WRITE 2
|
2022-11-02 17:40:05 +00:00
|
|
|
#define PROT_EXEC 4
|
2022-10-08 12:44:48 +00:00
|
|
|
|
2022-10-08 12:52:28 +00:00
|
|
|
#define PAGE_SIZE 4096
|
|
|
|
|
2022-10-23 10:10:05 +00:00
|
|
|
#define MAP_PRIVATE 0
|
|
|
|
#define MAP_SHARED 1
|
|
|
|
#define MAP_ANONYMOUS 2
|
|
|
|
|
2022-10-08 10:06:09 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
|
2022-10-12 10:15:12 +00:00
|
|
|
/* Maps size bytes of memory (rounded up to the nearest page-aligned size) into the current process's address
|
2022-10-12 10:06:45 +00:00
|
|
|
* space at addr. If addr is null, the kernel will choose an address. */
|
|
|
|
void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset);
|
2022-10-12 10:07:42 +00:00
|
|
|
|
2022-10-12 10:15:12 +00:00
|
|
|
/* Unmaps size bytes of memory (rounded up to the nearest page-aligned size) at addr from the current process's
|
2022-10-12 10:06:45 +00:00
|
|
|
* address space. */
|
|
|
|
int munmap(void* addr, size_t size);
|
2022-10-08 10:06:09 +00:00
|
|
|
|
2022-10-23 10:26:48 +00:00
|
|
|
/* Changes the permissions of size bytes of memory at addr zaccording to the prot argument. */
|
2022-10-15 10:57:14 +00:00
|
|
|
int mprotect(void* addr, size_t size, int prot);
|
|
|
|
|
2022-10-08 10:06:09 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|