Skip to content

Commit 76a9875

Browse files
committed
implement valgrind macros used in critnib
1 parent 46bca11 commit 76a9875

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
@@ -174,8 +174,8 @@ struct critnib *critnib_new(void) {
174174
goto err_free_critnib;
175175
}
176176

177-
VALGRIND_HG_DRD_DISABLE_CHECKING(&c->root, sizeof(c->root));
178-
VALGRIND_HG_DRD_DISABLE_CHECKING(&c->remove_count, sizeof(c->remove_count));
177+
utils_annotate_memory_no_check(&c->root, sizeof(c->root));
178+
utils_annotate_memory_no_check(&c->remove_count, sizeof(c->remove_count));
179179

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

262262
c->deleted_node = n->child[0];
263-
VALGRIND_ANNOTATE_NEW_MEMORY(n, sizeof(*n));
263+
utils_annotate_memory_new(n, sizeof(*n));
264264

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

293293
c->deleted_leaf = k->value;
294-
VALGRIND_ANNOTATE_NEW_MEMORY(k, sizeof(*k));
294+
utils_annotate_memory_new(k, sizeof(*k));
295295

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

319-
VALGRIND_HG_DRD_DISABLE_CHECKING(k, sizeof(struct critnib_leaf));
319+
utils_annotate_memory_no_check(k, sizeof(struct critnib_leaf));
320320

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

378378
return ENOMEM;
379379
}
380-
VALGRIND_HG_DRD_DISABLE_CHECKING(m, sizeof(struct critnib_node));
380+
utils_annotate_memory_no_check(m, sizeof(struct critnib_node));
381381

382382
for (int i = 0; i < SLNODES; i++) {
383383
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)