summaryrefslogtreecommitdiff
path: root/components/libc/posix/io/mman/sys/mman.h
blob: 0955975c65054fdcb3a81ed7da54f2d7f7188f09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author            Notes
 * 2017/11/30     Bernard           The first version.
 * 2024/03/29     TroyMitchelle     Add comments for all macros
 */

#ifndef __SYS_MMAN_H__
#define __SYS_MMAN_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>

#define MAP_FAILED     ((void *) -1)

/* mmap flags */
#define MAP_SHARED     0x01      /**< Share the mapping with other processes. */
#define MAP_PRIVATE    0x02      /**< Create a private copy-on-write mapping. */
#define MAP_TYPE       0x0f      /**< Mask for type of mapping. */
#define MAP_FIXED      0x10      /**< Interpret addr exactly. */
#define MAP_ANON       0x20      /**< Anonymous mapping. */
#define MAP_ANONYMOUS  MAP_ANON  /**< Synonym for MAP_ANON. */
#define MAP_NORESERVE  0x4000    /**< Don't reserve swap space for this mapping. */
#define MAP_GROWSDOWN  0x0100    /**< Stack-like segment. */
#define MAP_DENYWRITE  0x0800    /**< ETXTBSY. */
#define MAP_EXECUTABLE 0x1000    /**< Mark it as an executable. */
#define MAP_LOCKED     0x2000    /**< Lock the mapping's pages. */
#define MAP_POPULATE   0x8000    /**< Populate (prefault) pagetables. */
#define MAP_NONBLOCK   0x10000   /**< Do not block on IO. */
#define MAP_STACK      0x20000   /**< Allocation is a stack segment. */
#define MAP_HUGETLB    0x40000   /**< Create a huge page mapping. */
#define MAP_FILE       0         /**< Compatibility */

/* mmap protections */
#define PROT_NONE      0         /**< No access. */
#define PROT_READ      1         /**< Page can be read. */
#define PROT_WRITE     2         /**< Page can be written. */
#define PROT_EXEC      4         /**< Page can be executed. */
#define PROT_GROWSDOWN 0x01000000/**< Extend change to start of growsdown vma (mprotect only). */
#define PROT_GROWSUP   0x02000000/**< Extend change to start of growsup vma (mprotect only). */

/* msync flags */
#define MS_ASYNC       1         /**< Perform asynchronous writes. */
#define MS_INVALIDATE  2         /**< Invalidate mappings after writing. */
#define MS_SYNC        4         /**< Perform synchronous writes. */

/* mlockall flags */
#define MCL_CURRENT    1         /**< Lock all pages which are currently mapped into the address space of the process. */
#define MCL_FUTURE     2         /**< Lock all pages which will become mapped into the address space of the process in the future. */
#define MCL_ONFAULT    4         /**< Lock all pages which are currently mapped into the address space of the process on access. */


void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off);
int munmap (void *start, size_t len);

#ifdef __cplusplus
}
#endif
#endif