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
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#ifndef SUPPORT_NEXT_TO_FAULT_H
20#define SUPPORT_NEXT_TO_FAULT_H
21
22#include <sys/cdefs.h>
23#include <sys/types.h>
24
25__BEGIN_DECLS
26
27/* The memory region created by next_to_fault_allocate. */
28struct support_next_to_fault
29{
30 /* The user data. */
31 char *buffer;
32 size_t length;
33
34 /* The entire allocated region. */
35 void *region_start;
36 size_t region_size;
37};
38
39/* Allocate a buffer of SIZE bytes just before a page which is mapped
40 with PROT_NONE (so that overrunning the buffer will cause a
41 fault). */
42struct support_next_to_fault support_next_to_fault_allocate (size_t size);
43
44/* Deallocate the memory region allocated by
45 next_to_fault_allocate. */
46void support_next_to_fault_free (struct support_next_to_fault *);
47
48#endif /* SUPPORT_NEXT_TO_FAULT_H */
49