|
16 | 16 | extern "C" {
|
17 | 17 | #endif
|
18 | 18 |
|
| 19 | +/// |
| 20 | +/// @brief This structure comprises optional function pointers used |
| 21 | +/// by corresponding umfMemoryProvider* calls. A memory provider implementation |
| 22 | +/// can keep them NULL. |
| 23 | +/// |
| 24 | +typedef struct umf_memory_provider_ext_ops_t { |
| 25 | + /// |
| 26 | + /// @brief Discard physical pages within the virtual memory mapping associated at the given addr |
| 27 | + /// and \p size. This call is asynchronous and may delay purging the pages indefinitely. |
| 28 | + /// @param provider pointer to the memory provider |
| 29 | + /// @param ptr beginning of the virtual memory range |
| 30 | + /// @param size size of the virtual memory range |
| 31 | + /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
| 32 | + /// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. |
| 33 | + /// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. |
| 34 | + /// |
| 35 | + umf_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); |
| 36 | + |
| 37 | + /// |
| 38 | + /// @brief Discard physical pages within the virtual memory mapping associated at the given addr and \p size. |
| 39 | + /// This call is synchronous and if it succeeds, pages are guaranteed to be zero-filled on the next access. |
| 40 | + /// @param provider pointer to the memory provider |
| 41 | + /// @param ptr beginning of the virtual memory range |
| 42 | + /// @param size size of the virtual memory range |
| 43 | + /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
| 44 | + /// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. |
| 45 | + /// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. |
| 46 | + /// |
| 47 | + umf_result_t (*purge_force)(void *provider, void *ptr, size_t size); |
| 48 | + |
| 49 | + /// |
| 50 | + /// @brief Merges two coarse grain allocations into a single allocation that |
| 51 | + /// can be managed (freed) as a whole. |
| 52 | + /// @param hProvider handle to the memory provider |
| 53 | + /// @param lowPtr pointer to the first allocation |
| 54 | + /// @param highPtr pointer to the second allocation (should be > lowPtr) |
| 55 | + /// @param totalSize size of a new merged allocation. Should be equal |
| 56 | + /// to the sum of sizes of allocations beginning at lowPtr and highPtr |
| 57 | + /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
| 58 | + /// |
| 59 | + umf_result_t (*allocation_merge)(void *hProvider, void *lowPtr, |
| 60 | + void *highPtr, size_t totalSize); |
| 61 | + |
| 62 | + /// |
| 63 | + /// @brief Splits a coarse grain allocation into 2 adjacent allocations that |
| 64 | + /// can be managed (freed) separately. |
| 65 | + /// @param hProvider handle to the memory provider |
| 66 | + /// @param ptr pointer to the beginning of the allocation |
| 67 | + /// @param totalSize total size of the allocation to be split |
| 68 | + /// @param firstSize size of the first new allocation, second allocation |
| 69 | + // has a size equal to totalSize - firstSize |
| 70 | + /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
| 71 | + /// |
| 72 | + umf_result_t (*allocation_split)(void *hProvider, void *ptr, |
| 73 | + size_t totalSize, size_t firstSize); |
| 74 | + |
| 75 | +} umf_memory_provider_ext_ops_t; |
| 76 | + |
19 | 77 | ///
|
20 | 78 | /// @brief This structure comprises function pointers used by corresponding
|
21 | 79 | /// umfMemoryProvider* calls. Each memory provider implementation should
|
@@ -109,62 +167,14 @@ typedef struct umf_memory_provider_ops_t {
|
109 | 167 | umf_result_t (*get_min_page_size)(void *provider, void *ptr,
|
110 | 168 | size_t *pageSize);
|
111 | 169 |
|
112 |
| - /// |
113 |
| - /// @brief Discard physical pages within the virtual memory mapping associated at the given addr |
114 |
| - /// and \p size. This call is asynchronous and may delay purging the pages indefinitely. |
115 |
| - /// @param provider pointer to the memory provider |
116 |
| - /// @param ptr beginning of the virtual memory range |
117 |
| - /// @param size size of the virtual memory range |
118 |
| - /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure. |
119 |
| - /// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. |
120 |
| - /// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. |
121 |
| - /// |
122 |
| - umf_result_t (*purge_lazy)(void *provider, void *ptr, size_t size); |
123 |
| - |
124 |
| - /// |
125 |
| - /// @brief Discard physical pages within the virtual memory mapping associated at the given addr and \p size. |
126 |
| - /// This call is synchronous and if it succeeds, pages are guaranteed to be zero-filled on the next access. |
127 |
| - /// @param provider pointer to the memory provider |
128 |
| - /// @param ptr beginning of the virtual memory range |
129 |
| - /// @param size size of the virtual memory range |
130 |
| - /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
131 |
| - /// UMF_RESULT_ERROR_INVALID_ALIGNMENT if ptr or size is not page-aligned. |
132 |
| - /// UMF_RESULT_ERROR_NOT_SUPPORTED if operation is not supported by this provider. |
133 |
| - /// |
134 |
| - umf_result_t (*purge_force)(void *provider, void *ptr, size_t size); |
135 |
| - |
136 | 170 | ///
|
137 | 171 | /// @brief Retrieve name of a given memory \p provider.
|
138 | 172 | /// @param provider pointer to the memory provider
|
139 | 173 | /// @return pointer to a string containing the name of the \p provider
|
140 | 174 | ///
|
141 | 175 | const char *(*get_name)(void *provider);
|
142 | 176 |
|
143 |
| - /// |
144 |
| - /// @brief Splits a coarse grain allocation into 2 adjacent allocations that |
145 |
| - /// can be managed (freed) separately. |
146 |
| - /// @param hProvider handle to the memory provider |
147 |
| - /// @param ptr pointer to the beginning of the allocation |
148 |
| - /// @param totalSize total size of the allocation to be split |
149 |
| - /// @param firstSize size of the first new allocation, second allocation |
150 |
| - // has a size equal to totalSize - firstSize |
151 |
| - /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
152 |
| - /// |
153 |
| - umf_result_t (*allocation_split)(void *hProvider, void *ptr, |
154 |
| - size_t totalSize, size_t firstSize); |
155 |
| - |
156 |
| - /// |
157 |
| - /// @brief Merges two coarse grain allocations into a single allocation that |
158 |
| - /// can be managed (freed) as a whole. |
159 |
| - /// @param hProvider handle to the memory provider |
160 |
| - /// @param lowPtr pointer to the first allocation |
161 |
| - /// @param highPtr pointer to the second allocation (should be > lowPtr) |
162 |
| - /// @param totalSize size of a new merged allocation. Should be equal |
163 |
| - /// to the sum of sizes of allocations beginning at lowPtr and highPtr |
164 |
| - /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure |
165 |
| - /// |
166 |
| - umf_result_t (*allocation_merge)(void *hProvider, void *lowPtr, |
167 |
| - void *highPtr, size_t totalSize); |
| 177 | + umf_memory_provider_ext_ops_t ext; |
168 | 178 | } umf_memory_provider_ops_t;
|
169 | 179 |
|
170 | 180 | #ifdef __cplusplus
|
|
0 commit comments