summaryrefslogtreecommitdiff
path: root/source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2022-12-01 13:43:10 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2022-12-01 13:43:10 +0100
commit08fa92c1c94d9faddee48590a1a20506e89c191c (patch)
tree12bbf6fa56b69c47340d4c15f8f601be2d9487b5 /source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h
parent2593c827482f6c5a315d504cd5316879d6172656 (diff)
downloadcontext-08fa92c1c94d9faddee48590a1a20506e89c191c.tar.gz
2022-12-01 12:41:00
Diffstat (limited to 'source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h')
-rw-r--r--source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h b/source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h
new file mode 100644
index 000000000..bb9df4fa3
--- /dev/null
+++ b/source/luametatex/source/libraries/mimalloc/include/mimalloc-track.h
@@ -0,0 +1,43 @@
+/* ----------------------------------------------------------------------------
+Copyright (c) 2018-2021, Microsoft Research, Daan Leijen
+This is free software; you can redistribute it and/or modify it under the
+terms of the MIT license. A copy of the license can be found in the file
+"LICENSE" at the root of this distribution.
+-----------------------------------------------------------------------------*/
+#pragma once
+#ifndef MIMALLOC_TRACK_H
+#define MIMALLOC_TRACK_H
+
+// ------------------------------------------------------
+// Track memory ranges with macros for tools like Valgrind
+// or other memory checkers.
+// ------------------------------------------------------
+
+#if MI_VALGRIND
+
+#define MI_TRACK_ENABLED 1
+
+#include <valgrind/valgrind.h>
+#include <valgrind/memcheck.h>
+
+#define mi_track_malloc(p,size,zero) VALGRIND_MALLOCLIKE_BLOCK(p,size,MI_PADDING_SIZE /*red zone*/,zero)
+#define mi_track_resize(p,oldsize,newsize) VALGRIND_RESIZEINPLACE_BLOCK(p,oldsize,newsize,MI_PADDING_SIZE /*red zone*/)
+#define mi_track_free(p) VALGRIND_FREELIKE_BLOCK(p,MI_PADDING_SIZE /*red zone*/)
+#define mi_track_mem_defined(p,size) VALGRIND_MAKE_MEM_DEFINED(p,size)
+#define mi_track_mem_undefined(p,size) VALGRIND_MAKE_MEM_UNDEFINED(p,size)
+#define mi_track_mem_noaccess(p,size) VALGRIND_MAKE_MEM_NOACCESS(p,size)
+
+#else
+
+#define MI_TRACK_ENABLED 0
+
+#define mi_track_malloc(p,size,zero)
+#define mi_track_resize(p,oldsize,newsize)
+#define mi_track_free(p)
+#define mi_track_mem_defined(p,size)
+#define mi_track_mem_undefined(p,size)
+#define mi_track_mem_noaccess(p,size)
+
+#endif
+
+#endif