mmap_internal.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Common mmap definition for Linux implementation.
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef MMAP_INTERNAL_LINUX_H
  16. #define MMAP_INTERNAL_LINUX_H 1
  17. /* This is the minimum mmap2 unit size accept by the kernel. An architecture
  18. with multiple minimum page sizes (such as m68k) might define it as -1 and
  19. thus it will queried at runtime. */
  20. #ifndef MMAP2_PAGE_UNIT
  21. # define MMAP2_PAGE_UNIT 4096ULL
  22. #endif
  23. #if MMAP2_PAGE_UNIT == -1
  24. static uint64_t page_unit;
  25. # define MMAP_CHECK_PAGE_UNIT() \
  26. if (page_unit == 0) \
  27. page_unit = __getpagesize ();
  28. # undef MMAP2_PAGE_UNIT
  29. # define MMAP2_PAGE_UNIT page_unit
  30. #else
  31. # define MMAP_CHECK_PAGE_UNIT()
  32. #endif
  33. /* Do not accept offset not multiple of page size. */
  34. #define MMAP_OFF_LOW_MASK (MMAP2_PAGE_UNIT - 1)
  35. /* An architecture may override this. */
  36. #ifndef MMAP_CALL
  37. # define MMAP_CALL(__nr, __addr, __len, __prot, __flags, __fd, __offset) \
  38. INLINE_SYSCALL_CALL (__nr, __addr, __len, __prot, __flags, __fd, __offset)
  39. #endif
  40. #endif /* MMAP_INTERNAL_LINUX_H */