Skip to content

Commit e8e9a64

Browse files
committed
[CTL] Add CTL functionality (by handle access)
This commit introduces the control and introspection mechanism that can be accessed using pointer to supported pool or provider.
1 parent f36d893 commit e8e9a64

18 files changed

+563
-94
lines changed

include/umf/base.h

Lines changed: 37 additions & 0 deletions
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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,25 @@ extern "C" {
2222
/// has been modified.
2323
#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
2424

25+
/// @brief This structure comprises function pointers used by corresponding umfMemoryPool calls.
26+
typedef struct umf_memory_pool_ext_ops_t {
27+
///
28+
/// @brief Control operation for the memory pool.
29+
/// The function is used to perform various control operations
30+
/// on the memory pool.
31+
///
32+
/// @param hPool handle to the memory pool.
33+
/// @param operationType type of the operation to be performed.
34+
/// @param name name associated with the operation.
35+
/// @param arg argument for the operation.
36+
/// @param queryType type of the query to be performed.
37+
///
38+
/// @return umf_result_t result of the control operation.
39+
///
40+
umf_result_t (*ctl)(void *hPool, int operationType, const char *name,
41+
void *arg, umf_ctl_query_type_t queryType);
42+
} umf_memory_pool_ext_ops_t;
43+
2544
///
2645
/// @brief This structure comprises function pointers used by corresponding umfPool*
2746
/// calls. Each memory pool implementation should initialize all function
@@ -125,6 +144,11 @@ typedef struct umf_memory_pool_ops_t {
125144
/// The value is undefined if the previous allocation was successful.
126145
///
127146
umf_result_t (*get_last_allocation_error)(void *pool);
147+
148+
///
149+
/// @brief Optional ops
150+
///
151+
umf_memory_provider_ext_ops_t ext;
128152
} umf_memory_pool_ops_t;
129153

130154
#ifdef __cplusplus

include/umf/memory_provider_ops.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
*
88
*/
9-
109
#ifndef UMF_MEMORY_PROVIDER_OPS_H
1110
#define UMF_MEMORY_PROVIDER_OPS_H 1
1211

@@ -83,6 +82,22 @@ typedef struct umf_memory_provider_ext_ops_t {
8382
umf_result_t (*allocation_split)(void *hProvider, void *ptr,
8483
size_t totalSize, size_t firstSize);
8584

85+
///
86+
/// @brief Control operation for the memory provider.
87+
/// The function is used to perform various control operations
88+
/// on the memory provider.
89+
///
90+
/// @param hProvider handle to the memory provider.
91+
/// @param operationType type of the operation to be performed.
92+
/// @param name name associated with the operation.
93+
/// @param arg argument for the operation.
94+
/// @param queryType type of the query to be performed.
95+
///
96+
/// @return umf_result_t result of the control operation.
97+
///
98+
umf_result_t (*ctl)(void *hProvider, int operationType, const char *name,
99+
void *arg, umf_ctl_query_type_t queryType);
100+
86101
} umf_memory_provider_ext_ops_t;
87102

88103
///

0 commit comments

Comments
 (0)