GDAL
cpl_virtualmem.h
Go to the documentation of this file.
1 /**********************************************************************
2  * $Id: cpl_virtualmem.h 36485 2016-11-24 07:54:20Z goatbar $
3  *
4  * Name: cpl_virtualmem.h
5  * Project: CPL - Common Portability Library
6  * Purpose: Virtual memory
7  * Author: Even Rouault, <even dot rouault at mines dash paris dot org>
8  *
9  **********************************************************************
10  * Copyright (c) 2014, Even Rouault <even dot rouault at mines-paris dot org>
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining a
13  * copy of this software and associated documentation files (the "Software"),
14  * to deal in the Software without restriction, including without limitation
15  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
16  * and/or sell copies of the Software, and to permit persons to whom the
17  * Software is furnished to do so, subject to the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be included
20  * in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
25  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
27  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
28  * DEALINGS IN THE SOFTWARE.
29  ****************************************************************************/
30 
31 #ifndef CPL_VIRTUAL_MEM_INCLUDED
32 #define CPL_VIRTUAL_MEM_INCLUDED
33 
34 #include <stddef.h>
35 
36 #include "cpl_port.h"
37 #include "cpl_vsi.h"
38 
40 
63 
75  size_t nOffset,
76  void* pPageToFill,
77  size_t nToFill,
78  void* pUserData);
79 
91  size_t nOffset,
92  const void* pPageToBeEvicted,
93  size_t nToBeEvicted,
94  void* pUserData);
95 
99 typedef void (*CPLVirtualMemFreeUserData)(void* pUserData);
100 
102 typedef enum
103 {
114 
121 size_t CPL_DLL CPLGetPageSize(void);
122 
167 CPLVirtualMem CPL_DLL *CPLVirtualMemNew(size_t nSize,
168  size_t nCacheSize,
169  size_t nPageSizeHint,
170  int bSingleThreadUsage,
171  CPLVirtualMemAccessMode eAccessMode,
172  CPLVirtualMemCachePageCbk pfnCachePage,
173  CPLVirtualMemUnCachePageCbk pfnUnCachePage,
174  CPLVirtualMemFreeUserData pfnFreeUserData,
175  void *pCbkUserData);
176 
182 int CPL_DLL CPLIsVirtualMemFileMapAvailable(void);
183 
211  vsi_l_offset nOffset,
212  vsi_l_offset nLength,
213  CPLVirtualMemAccessMode eAccessMode,
214  CPLVirtualMemFreeUserData pfnFreeUserData,
215  void *pCbkUserData );
216 
237  vsi_l_offset nOffset,
238  vsi_l_offset nSize,
239  CPLVirtualMemFreeUserData pfnFreeUserData,
240  void *pCbkUserData);
241 
253 void CPL_DLL CPLVirtualMemFree(CPLVirtualMem* ctxt);
254 
270 void CPL_DLL *CPLVirtualMemGetAddr(CPLVirtualMem* ctxt);
271 
279 size_t CPL_DLL CPLVirtualMemGetSize(CPLVirtualMem* ctxt);
280 
288 int CPL_DLL CPLVirtualMemIsFileMapping(CPLVirtualMem* ctxt);
289 
298 
309 size_t CPL_DLL CPLVirtualMemGetPageSize(CPLVirtualMem* ctxt);
310 
329 
342 void CPL_DLL CPLVirtualMemDeclareThread(CPLVirtualMem* ctxt);
343 
356 void CPL_DLL CPLVirtualMemUnDeclareThread(CPLVirtualMem* ctxt);
357 
375 void CPL_DLL CPLVirtualMemPin(CPLVirtualMem* ctxt,
376  void* pAddr, size_t nSize, int bWriteOp);
377 
385 void CPL_DLL CPLVirtualMemManagerTerminate(void);
386 
387 CPL_C_END
388 
389 #endif /* CPL_VIRTUAL_MEM_INCLUDED */
size_t CPLVirtualMemGetPageSize(CPLVirtualMem *ctxt)
Return the page size associated to a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2224
Standard C Covers.
Core portability definitions for CPL.
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:352
FILE VSILFILE
Opaque type for a FILE that implements the VSIVirtualHandle API.
Definition: cpl_vsi.h:154
void CPLVirtualMemUnDeclareThread(CPLVirtualMem *ctxt)
Declare that a thread will stop accessing a virtual memory mapping.
Definition: cpl_virtualmem.cpp:1979
struct CPLVirtualMem CPLVirtualMem
Opaque type that represents a virtual memory mapping.
Definition: cpl_virtualmem.h:62
void CPLVirtualMemManagerTerminate(void)
Cleanup any resource and handlers related to virtual memory.
Definition: cpl_virtualmem.cpp:1987
int CPLVirtualMemIsFileMapping(CPLVirtualMem *ctxt)
Return if the virtual memory mapping is a direct file mapping.
Definition: cpl_virtualmem.cpp:2206
Definition: cpl_virtualmem.h:106
CPLVirtualMem * CPLVirtualMemDerivedNew(CPLVirtualMem *pVMemBase, vsi_l_offset nOffset, vsi_l_offset nSize, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping derived from an other virtual memory mapping. ...
Definition: cpl_virtualmem.cpp:2251
void(* CPLVirtualMemCachePageCbk)(CPLVirtualMem *ctxt, size_t nOffset, void *pPageToFill, size_t nToFill, void *pUserData)
Callback triggered when a still unmapped page of virtual memory is accessed.
Definition: cpl_virtualmem.h:74
int CPLIsVirtualMemFileMapAvailable(void)
Return if virtual memory mapping of a file is available.
Definition: cpl_virtualmem.cpp:2151
size_t CPLVirtualMemGetSize(CPLVirtualMem *ctxt)
Return the size of the virtual memory mapping.
Definition: cpl_virtualmem.cpp:2233
size_t CPLGetPageSize(void)
Return the size of a page of virtual memory.
Definition: cpl_virtualmem.cpp:2138
void(* CPLVirtualMemUnCachePageCbk)(CPLVirtualMem *ctxt, size_t nOffset, const void *pPageToBeEvicted, size_t nToBeEvicted, void *pUserData)
Callback triggered when a dirty mapped page is going to be freed.
Definition: cpl_virtualmem.h:90
CPLVirtualMemAccessMode
Access mode of a virtual memory mapping.
Definition: cpl_virtualmem.h:102
void CPLVirtualMemFree(CPLVirtualMem *ctxt)
Free a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2164
int CPLVirtualMemIsAccessThreadSafe(CPLVirtualMem *ctxt)
Return TRUE if this memory mapping can be accessed safely from concurrent threads.
Definition: cpl_virtualmem.cpp:2242
CPLVirtualMemAccessMode CPLVirtualMemGetAccessMode(CPLVirtualMem *ctxt)
Return the access mode of the virtual memory mapping.
Definition: cpl_virtualmem.cpp:2215
GUIntBig vsi_l_offset
Type for a file offset.
Definition: cpl_vsi.h:138
void CPLVirtualMemPin(CPLVirtualMem *ctxt, void *pAddr, size_t nSize, int bWriteOp)
Make sure that a region of virtual memory will be realized.
Definition: cpl_virtualmem.cpp:1981
void * CPLVirtualMemGetAddr(CPLVirtualMem *ctxt)
Return the pointer to the start of a virtual memory mapping.
Definition: cpl_virtualmem.cpp:2197
void(* CPLVirtualMemFreeUserData)(void *pUserData)
Callback triggered when a virtual memory mapping is destroyed.
Definition: cpl_virtualmem.h:99
Definition: cpl_virtualmem.h:112
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:354
Definition: cpl_virtualmem.h:109
CPLVirtualMem * CPLVirtualMemNew(size_t nSize, size_t nCacheSize, size_t nPageSizeHint, int bSingleThreadUsage, CPLVirtualMemAccessMode eAccessMode, CPLVirtualMemCachePageCbk pfnCachePage, CPLVirtualMemUnCachePageCbk pfnUnCachePage, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping.
Definition: cpl_virtualmem.cpp:1960
CPLVirtualMem * CPLVirtualMemFileMapNew(VSILFILE *fp, vsi_l_offset nOffset, vsi_l_offset nLength, CPLVirtualMemAccessMode eAccessMode, CPLVirtualMemFreeUserData pfnFreeUserData, void *pCbkUserData)
Create a new virtual memory mapping from a file.
Definition: cpl_virtualmem.cpp:2118
void CPLVirtualMemDeclareThread(CPLVirtualMem *ctxt)
Declare that a thread will access a virtual memory mapping.
Definition: cpl_virtualmem.cpp:1977

Generated for GDAL by doxygen 1.8.8.