Skip to content

Commit dcd7c9c

Browse files
Merge pull request #1073 from KFilipek/task-ctl_by_handle
[CTL] Add CTL by handle
2 parents 7e68cc8 + d319917 commit dcd7c9c

20 files changed

+597
-99
lines changed

.github/workflows/reusable_compatibility.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ jobs:
110110
run: >
111111
UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
112112
LD_LIBRARY_PATH=${{github.workspace}}/latest_version/build/lib/
113-
ctest --output-on-failure
113+
ctest --output-on-failure -E "umf-mempolicy" # disable tests that rely on internal structures
114114
115115
windows-build:
116116
name: Windows

include/umf/base.h

+37
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,43 @@ typedef enum umf_result_t {
5050
UMF_RESULT_ERROR_UNKNOWN = 0x7ffffffe ///< Unknown or internal error
5151
} umf_result_t;
5252

53+
/// @brief Type of the CTL query
54+
typedef enum umf_ctl_query_type {
55+
CTL_QUERY_READ,
56+
CTL_QUERY_WRITE,
57+
CTL_QUERY_RUNNABLE,
58+
CTL_QUERY_SUBTREE,
59+
60+
MAX_CTL_QUERY_TYPE
61+
} umf_ctl_query_type_t;
62+
63+
///
64+
/// @brief Get value of a specified attribute at the given name.
65+
/// @param name name of an attribute to be retrieved
66+
/// @param ctx pointer to the pool or the provider
67+
/// @param arg [out] pointer to the variable where the value will be stored
68+
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
69+
///
70+
umf_result_t umfCtlGet(const char *name, void *ctx, void *arg);
71+
72+
///
73+
/// @brief Set value of a specified attribute at the given name.
74+
/// @param name name of an attribute to be set
75+
/// @param ctx pointer to the pool or the provider
76+
/// @param arg [in] pointer to the value that will be set
77+
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
78+
///
79+
umf_result_t umfCtlSet(const char *name, void *ctx, void *arg);
80+
81+
///
82+
/// @brief Execute callback related with the specified attribute.
83+
/// @param name name of an attribute to be executed
84+
/// @param ctx pointer to the pool or the provider
85+
/// @param arg [in/out] pointer to the value, can be used as an input or output
86+
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
87+
///
88+
umf_result_t umfCtlExec(const char *name, void *ctx, void *arg);
89+
5390
#ifdef __cplusplus
5491
}
5592
#endif

include/umf/memory_pool_ops.h

+16
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,22 @@ typedef struct umf_memory_pool_ops_t {
125125
/// The value is undefined if the previous allocation was successful.
126126
///
127127
umf_result_t (*get_last_allocation_error)(void *pool);
128+
129+
///
130+
/// @brief Control operation for the memory pool.
131+
/// The function is used to perform various control operations
132+
/// on the memory pool.
133+
///
134+
/// @param hPool handle to the memory pool.
135+
/// @param operationType type of the operation to be performed.
136+
/// @param name name associated with the operation.
137+
/// @param arg argument for the operation.
138+
/// @param queryType type of the query to be performed.
139+
///
140+
/// @return umf_result_t result of the control operation.
141+
///
142+
umf_result_t (*ctl)(void *hPool, int operationType, const char *name,
143+
void *arg, umf_ctl_query_type_t queryType);
128144
} umf_memory_pool_ops_t;
129145

130146
#ifdef __cplusplus

include/umf/memory_provider_ops.h

+17-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ typedef struct umf_memory_provider_ext_ops_t {
8282
///
8383
umf_result_t (*allocation_split)(void *hProvider, void *ptr,
8484
size_t totalSize, size_t firstSize);
85-
8685
} umf_memory_provider_ext_ops_t;
8786

8887
///
@@ -250,6 +249,23 @@ typedef struct umf_memory_provider_ops_t {
250249
/// @brief Optional IPC ops. The API allows sharing of memory objects across different processes.
251250
///
252251
umf_memory_provider_ipc_ops_t ipc;
252+
253+
///
254+
/// @brief Control operation for the memory provider.
255+
/// The function is used to perform various control operations
256+
/// on the memory provider.
257+
///
258+
/// @param hProvider handle to the memory provider.
259+
/// @param operationType type of the operation to be performed.
260+
/// @param name name associated with the operation.
261+
/// @param arg argument for the operation.
262+
/// @param queryType type of the query to be performed.
263+
///
264+
/// @return umf_result_t result of the control operation.
265+
///
266+
umf_result_t (*ctl)(void *hProvider, int operationType, const char *name,
267+
void *arg, umf_ctl_query_type_t queryType);
268+
253269
} umf_memory_provider_ops_t;
254270

255271
#ifdef __cplusplus

0 commit comments

Comments
 (0)