GDAL
cpl_userfaultfd.h
1/******************************************************************************
2 *
3 * Name: cpl_userfault.h
4 * Project: CPL - Common Portability Library
5 * Purpose: Use userfaultfd and VSIL to service page faults
6 * Author: James McClain, <james.mcclain@gmail.com>
7 *
8 ******************************************************************************
9 * Copyright (c) 2018, Dr. James McClain <james.mcclain@gmail.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included
19 * in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 ****************************************************************************/
29
30#ifndef CPL_USERFAULTFD
31#define CPL_USERFAULTFD
32
33#include <stdint.h>
34
35#include <fcntl.h>
36#include <unistd.h>
37
38#include <sys/mman.h>
39#include <sys/stat.h>
40#include <sys/types.h>
41#include <linux/userfaultfd.h>
42
43#define GDAL_UFFD_LIMIT "GDAL_UFFD_LIMIT"
44
45typedef struct cpl_uffd_context cpl_uffd_context;
46
47bool CPL_DLL CPLIsUserFaultMappingSupported();
48cpl_uffd_context CPL_DLL *CPLCreateUserFaultMapping(const char *pszFilename,
49 void **ppVma,
50 uint64_t *pnVmaSize);
51void CPL_DLL CPLDeleteUserFaultMapping(cpl_uffd_context *ctx);
52
53#endif