blob: 6b1404bc3cdd3279fbcca95bb1e0999a860d59a1 [file] [log] [blame]
Gilles Peskine87270e52023-11-02 17:14:01 +01001/**
2 * \file memory.c
3 *
4 * \brief Helper functions related to testing memory management.
5 */
6
7/*
8 * Copyright The Mbed TLS Contributors
9 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
10 */
11
12#include <test/helpers.h>
13#include <test/macros.h>
14#include <test/memory.h>
15
Gilles Peskine071d1442023-11-02 20:49:34 +010016#if defined(MBEDTLS_TEST_HAVE_ASAN)
17#include <sanitizer/asan_interface.h>
18#include <stdint.h>
19#endif
20
21#if defined(MBEDTLS_TEST_HAVE_ASAN)
22void mbedtls_test_memory_poison(const unsigned char *ptr, size_t size)
23{
24 if (size == 0) {
25 return;
26 }
27 __asan_poison_memory_region(ptr, size);
28}
29
30void mbedtls_test_memory_unpoison(const unsigned char *ptr, size_t size)
31{
32 if (size == 0) {
33 return;
34 }
35 __asan_unpoison_memory_region(ptr, size);
36}
37#endif /* Asan */