[Ada] Fix assertion failure on pragma Compile_Time_Error in generic unit
[official-gcc.git] / libsanitizer / asan / asan_malloc_mac.cc
blobe34884be85b20d06357b13b273e1b8babccf983a
1 //===-- asan_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 AddressSanitizer, an address sanity checker.
9 //
10 // Mac-specific malloc interception.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_common/sanitizer_platform.h"
14 #if SANITIZER_MAC
16 #include "asan_interceptors.h"
17 #include "asan_report.h"
18 #include "asan_stack.h"
19 #include "asan_stats.h"
21 using namespace __asan;
22 #define COMMON_MALLOC_ZONE_NAME "asan"
23 #define COMMON_MALLOC_ENTER() ENSURE_ASAN_INITED()
24 #define COMMON_MALLOC_SANITIZER_INITIALIZED asan_inited
25 #define COMMON_MALLOC_FORCE_LOCK() asan_mz_force_lock()
26 #define COMMON_MALLOC_FORCE_UNLOCK() asan_mz_force_unlock()
27 #define COMMON_MALLOC_MEMALIGN(alignment, size) \
28 GET_STACK_TRACE_MALLOC; \
29 void *p = asan_memalign(alignment, size, &stack, FROM_MALLOC)
30 #define COMMON_MALLOC_MALLOC(size) \
31 GET_STACK_TRACE_MALLOC; \
32 void *p = asan_malloc(size, &stack)
33 #define COMMON_MALLOC_REALLOC(ptr, size) \
34 GET_STACK_TRACE_MALLOC; \
35 void *p = asan_realloc(ptr, size, &stack);
36 #define COMMON_MALLOC_CALLOC(count, size) \
37 GET_STACK_TRACE_MALLOC; \
38 void *p = asan_calloc(count, size, &stack);
39 #define COMMON_MALLOC_POSIX_MEMALIGN(memptr, alignment, size) \
40 GET_STACK_TRACE_MALLOC; \
41 int res = asan_posix_memalign(memptr, alignment, size, &stack);
42 #define COMMON_MALLOC_VALLOC(size) \
43 GET_STACK_TRACE_MALLOC; \
44 void *p = asan_memalign(GetPageSizeCached(), size, &stack, FROM_MALLOC);
45 #define COMMON_MALLOC_FREE(ptr) \
46 GET_STACK_TRACE_FREE; \
47 asan_free(ptr, &stack, FROM_MALLOC);
48 #define COMMON_MALLOC_SIZE(ptr) \
49 uptr size = asan_mz_size(ptr);
50 #define COMMON_MALLOC_FILL_STATS(zone, stats) \
51 AsanMallocStats malloc_stats; \
52 FillMallocStatistics(&malloc_stats); \
53 CHECK(sizeof(malloc_statistics_t) == sizeof(AsanMallocStats)); \
54 internal_memcpy(stats, &malloc_stats, sizeof(malloc_statistics_t));
55 #define COMMON_MALLOC_REPORT_UNKNOWN_REALLOC(ptr, zone_ptr, zone_name) \
56 GET_STACK_TRACE_FREE; \
57 ReportMacMzReallocUnknown((uptr)ptr, (uptr)zone_ptr, zone_name, &stack);
58 #define COMMON_MALLOC_NAMESPACE __asan
60 #include "sanitizer_common/sanitizer_malloc_mac.inc"
62 #endif