mman.pxd 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # http://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/mman.h.html
  2. from posix.types cimport off_t, mode_t
  3. cdef extern from "<sys/mman.h>" nogil:
  4. enum: PROT_EXEC # protection bits for mmap/mprotect
  5. enum: PROT_READ
  6. enum: PROT_WRITE
  7. enum: PROT_NONE
  8. enum: MAP_PRIVATE # flag bits for mmap
  9. enum: MAP_SHARED
  10. enum: MAP_FIXED
  11. enum: MAP_ANON # These three are not in POSIX, but are
  12. enum: MAP_ANONYMOUS # fairly common in spelling/semantics
  13. enum: MAP_STACK
  14. enum: MAP_LOCKED # Typically available only on Linux
  15. enum: MAP_HUGETLB
  16. enum: MAP_POPULATE
  17. enum: MAP_NORESERVE
  18. enum: MAP_GROWSDOWN
  19. enum: MAP_NOCORE # Typically available only on BSD
  20. enum: MAP_NOSYNC
  21. void *MAP_FAILED
  22. void *mmap(void *addr, size_t Len, int prot, int flags, int fd, off_t off)
  23. int munmap(void *addr, size_t Len)
  24. int mprotect(void *addr, size_t Len, int prot)
  25. enum: MS_ASYNC
  26. enum: MS_SYNC
  27. enum: MS_INVALIDATE
  28. int msync(void *addr, size_t Len, int flags)
  29. enum: POSIX_MADV_NORMAL # POSIX advice flags
  30. enum: POSIX_MADV_SEQUENTIAL
  31. enum: POSIX_MADV_RANDOM
  32. enum: POSIX_MADV_WILLNEED
  33. enum: POSIX_MADV_DONTNEED
  34. int posix_madvise(void *addr, size_t Len, int advice)
  35. enum: MCL_CURRENT
  36. enum: MCL_FUTURE
  37. int mlock(const void *addr, size_t Len)
  38. int munlock(const void *addr, size_t Len)
  39. int mlockall(int flags)
  40. int munlockall()
  41. # Linux-specific
  42. enum: MLOCK_ONFAULT
  43. enum: MCL_ONFAULT
  44. int mlock2(const void *addr, size_t len, int flags)
  45. int shm_open(const char *name, int oflag, mode_t mode)
  46. int shm_unlink(const char *name)
  47. # often available
  48. enum: MADV_NORMAL # pre-POSIX advice flags; should translate 1-1 to POSIX_*
  49. enum: MADV_RANDOM # but in practice it is not always the same.
  50. enum: MADV_SEQUENTIAL
  51. enum: MADV_WILLNEED
  52. enum: MADV_DONTNEED
  53. enum: MADV_REMOVE # other pre-POSIX advice flags; often available
  54. enum: MADV_DONTFORK
  55. enum: MADV_DOFORK
  56. enum: MADV_HWPOISON
  57. enum: MADV_MERGEABLE,
  58. enum: MADV_UNMERGEABLE
  59. enum: MADV_SOFT_OFFLINE
  60. enum: MADV_HUGEPAGE
  61. enum: MADV_NOHUGEPAGE
  62. enum: MADV_DONTDUMP
  63. enum: MADV_DODUMP
  64. enum: MADV_FREE
  65. enum: MADV_WIPEONFORK
  66. enum: MADV_KEEPONFORK
  67. int madvise(void *addr, size_t Len, int advice)
  68. # sometimes available
  69. int mincore(void *addr, size_t Len, unsigned char *vec)
  70. # These two are Linux specific but sometimes very efficient
  71. void *mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
  72. int remap_file_pages(void *addr, size_t Len, int prot,
  73. size_t pgoff, int flags)
  74. # The rare but standardized typed memory option
  75. enum: POSIX_TYPED_MEM_ALLOCATE
  76. enum: POSIX_TYPED_MEM_ALLOCATE_CONTIG
  77. enum: POSIX_TYPED_MEM_MAP_ALLOCATABLE
  78. int posix_typed_mem_open(const char *name, int oflag, int tflag)
  79. int posix_mem_offset(const void *addr, size_t Len, off_t *off,
  80. size_t *contig_len, int *fildes)
  81. cdef struct posix_typed_mem_info:
  82. size_t posix_tmi_length
  83. int posix_typed_mem_get_info(int fildes, posix_typed_mem_info *info)