PR middle-end/85496
[official-gcc.git] / libsanitizer / lsan / lsan_malloc_mac.cc
blob2d810af841fe5cacbf4a30e9ce2290b4952b1c59
1 //===-- lsan_malloc_mac.cc ------------------------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of LeakSanitizer (LSan), a memory leak detector.
9 //
10 // Mac-specific malloc interception.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_platform.h"
14 #if SANITIZER_MAC
16 #include "lsan.h"
17 #include "lsan_allocator.h"
18 #include "lsan_thread.h"
20 using namespace __lsan;
21 #define COMMON_MALLOC_ZONE_NAME "lsan"
22 #define COMMON_MALLOC_ENTER() ENSURE_LSAN_INITED
23 #define COMMON_MALLOC_SANITIZER_INITIALIZED lsan_inited
24 #define COMMON_MALLOC_FORCE_LOCK()
25 #define COMMON_MALLOC_FORCE_UNLOCK()
26 #define COMMON_MALLOC_MEMALIGN(alignment, size) \
27 GET_STACK_TRACE_MALLOC; \
28 void *p = lsan_memalign(alignment, size, stack)
29 #define COMMON_MALLOC_MALLOC(size) \
30 GET_STACK_TRACE_MALLOC; \
31 void *p = lsan_malloc(size, stack)
32 #define COMMON_MALLOC_REALLOC(ptr, size) \
33 GET_STACK_TRACE_MALLOC; \
34 void *p = lsan_realloc(ptr, size, stack)
35 #define COMMON_MALLOC_CALLOC(count, size) \
36 GET_STACK_TRACE_MALLOC; \
37 void *p = lsan_calloc(count, size, stack)
38 #define COMMON_MALLOC_VALLOC(size) \
39 GET_STACK_TRACE_MALLOC; \
40 void *p = lsan_valloc(size, stack)
41 #define COMMON_MALLOC_FREE(ptr) \
42 lsan_free(ptr)
43 #define COMMON_MALLOC_SIZE(ptr) \
44 uptr size = lsan_mz_size(ptr)
45 #define COMMON_MALLOC_FILL_STATS(zone, stats)
46 #define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
47 (void)zone_name; \
48 Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);
49 #define COMMON_MALLOC_NAMESPACE __lsan
51 #include "sanitizer_common/sanitizer_malloc_mac.inc"
53 #endif // SANITIZER_MAC