Skip to content

Commit 02ccc4c

Browse files
committed
implement valgrind macros used in critnib
1 parent 0a4d3c7 commit 02ccc4c

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

src/critnib/critnib.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ struct critnib *critnib_new(void) {
173173
goto err_free_critnib;
174174
}
175175

176-
VALGRIND_HG_DRD_DISABLE_CHECKING(&c->root, sizeof(c->root));
177-
VALGRIND_HG_DRD_DISABLE_CHECKING(&c->remove_count, sizeof(c->remove_count));
176+
utils_annotate_memory_no_check(&c->root, sizeof(c->root));
177+
utils_annotate_memory_no_check(&c->remove_count, sizeof(c->remove_count));
178178

179179
return c;
180180
err_free_critnib:
@@ -259,7 +259,7 @@ static struct critnib_node *alloc_node(struct critnib *__restrict c) {
259259
struct critnib_node *n = c->deleted_node;
260260

261261
c->deleted_node = n->child[0];
262-
VALGRIND_ANNOTATE_NEW_MEMORY(n, sizeof(*n));
262+
utils_annotate_memory_new(n, sizeof(*n));
263263

264264
return n;
265265
}
@@ -290,7 +290,7 @@ static struct critnib_leaf *alloc_leaf(struct critnib *__restrict c) {
290290
struct critnib_leaf *k = c->deleted_leaf;
291291

292292
c->deleted_leaf = k->value;
293-
VALGRIND_ANNOTATE_NEW_MEMORY(k, sizeof(*k));
293+
utils_annotate_memory_new(k, sizeof(*k));
294294

295295
return k;
296296
}
@@ -315,7 +315,7 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) {
315315
return ENOMEM;
316316
}
317317

318-
VALGRIND_HG_DRD_DISABLE_CHECKING(k, sizeof(struct critnib_leaf));
318+
utils_annotate_memory_no_check(k, sizeof(struct critnib_leaf));
319319

320320
k->key = key;
321321
k->value = value;
@@ -376,7 +376,7 @@ int critnib_insert(struct critnib *c, word key, void *value, int update) {
376376

377377
return ENOMEM;
378378
}
379-
VALGRIND_HG_DRD_DISABLE_CHECKING(m, sizeof(struct critnib_node));
379+
utils_annotate_memory_no_check(m, sizeof(struct critnib_node));
380380

381381
for (int i = 0; i < SLNODES; i++) {
382382
m->child[i] = NULL;

src/utils/utils_common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ typedef enum umf_purge_advise_t {
5353
#define ASSERT_IS_ALIGNED(value, align) \
5454
DO_WHILE_EXPRS(assert(IS_ALIGNED(value, align)))
5555

56-
#define VALGRIND_ANNOTATE_NEW_MEMORY(p, s) DO_WHILE_EMPTY
57-
#define VALGRIND_HG_DRD_DISABLE_CHECKING(p, s) DO_WHILE_EMPTY
58-
5956
#ifdef _WIN32 /* Windows */
6057

6158
#define __TLS __declspec(thread)

src/utils/utils_sanitizers.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
*
3-
* Copyright (C) 2024 Intel Corporation
3+
* Copyright (C) 2024-2025 Intel Corporation
44
*
55
* Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
66
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
@@ -168,6 +168,24 @@ static inline void utils_annotate_memory_inaccessible(void *ptr, size_t size) {
168168
#endif
169169
}
170170

171+
static inline void utils_annotate_memory_new(void *ptr, size_t size) {
172+
#ifdef UMF_VG_DRD_ENABLED
173+
ANNOTATE_NEW_MEMORY(ptr, size);
174+
#else
175+
(void)ptr;
176+
(void)size;
177+
#endif
178+
}
179+
180+
static inline void utils_annotate_memory_no_check(void *ptr, size_t size) {
181+
#ifdef UMF_VG_HELGRIND_ENABLED
182+
VALGRIND_HG_DISABLE_CHECKING(ptr, size);
183+
#else
184+
(void)ptr;
185+
(void)size;
186+
#endif
187+
}
188+
171189
#ifdef __cplusplus
172190
}
173191
#endif

0 commit comments

Comments
 (0)