mman-shared.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* Memory-mapping-related declarations/definitions, not architecture-specific.
  2. Copyright (C) 2017-2018 Free Software Foundation, Inc.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #ifndef _SYS_MMAN_H
  15. # error "Never use <bits/mman-shared.h> directly; include <sys/mman.h> instead."
  16. #endif
  17. #ifdef __USE_GNU
  18. /* Flags for memfd_create. */
  19. # ifndef MFD_CLOEXEC
  20. # define MFD_CLOEXEC 1U
  21. # define MFD_ALLOW_SEALING 2U
  22. # define MFD_HUGETLB 4U
  23. # endif
  24. /* Flags for mlock2. */
  25. # ifndef MLOCK_ONFAULT
  26. # define MLOCK_ONFAULT 1U
  27. # endif
  28. /* Access rights for pkey_alloc. */
  29. # ifndef PKEY_DISABLE_ACCESS
  30. # define PKEY_DISABLE_ACCESS 0x1
  31. # define PKEY_DISABLE_WRITE 0x2
  32. # endif
  33. __BEGIN_DECLS
  34. #if 0
  35. /* Create a new memory file descriptor. NAME is a name for debugging.
  36. FLAGS is a combination of the MFD_* constants. */
  37. int memfd_create (const char *__name, unsigned int __flags) __THROW;
  38. #endif
  39. /* Lock pages from ADDR (inclusive) to ADDR + LENGTH (exclusive) into
  40. memory. FLAGS is a combination of the MLOCK_* flags above. */
  41. int mlock2 (const void *__addr, size_t __length, unsigned int __flags) __THROW;
  42. /* Allocate a new protection key, with the PKEY_DISABLE_* bits
  43. specified in ACCESS_RIGHTS. The protection key mask for the
  44. current thread is updated to match the access privilege for the new
  45. key. */
  46. int pkey_alloc (unsigned int __flags, unsigned int __access_rights) __THROW;
  47. /* Update the access rights for the current thread for KEY, which must
  48. have been allocated using pkey_alloc. */
  49. int pkey_set (int __key, unsigned int __access_rights) __THROW;
  50. /* Return the access rights for the current thread for KEY, which must
  51. have been allocated using pkey_alloc. */
  52. int pkey_get (int _key) __THROW;
  53. /* Free an allocated protection key, which must have been allocated
  54. using pkey_alloc. */
  55. int pkey_free (int __key) __THROW;
  56. /* Apply memory protection flags for KEY to the specified address
  57. range. */
  58. int pkey_mprotect (void *__addr, size_t __len, int __prot, int __pkey) __THROW;
  59. __END_DECLS
  60. #endif /* __USE_GNU */