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
+ /// allocation_split and allocation_merge should be both set or both NULL.
53
+ /// @param hProvider handle to the memory provider
54
+ /// @param lowPtr pointer to the first allocation
55
+ /// @param highPtr pointer to the second allocation (should be > lowPtr)
56
+ /// @param totalSize size of a new merged allocation. Should be equal
57
+ /// to the sum of sizes of allocations beginning at lowPtr and highPtr
58
+ /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure
59
+ ///
60
+ umf_result_t (* allocation_merge )(void * hProvider , void * lowPtr ,
61
+ void * highPtr , size_t totalSize );
62
+
63
+ ///
64
+ /// @brief Splits a coarse grain allocation into 2 adjacent allocations that
65
+ /// can be managed (freed) separately.
66
+ /// allocation_split and allocation_merge should be both set or both NULL.
67
+ /// @param hProvider handle to the memory provider
68
+ /// @param ptr pointer to the beginning of the allocation
69
+ /// @param totalSize total size of the allocation to be split
70
+ /// @param firstSize size of the first new allocation, second allocation
71
+ // has a size equal to totalSize - firstSize
72
+ /// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure
73
+ ///
74
+ umf_result_t (* allocation_split )(void * hProvider , void * ptr ,
75
+ size_t totalSize , size_t firstSize );
76
+
77
+ } umf_memory_provider_ext_ops_t ;
78
+
19
79
///
20
80
/// @brief This structure comprises function pointers used by corresponding
21
81
/// umfMemoryProvider* calls. Each memory provider implementation should
@@ -109,30 +169,6 @@ typedef struct umf_memory_provider_ops_t {
109
169
umf_result_t (* get_min_page_size )(void * provider , void * ptr ,
110
170
size_t * pageSize );
111
171
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
172
///
137
173
/// @brief Retrieve name of a given memory \p provider.
138
174
/// @param provider pointer to the memory provider
@@ -141,30 +177,9 @@ typedef struct umf_memory_provider_ops_t {
141
177
const char * (* get_name )(void * provider );
142
178
143
179
///
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
180
+ /// @brief Optional ops
152
181
///
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 );
182
+ umf_memory_provider_ext_ops_t ext ;
168
183
} umf_memory_provider_ops_t ;
169
184
170
185
#ifdef __cplusplus
0 commit comments