Skip to content

Commit e90fbed

Browse files
committed
make get_name not experimental
1 parent a2a0919 commit e90fbed

File tree

10 files changed

+46
-22
lines changed

10 files changed

+46
-22
lines changed

include/umf/base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ extern "C" {
2828
#define UMF_MINOR_VERSION(_ver) (_ver & 0x0000ffff)
2929

3030
/// @brief Current version of the UMF headers
31-
#define UMF_VERSION_CURRENT UMF_MAKE_VERSION(0, 11)
31+
#define UMF_VERSION_CURRENT UMF_MAKE_VERSION(0, 12)
3232

3333
/// @brief Operation results
3434
typedef enum umf_result_t {

include/umf/memory_pool_ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ typedef struct umf_memory_pool_ops_t {
130130
umf_result_t (*get_last_allocation_error)(void *pool);
131131

132132
///
133-
/// Following functions, with ext prefix, are optional and memory pool implementation
134-
/// can keep them NULL.
133+
/// The following function is optional and memory pool implementation
134+
/// can keep it NULL.
135135
///
136136

137137
///
@@ -163,7 +163,7 @@ typedef struct umf_memory_pool_ops_t {
163163
/// otherwise the pool's name is returned.
164164
/// @return UMF_RESULT_SUCCESS on success or appropriate error code on failure.
165165
///
166-
umf_result_t (*ext_get_name)(void *pool, const char **name);
166+
umf_result_t (*get_name)(void *pool, const char **name);
167167
} umf_memory_pool_ops_t;
168168

169169
#ifdef __cplusplus

src/memory_pool.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,10 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
210210
// Set default property "name" to pool if exists
211211
for (int i = 0; i < UMF_DEFAULT_SIZE; i++) {
212212
const char *pname = NULL;
213-
if (ops->ext_get_name) {
214-
ret = ops->ext_get_name(NULL, &pname);
215-
if (ret != UMF_RESULT_SUCCESS) {
216-
LOG_ERR("Failed to get pool name");
217-
goto err_pool_init;
218-
}
219-
} else {
220-
LOG_INFO("Pool name getter is not implemented, CTL defaults "
221-
"settings are not supported for this pool");
222-
break;
213+
ret = ops->get_name(NULL, &pname);
214+
if (ret != UMF_RESULT_SUCCESS) {
215+
LOG_ERR("Failed to get pool name");
216+
goto err_pool_init;
223217
}
224218
if (CTL_DEFAULT_ENTRIES[i][0] != '\0' && pname &&
225219
strstr(CTL_DEFAULT_ENTRIES[i], pname)) {
@@ -314,11 +308,7 @@ umf_result_t umfPoolGetMemoryProvider(umf_memory_pool_handle_t hPool,
314308
umf_result_t umfPoolGetName(umf_memory_pool_handle_t pool, const char **name) {
315309
UMF_CHECK((pool != NULL), UMF_RESULT_ERROR_INVALID_ARGUMENT);
316310
UMF_CHECK((name != NULL), UMF_RESULT_ERROR_INVALID_ARGUMENT);
317-
if (pool->ops.ext_get_name == NULL) {
318-
*name = NULL;
319-
return UMF_RESULT_ERROR_NOT_SUPPORTED;
320-
}
321-
return pool->ops.ext_get_name(pool->pool_priv, name);
311+
return pool->ops.get_name(pool->pool_priv, name);
322312
}
323313

324314
umf_result_t umfPoolCreate(const umf_memory_pool_ops_t *ops,

src/pool/pool_disjoint.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ static umf_memory_pool_ops_t UMF_DISJOINT_POOL_OPS = {
10561056
.malloc_usable_size = disjoint_pool_malloc_usable_size,
10571057
.free = disjoint_pool_free,
10581058
.get_last_allocation_error = disjoint_pool_get_last_allocation_error,
1059-
.ext_get_name = disjoint_pool_get_name,
1059+
.get_name = disjoint_pool_get_name,
10601060
.ext_ctl = disjoint_pool_ctl,
10611061
};
10621062

src/pool/pool_jemalloc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,12 @@ static umf_result_t op_get_last_allocation_error(void *pool) {
557557
return TLS_last_allocation_error;
558558
}
559559

560+
static umf_result_t op_get_name(void *pool, const char **name) {
561+
(void)pool;
562+
*name = "jemalloc";
563+
return UMF_RESULT_SUCCESS;
564+
}
565+
560566
static umf_memory_pool_ops_t UMF_JEMALLOC_POOL_OPS = {
561567
.version = UMF_POOL_OPS_VERSION_CURRENT,
562568
.initialize = op_initialize,
@@ -568,6 +574,7 @@ static umf_memory_pool_ops_t UMF_JEMALLOC_POOL_OPS = {
568574
.malloc_usable_size = op_malloc_usable_size,
569575
.free = op_free,
570576
.get_last_allocation_error = op_get_last_allocation_error,
577+
.get_name = op_get_name,
571578
};
572579

573580
const umf_memory_pool_ops_t *umfJemallocPoolOps(void) {

src/pool/pool_proxy.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ static umf_result_t proxy_get_last_allocation_error(void *pool) {
130130
return TLS_last_allocation_error;
131131
}
132132

133+
static umf_result_t proxy_get_name(void *pool, const char **name) {
134+
(void)pool;
135+
*name = "proxy";
136+
return UMF_RESULT_SUCCESS;
137+
}
138+
133139
static umf_memory_pool_ops_t UMF_PROXY_POOL_OPS = {
134140
.version = UMF_POOL_OPS_VERSION_CURRENT,
135141
.initialize = proxy_pool_initialize,
@@ -140,7 +146,8 @@ static umf_memory_pool_ops_t UMF_PROXY_POOL_OPS = {
140146
.aligned_malloc = proxy_aligned_malloc,
141147
.malloc_usable_size = proxy_malloc_usable_size,
142148
.free = proxy_free,
143-
.get_last_allocation_error = proxy_get_last_allocation_error};
149+
.get_last_allocation_error = proxy_get_last_allocation_error,
150+
.get_name = proxy_get_name};
144151

145152
const umf_memory_pool_ops_t *umfProxyPoolOps(void) {
146153
return &UMF_PROXY_POOL_OPS;

src/pool/pool_scalable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ static umf_memory_pool_ops_t UMF_SCALABLE_POOL_OPS = {
449449
.free = tbb_free,
450450
.get_last_allocation_error = tbb_get_last_allocation_error,
451451
.ext_ctl = pool_ctl,
452-
.ext_get_name = scalable_get_name,
452+
.get_name = scalable_get_name,
453453
};
454454

455455
const umf_memory_pool_ops_t *umfScalablePoolOps(void) {

test/common/pool_null.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ static umf_result_t nullGetLastStatus(void *pool) {
7070
return UMF_RESULT_SUCCESS;
7171
}
7272

73+
static umf_result_t nullGetName(void *pool, const char **name) {
74+
(void)pool;
75+
*name = "null";
76+
return UMF_RESULT_SUCCESS;
77+
}
78+
7379
umf_memory_pool_ops_t UMF_NULL_POOL_OPS = {
7480
.version = UMF_POOL_OPS_VERSION_CURRENT,
7581
.initialize = nullInitialize,
@@ -81,4 +87,5 @@ umf_memory_pool_ops_t UMF_NULL_POOL_OPS = {
8187
.malloc_usable_size = nullMallocUsableSize,
8288
.free = nullFree,
8389
.get_last_allocation_error = nullGetLastStatus,
90+
.get_name = nullGetName,
8491
};

test/common/pool_trace.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ static umf_result_t traceGetLastStatus(void *pool) {
9393
return umfPoolGetLastAllocationError(trace_pool->params.hUpstreamPool);
9494
}
9595

96+
static umf_result_t traceGetName(void *pool, const char **name) {
97+
(void)pool;
98+
*name = "trace";
99+
return UMF_RESULT_SUCCESS;
100+
}
101+
96102
umf_memory_pool_ops_t UMF_TRACE_POOL_OPS = {
97103
.version = UMF_POOL_OPS_VERSION_CURRENT,
98104
.initialize = traceInitialize,
@@ -104,4 +110,5 @@ umf_memory_pool_ops_t UMF_TRACE_POOL_OPS = {
104110
.malloc_usable_size = traceMallocUsableSize,
105111
.free = traceFree,
106112
.get_last_allocation_error = traceGetLastStatus,
113+
.get_name = traceGetName,
107114
};

test/utils/cpp_helpers.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ template <typename T> umf_memory_pool_ops_t poolOpsBase() {
7979
UMF_ASSIGN_OP(ops, T, malloc_usable_size, UMF_RESULT_SUCCESS);
8080
UMF_ASSIGN_OP(ops, T, free, UMF_RESULT_SUCCESS);
8181
UMF_ASSIGN_OP(ops, T, get_last_allocation_error, UMF_RESULT_ERROR_UNKNOWN);
82+
ops.get_name = [](void *, const char **name) {
83+
if (name) {
84+
*name = "test_pool";
85+
}
86+
return UMF_RESULT_SUCCESS;
87+
};
8288
return ops;
8389
}
8490

0 commit comments

Comments
 (0)