next_to_fault.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* Memory allocation next to an unmapped page.
  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 SUPPORT_NEXT_TO_FAULT_H
  16. #define SUPPORT_NEXT_TO_FAULT_H
  17. #include <sys/cdefs.h>
  18. #include <sys/types.h>
  19. __BEGIN_DECLS
  20. /* The memory region created by next_to_fault_allocate. */
  21. struct support_next_to_fault
  22. {
  23. /* The user data. */
  24. char *buffer;
  25. size_t length;
  26. /* The entire allocated region. */
  27. void *region_start;
  28. size_t region_size;
  29. };
  30. /* Allocate a buffer of SIZE bytes just before a page which is mapped
  31. with PROT_NONE (so that overrunning the buffer will cause a
  32. fault). */
  33. struct support_next_to_fault support_next_to_fault_allocate (size_t size);
  34. /* Deallocate the memory region allocated by
  35. next_to_fault_allocate. */
  36. void support_next_to_fault_free (struct support_next_to_fault *);
  37. #endif /* SUPPORT_NEXT_TO_FAULT_H */