diff --git a/include/umf/base.h b/include/umf/base.h index cc6b0ccbd..d2480abe0 100644 --- a/include/umf/base.h +++ b/include/umf/base.h @@ -63,29 +63,26 @@ typedef enum umf_ctl_query_type { /// /// @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 ... number and type of arguments depends on the given name /// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure. /// -umf_result_t umfCtlGet(const char *name, void *ctx, void *arg); +umf_result_t umfCtlGet(const char *name, ...); /// /// @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 -/// @param arg [in] pointer to the value that will be set +/// @param ... number and type of arguments depends on the given name /// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure. /// -umf_result_t umfCtlSet(const char *name, void *ctx, void *arg); +umf_result_t umfCtlSet(const char *name, ...); /// /// @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 ... number and type of arguments depends on the given name /// @return UMF_RESULT_SUCCESS on success or UMF_RESULT_ERROR_UNKNOWN on failure. /// -umf_result_t umfCtlExec(const char *name, void *ctx, void *arg); +umf_result_t umfCtlExec(const char *name, ...); #ifdef __cplusplus } diff --git a/include/umf/memory_pool_ops.h b/include/umf/memory_pool_ops.h index bf44383b4..df3cf1ebc 100644 --- a/include/umf/memory_pool_ops.h +++ b/include/umf/memory_pool_ops.h @@ -20,7 +20,7 @@ extern "C" { /// @brief Version of the Memory Pool ops structure. /// NOTE: This is equal to the latest UMF version, in which the ops structure /// has been modified. -#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11) +#define UMF_POOL_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 12) /// /// @brief This structure comprises function pointers used by corresponding umfPool* diff --git a/include/umf/memory_provider_ops.h b/include/umf/memory_provider_ops.h index 638f2975b..5a7995b6a 100644 --- a/include/umf/memory_provider_ops.h +++ b/include/umf/memory_provider_ops.h @@ -19,7 +19,7 @@ extern "C" { /// @brief Version of the Memory Provider ops structure. /// NOTE: This is equal to the latest UMF version, in which the ops structure /// has been modified. -#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 11) +#define UMF_PROVIDER_OPS_VERSION_CURRENT UMF_MAKE_VERSION(0, 12) /// /// @brief This structure comprises optional function pointers used diff --git a/src/ctl/ctl.c b/src/ctl/ctl.c index 99ab2d96e..131e71255 100644 --- a/src/ctl/ctl.c +++ b/src/ctl/ctl.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -81,30 +82,54 @@ char *Strdup(const char *s) { return p; } -umf_result_t umfCtlGet(const char *name, void *ctx, void *arg) { - if (name == NULL || arg == NULL || ctx == NULL) { - return UMF_RESULT_ERROR_INVALID_ARGUMENT; - } +umf_result_t umfCtlGet(const char *name, ...) { + assert(name != NULL); + + va_list args; + va_start(args, name); + + void *ctx = va_arg(args, void *); + void *arg = va_arg(args, void *); + va_end(args); + + assert(arg != NULL); + assert(ctx != NULL); return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, CTL_QUERY_READ, arg) ? UMF_RESULT_ERROR_UNKNOWN : UMF_RESULT_SUCCESS; } -umf_result_t umfCtlSet(const char *name, void *ctx, void *arg) { - if (name == NULL || arg == NULL || ctx == NULL) { - return UMF_RESULT_ERROR_INVALID_ARGUMENT; - } +umf_result_t umfCtlSet(const char *name, ...) { + assert(name != NULL); + + va_list args; + va_start(args, name); + + void *ctx = va_arg(args, void *); + void *arg = va_arg(args, void *); + va_end(args); + + assert(arg != NULL); + assert(ctx != NULL); return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, CTL_QUERY_WRITE, arg) ? UMF_RESULT_ERROR_UNKNOWN : UMF_RESULT_SUCCESS; } -umf_result_t umfCtlExec(const char *name, void *ctx, void *arg) { - if (name == NULL || arg == NULL || ctx == NULL) { - return UMF_RESULT_ERROR_INVALID_ARGUMENT; - } +umf_result_t umfCtlExec(const char *name, ...) { + assert(name != NULL); + + va_list args; + va_start(args, name); + + void *ctx = va_arg(args, void *); + void *arg = va_arg(args, void *); + va_end(args); + + assert(arg != NULL); + assert(ctx != NULL); return ctl_query(NULL, ctx, CTL_QUERY_PROGRAMMATIC, name, CTL_QUERY_RUNNABLE, arg) ? UMF_RESULT_ERROR_UNKNOWN diff --git a/src/libumf.def b/src/libumf.def index dd0ddfbfc..34ecee889 100644 --- a/src/libumf.def +++ b/src/libumf.def @@ -119,9 +119,6 @@ EXPORTS umfScalablePoolParamsSetKeepAllMemory ; Added in UMF_0.11 umfCUDAMemoryProviderParamsSetAllocFlags - umfCtlExec - umfCtlGet - umfCtlSet umfDisjointPoolOps umfDisjointPoolParamsCreate umfDisjointPoolParamsDestroy @@ -139,3 +136,7 @@ EXPORTS umfFixedMemoryProviderParamsDestroy umfLevelZeroMemoryProviderParamsSetFreePolicy umfLevelZeroMemoryProviderParamsSetDeviceOrdinal +; Added in UMF_0.12 + umfCtlExec + umfCtlGet + umfCtlSet diff --git a/src/libumf.map b/src/libumf.map index 5e97acc09..21b16fe01 100644 --- a/src/libumf.map +++ b/src/libumf.map @@ -117,9 +117,6 @@ UMF_0.10 { UMF_0.11 { umfCUDAMemoryProviderParamsSetAllocFlags; - umfCtlExec; - umfCtlGet; - umfCtlSet; umfDisjointPoolOps; umfDisjointPoolParamsCreate; umfDisjointPoolParamsDestroy; @@ -138,3 +135,9 @@ UMF_0.11 { umfLevelZeroMemoryProviderParamsSetFreePolicy; umfLevelZeroMemoryProviderParamsSetDeviceOrdinal; } UMF_0.10; + +UMF_0.12 { + umfCtlExec; + umfCtlGet; + umfCtlSet; +} UMF_0.11;