mman.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017/11/30 Bernard The first version.
  9. * 2024/03/29 TroyMitchelle Add comments for all macros
  10. */
  11. #ifndef __SYS_MMAN_H__
  12. #define __SYS_MMAN_H__
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #include <sys/types.h>
  17. #define MAP_FAILED ((void *) -1)
  18. /* mmap flags */
  19. #define MAP_SHARED 0x01 /**< Share the mapping with other processes. */
  20. #define MAP_PRIVATE 0x02 /**< Create a private copy-on-write mapping. */
  21. #define MAP_TYPE 0x0f /**< Mask for type of mapping. */
  22. #define MAP_FIXED 0x10 /**< Interpret addr exactly. */
  23. #define MAP_ANON 0x20 /**< Anonymous mapping. */
  24. #define MAP_ANONYMOUS MAP_ANON /**< Synonym for MAP_ANON. */
  25. #define MAP_NORESERVE 0x4000 /**< Don't reserve swap space for this mapping. */
  26. #define MAP_GROWSDOWN 0x0100 /**< Stack-like segment. */
  27. #define MAP_DENYWRITE 0x0800 /**< ETXTBSY. */
  28. #define MAP_EXECUTABLE 0x1000 /**< Mark it as an executable. */
  29. #define MAP_LOCKED 0x2000 /**< Lock the mapping's pages. */
  30. #define MAP_POPULATE 0x8000 /**< Populate (prefault) pagetables. */
  31. #define MAP_NONBLOCK 0x10000 /**< Do not block on IO. */
  32. #define MAP_STACK 0x20000 /**< Allocation is a stack segment. */
  33. #define MAP_HUGETLB 0x40000 /**< Create a huge page mapping. */
  34. #define MAP_FILE 0 /**< Compatibility */
  35. /* mmap protections */
  36. #define PROT_NONE 0 /**< No access. */
  37. #define PROT_READ 1 /**< Page can be read. */
  38. #define PROT_WRITE 2 /**< Page can be written. */
  39. #define PROT_EXEC 4 /**< Page can be executed. */
  40. #define PROT_GROWSDOWN 0x01000000/**< Extend change to start of growsdown vma (mprotect only). */
  41. #define PROT_GROWSUP 0x02000000/**< Extend change to start of growsup vma (mprotect only). */
  42. /* msync flags */
  43. #define MS_ASYNC 1 /**< Perform asynchronous writes. */
  44. #define MS_INVALIDATE 2 /**< Invalidate mappings after writing. */
  45. #define MS_SYNC 4 /**< Perform synchronous writes. */
  46. /* mlockall flags */
  47. #define MCL_CURRENT 1 /**< Lock all pages which are currently mapped into the address space of the process. */
  48. #define MCL_FUTURE 2 /**< Lock all pages which will become mapped into the address space of the process in the future. */
  49. #define MCL_ONFAULT 4 /**< Lock all pages which are currently mapped into the address space of the process on access. */
  50. void *mmap (void *start, size_t len, int prot, int flags, int fd, off_t off);
  51. int munmap (void *start, size_t len);
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif