HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
virtualMemory.h
Go to the documentation of this file.
1 //
2 // Copyright 2019 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_ARCH_VIRTUAL_MEMORY_H
8 #define PXR_BASE_ARCH_VIRTUAL_MEMORY_H
9 
10 /// \file arch/virtualMemory.h
11 /// \ingroup group_arch_SystemFunctions
12 /// Architecture dependent routines for virtual memory.
13 
14 #include "pxr/pxr.h"
15 #include "pxr/base/arch/api.h"
16 
17 #include <cstddef>
18 
20 
21 /// Reserve \p numBytes bytes of virtual memory. Call ArchCommitVirtualMemory()
22 /// on subranges to write to and read from the memory. Return nullptr in case
23 /// of an error; check errno.
24 ARCH_API void *
25 ArchReserveVirtualMemory(size_t numBytes);
26 
27 /// Make the range of \p numBytes bytes starting at \p start available for
28 /// reading and writing. The range must be within one previously reserved by
29 /// ArchReserveVirtualMemory(). It is not an error to commit a range that was
30 /// previously partly or fully committed. Return false in case of an error;
31 /// check errno.
32 ARCH_API bool
33 ArchCommitVirtualMemoryRange(void *start, size_t numBytes);
34 
35 /// Return memory obtained with ArchReserveVirtualMemory() to the system. The
36 /// \p start argument must be the value returned from a previous call to
37 /// ArchReserveVirtualMemory, and \p numBytes must match the argument from that
38 /// call. Memory within the range may not be accessed after this call. Return
39 /// false in case of an error; check errno.
40 ARCH_API bool
41 ArchFreeVirtualMemory(void *start, size_t numBytes);
42 
43 /// Memory protection options, see ArchSetMemoryProtection().
49 };
50 
51 /// Change the memory protection on the pages containing \p start and \p start +
52 /// \p numBytes to \p protection. Return true if the protection is changed
53 /// successfully. Return false in case of an error; check errno. This function
54 /// rounds \p start to the nearest lower page boundary. On POSIX systems,
55 /// ArchProtectReadWrite and ArchProtectReadWriteCopy are the same, on Windows
56 /// they differ but the Windows API documentation does not make it clear what
57 /// using ReadWrite means for a private file-backed mapping.
58 ARCH_API bool
59 ArchSetMemoryProtection(void const *start, size_t numBytes,
60  ArchMemoryProtection protection);
61 
63 
64 #endif // PXR_BASE_ARCH_VIRTUAL_MEMORY_H
GLuint start
Definition: glcorearb.h:475
ARCH_API bool ArchCommitVirtualMemoryRange(void *start, size_t numBytes)
ARCH_API bool ArchSetMemoryProtection(void const *start, size_t numBytes, ArchMemoryProtection protection)
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
PXR_NAMESPACE_OPEN_SCOPE ARCH_API void * ArchReserveVirtualMemory(size_t numBytes)
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
ARCH_API bool ArchFreeVirtualMemory(void *start, size_t numBytes)
ArchMemoryProtection
Memory protection options, see ArchSetMemoryProtection().
Definition: virtualMemory.h:44
#define ARCH_API
Definition: api.h:23