Skip to content

Va args #1434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 15, 2025
Merged

Va args #1434

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmark/benchmark_umf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ struct provider_interface {
if (state.thread_index() != 0) {
return;
}
umfCtlExec("umf.provider.by_handle.stats.peak_memory.reset", provider,
NULL, 0);
umfCtlExec("umf.provider.by_handle.{}.stats.peak_memory.reset", NULL, 0,
provider);
}

void postBench([[maybe_unused]] ::benchmark::State &state) {
Expand All @@ -55,8 +55,8 @@ struct provider_interface {
}
size_t arg;
umf_result_t ret =
umfCtlGet("umf.provider.by_handle.stats.allocated_memory", provider,
&arg, sizeof(arg));
umfCtlGet("umf.provider.by_handle.{}.stats.allocated_memory", &arg,
sizeof(arg), provider);
if (ret == UMF_RESULT_SUCCESS) {
state.counters["provider_memory_allocated"] =
static_cast<double>(arg);
Expand Down
11 changes: 8 additions & 3 deletions include/umf/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@ typedef enum umf_ctl_query_type {
CTL_QUERY_READ,
CTL_QUERY_WRITE,
CTL_QUERY_RUNNABLE,
CTL_QUERY_SUBTREE,

MAX_CTL_QUERY_TYPE
} umf_ctl_query_type_t;

typedef enum ctl_query_source {
CTL_UNKNOWN_QUERY_SOURCE,
/* query executed directly from the program */
CTL_QUERY_PROGRAMMATIC,
/* query executed from the config file */
CTL_QUERY_CONFIG_INPUT
} umf_ctl_query_source_t;

#ifdef __cplusplus
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions include/umf/experimental/ctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@ extern "C" {
///
/// @brief Get value of a specified attribute at the given name.
/// @param name name of an attribute to be retrieved
/// @param ctx pointer to the pool or the provider
/// @param arg [out] pointer to the variable where the value will be stored
/// @param size size of the value, depends on the context
/// @param ... additional arguments that can be passed to the callback
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
///
umf_result_t umfCtlGet(const char *name, void *ctx, void *arg, size_t size);
umf_result_t umfCtlGet(const char *name, void *arg, size_t size, ...);

///
/// @brief Set value of a specified attribute at the given name.
/// @param name name of an attribute to be set
/// @param ctx pointer to the pool or the provider, NULL for the 'default' path
/// @param arg [in] pointer to the value that will be set
/// @param size [in] size of the value, depends on the context
/// @param ... additional arguments that can be passed to the callback
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
///
umf_result_t umfCtlSet(const char *name, void *ctx, void *arg, size_t size);
umf_result_t umfCtlSet(const char *name, void *arg, size_t size, ...);

///
/// @brief Execute callback related with the specified attribute.
/// @param name name of an attribute to be executed
/// @param ctx pointer to the pool or the provider
/// @param arg [in/out] pointer to the value, can be used as an input or output
/// @param size [in] size of the value, depends on the context
/// @param ... additional arguments that can be passed to the callback
/// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure.
///
umf_result_t umfCtlExec(const char *name, void *ctx, void *arg, size_t size);
umf_result_t umfCtlExec(const char *name, void *arg, size_t size, ...);

#ifdef __cplusplus
}
Expand Down
11 changes: 7 additions & 4 deletions include/umf/memory_pool_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef UMF_MEMORY_POOL_OPS_H
#define UMF_MEMORY_POOL_OPS_H 1

#include <stdarg.h>

#include <umf/base.h>
#include <umf/memory_provider.h>

Expand Down Expand Up @@ -153,17 +155,18 @@ typedef struct umf_memory_pool_ops_t {
/// on the memory pool.
///
/// @param pool handle to the memory pool.
/// @param operationType type of the operation to be performed.
/// @param source source of the ctl operation.
/// @param name name associated with the operation.
/// @param arg argument for the operation.
/// @param size size of the argument [optional - check name requirements]
/// @param queryType type of the query to be performed.
/// @param args variable arguments for the operation.
///
/// @return umf_result_t result of the control operation.
///
umf_result_t (*ext_ctl)(void *hPool, int operationType, const char *name,
void *arg, size_t size,
umf_ctl_query_type_t queryType);
umf_result_t (*ext_ctl)(void *hPool, umf_ctl_query_source_t source,
const char *name, void *arg, size_t size,
umf_ctl_query_type_t queryType, va_list args);

} umf_memory_pool_ops_t;

Expand Down
11 changes: 7 additions & 4 deletions include/umf/memory_provider_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef UMF_MEMORY_PROVIDER_OPS_H
#define UMF_MEMORY_PROVIDER_OPS_H 1

#include <stdarg.h>

#include <umf/base.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -263,17 +265,18 @@ typedef struct umf_memory_provider_ops_t {
/// Backward compatibility is not guaranteed.
///
/// @param provider handle to the memory provider.
/// @param operationType type of the operation to be performed.
/// @param source source of the ctl operation.
/// @param name name associated with the operation.
/// @param arg argument for the operation.
/// @param size size of the argument [optional - check name requirements]
/// @param queryType type of the query to be performed.
/// @param args variable arguments for the operation.
///
/// @return umf_result_t result of the control operation.
///
umf_result_t (*ext_ctl)(void *provider, int operationType, const char *name,
void *arg, size_t size,
umf_ctl_query_type_t queryType);
umf_result_t (*ext_ctl)(void *provider, umf_ctl_query_source_t source,
const char *name, void *arg, size_t size,
umf_ctl_query_type_t queryType, va_list args);

} umf_memory_provider_ops_t;

Expand Down
Loading
Loading