]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/lsan/lsan_malloc_mac.cc
Merge clang 7.0.1 and several follow-up changes
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / lsan / lsan_malloc_mac.cc
1 //===-- lsan_malloc_mac.cc ------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file is a part of LeakSanitizer (LSan), a memory leak detector.
11 //
12 // Mac-specific malloc interception.
13 //===----------------------------------------------------------------------===//
14
15 #include "sanitizer_common/sanitizer_platform.h"
16 #if SANITIZER_MAC
17
18 #include "lsan.h"
19 #include "lsan_allocator.h"
20 #include "lsan_thread.h"
21
22 using namespace __lsan;
23 #define COMMON_MALLOC_ZONE_NAME "lsan"
24 #define COMMON_MALLOC_ENTER() ENSURE_LSAN_INITED
25 #define COMMON_MALLOC_SANITIZER_INITIALIZED lsan_inited
26 #define COMMON_MALLOC_FORCE_LOCK()
27 #define COMMON_MALLOC_FORCE_UNLOCK()
28 #define COMMON_MALLOC_MEMALIGN(alignment, size) \
29   GET_STACK_TRACE_MALLOC; \
30   void *p = lsan_memalign(alignment, size, stack)
31 #define COMMON_MALLOC_MALLOC(size) \
32   GET_STACK_TRACE_MALLOC; \
33   void *p = lsan_malloc(size, stack)
34 #define COMMON_MALLOC_REALLOC(ptr, size) \
35   GET_STACK_TRACE_MALLOC; \
36   void *p = lsan_realloc(ptr, size, stack)
37 #define COMMON_MALLOC_CALLOC(count, size) \
38   GET_STACK_TRACE_MALLOC; \
39   void *p = lsan_calloc(count, size, stack)
40 #define COMMON_MALLOC_POSIX_MEMALIGN(memptr, alignment, size) \
41   GET_STACK_TRACE_MALLOC; \
42   int res = lsan_posix_memalign(memptr, alignment, size, stack)
43 #define COMMON_MALLOC_VALLOC(size) \
44   GET_STACK_TRACE_MALLOC; \
45   void *p = lsan_valloc(size, stack)
46 #define COMMON_MALLOC_FREE(ptr) \
47   lsan_free(ptr)
48 #define COMMON_MALLOC_SIZE(ptr) \
49   uptr size = lsan_mz_size(ptr)
50 #define COMMON_MALLOC_FILL_STATS(zone, stats)
51 #define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
52   (void)zone_name; \
53   Report("mz_realloc(%p) -- attempting to realloc unallocated memory.\n", ptr);
54 #define COMMON_MALLOC_NAMESPACE __lsan
55
56 #include "sanitizer_common/sanitizer_malloc_mac.inc"
57
58 #endif // SANITIZER_MAC