Skip to content

Commit 172429a

Browse files
committed
NEW
1 parent 5b35410 commit 172429a

File tree

9 files changed

+23
-17
lines changed

9 files changed

+23
-17
lines changed

.github/workflows/reusable_compatibility.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
229229
- name: Run disabled tests individually with latest UMF libs (warnings enabled)
230230
working-directory: ${{github.workspace}}/tag_version/build
231-
run: >
231+
run: |
232232
$env:UMF_LOG="level:warning;flush:debug;output:stderr;pid:no"
233233
cp ${{github.workspace}}/latest_version/build/bin/Debug/umf.dll ${{github.workspace}}/tag_version/build/bin/Debug/umf.dll
234234
# Run the test_disjoint_pool with the latest UMF libs, excluding disjoint pool internals

include/umf/base.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ extern "C" {
3030
/// @brief Current version of the UMF headers
3131
#define UMF_VERSION_CURRENT UMF_MAKE_VERSION(1, 0)
3232

33+
// Is current version below specified version?
34+
#define UMF_VERSION_BELOW(_major, _minor) \
35+
(UMF_MAJOR_VERSION(UMF_VERSION_CURRENT) < (_major) || \
36+
(UMF_MAJOR_VERSION(UMF_VERSION_CURRENT) == (_major) && \
37+
UMF_MINOR_VERSION(UMF_VERSION_CURRENT) < (_minor))) \
38+
3339
/// @brief Operation results
3440
typedef enum umf_result_t {
3541
UMF_RESULT_SUCCESS = 0, ///< Success

include/umf/memory_pool_ops.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ typedef struct umf_memory_pool_ops_t {
194194
/// @brief Post-initializes and set up memory pool.
195195
///
196196
/// \details
197-
/// * This function must be implemented if the pool/provider supports CTL that overrides defaults
197+
/// * This function *must* be implemented if the pool/provider supports CTL that overrides defaults.
198+
/// * This function *must* free any resources allocated in the function.
198199
/// * This function *must* be called after the memory pool has been allocated in initialize function
199200
/// and is used to perform any additional setup required by the memory pool.
200201
/// * This function *may* be used to set up any additional resources required by the memory pool.

include/umf/memory_provider_ops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,8 @@ typedef struct umf_memory_provider_ops_t {
278278
const char *name, void *arg, size_t size,
279279
umf_ctl_query_type_t queryType, va_list args);
280280

281+
// The following operations were added in ops version 1.1
282+
281283
///
282284
/// @brief Post-initializes memory provider.
283285
/// @param params provider-specific params, or NULL for defaults

src/memory_pool.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
265265

266266
// Create a new ops compatible structure with the current version
267267
memset(&compatible_ops, 0, sizeof(compatible_ops));
268-
if (UMF_MINOR_VERSION(ops->version) == 0) {
269-
LOG_INFO("Detected 1.0 version of Memory Pool ops, "
268+
if(UMF_VERSION_BELOW(1, 1)) {
269+
LOG_INFO("Detected 1.0 version or below of Memory Pool ops, "
270270
"upgrading to current version");
271271
memcpy(&compatible_ops, ops,
272272
offsetof(umf_memory_pool_ops_t, ext_trim_memory));
@@ -344,8 +344,7 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
344344
}
345345
}
346346

347-
ret =
348-
pool->ops.ext_post_initialize(pool->pool_priv);
347+
ret = pool->ops.ext_post_initialize(pool->pool_priv);
349348
if (ret != UMF_RESULT_SUCCESS) {
350349
LOG_ERR("Failed to post-initialize pool");
351350
goto err_pool_init;

src/pool/pool_disjoint.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,8 +763,7 @@ umf_result_t disjoint_pool_initialize(umf_memory_provider_handle_t provider,
763763
return UMF_RESULT_SUCCESS;
764764
}
765765

766-
umf_result_t
767-
disjoint_pool_post_initialize(void *ppPool) {
766+
umf_result_t disjoint_pool_post_initialize(void *ppPool) {
768767
disjoint_pool_t *disjoint_pool = (disjoint_pool_t *)ppPool;
769768

770769
disjoint_pool->known_slabs = critnib_new(free_slab, NULL);

src/pool/pool_jemalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
446446
return UMF_RESULT_ERROR_OUT_OF_HOST_MEMORY;
447447
}
448448
memset(pool, 0, sizeof(*pool));
449-
449+
450450
pool->provider = provider;
451451
if (params) {
452452
pool->params = *(const umf_jemalloc_pool_params_t *)params;
@@ -455,7 +455,7 @@ static umf_result_t op_initialize(umf_memory_provider_handle_t provider,
455455
memset(&pool->params, 0, sizeof(pool->params));
456456
strncpy(pool->params.name, DEFAULT_NAME, sizeof(pool->params.name) - 1);
457457
}
458-
458+
459459
*out_pool = pool;
460460

461461
return UMF_RESULT_SUCCESS;

src/pool/pool_proxy.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ proxy_pool_initialize(umf_memory_provider_handle_t hProvider,
3939
return UMF_RESULT_SUCCESS;
4040
}
4141

42-
static umf_result_t
43-
proxy_pool_post_initialize(void *ppPool) {
42+
static umf_result_t proxy_pool_post_initialize(void *ppPool) {
4443
(void)ppPool;
4544
return UMF_RESULT_SUCCESS;
4645
}

src/pool/pool_scalable.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,24 +301,24 @@ static umf_result_t tbb_pool_initialize(umf_memory_provider_handle_t provider,
301301

302302
memset(pool_data, 0, sizeof(*pool_data));
303303
pool_data->mem_provider = provider;
304-
304+
305305
if (params) {
306306
pool_data->params = *(const umf_scalable_pool_params_t *)params;
307307
} else {
308308
// Set default values
309309
memset(&pool_data->params, 0, sizeof(pool_data->params));
310310
pool_data->params.granularity = DEFAULT_GRANULARITY;
311311
pool_data->params.keep_all_memory = false;
312-
strncpy(pool_data->params.name, DEFAULT_NAME, sizeof(pool_data->params.name) - 1);
312+
strncpy(pool_data->params.name, DEFAULT_NAME,
313+
sizeof(pool_data->params.name) - 1);
313314
}
314315

315316
*pool = (void *)pool_data;
316317

317318
return UMF_RESULT_SUCCESS;
318319
}
319320

320-
static umf_result_t
321-
tbb_pool_post_initialize(void *pool) {
321+
static umf_result_t tbb_pool_post_initialize(void *pool) {
322322
tbb_mem_pool_policy_t policy = {.pAlloc = tbb_raw_alloc_wrapper,
323323
.pFree = tbb_raw_free_wrapper,
324324
.granularity = DEFAULT_GRANULARITY,
@@ -335,7 +335,7 @@ tbb_pool_post_initialize(void *pool) {
335335

336336
const umf_scalable_pool_params_t *scalable_params = &pool_data->params;
337337
const char *pool_name = scalable_params->name;
338-
338+
339339
// Use stored params
340340
policy.granularity = scalable_params->granularity;
341341
policy.keep_all_memory = scalable_params->keep_all_memory;

0 commit comments

Comments
 (0)