blob: 827b8b0016992abb604c01aa133417568d8cbfbd [file] [log] [blame]
Alexander Potapenkod079db62012-07-06 11:58:54 +00001//===-- asan_mac.h ----------------------------------------------*- C++ -*-===//
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 AddressSanitizer, an address sanity checker.
11//
12// Mac-specific ASan definitions.
13//===----------------------------------------------------------------------===//
Evgeniy Stepanov24e13722013-03-19 14:33:38 +000014#ifndef ASAN_MAC_H
Richard Trieuf9262ae2013-06-12 22:37:22 +000015#define ASAN_MAC_H
Alexander Potapenkod079db62012-07-06 11:58:54 +000016
Alexander Potapenkobf9f6fb2012-07-06 13:04:12 +000017// CF_RC_BITS, the layout of CFRuntimeBase and __CFStrIsConstant are internal
18// and subject to change in further CoreFoundation versions. Apple does not
19// guarantee any binary compatibility from release to release.
20
21// See http://opensource.apple.com/source/CF/CF-635.15/CFInternal.h
22#if defined(__BIG_ENDIAN__)
23#define CF_RC_BITS 0
24#endif
25
26#if defined(__LITTLE_ENDIAN__)
27#define CF_RC_BITS 3
28#endif
29
30// See http://opensource.apple.com/source/CF/CF-635.15/CFRuntime.h
31typedef struct __CFRuntimeBase {
32 uptr _cfisa;
33 u8 _cfinfo[4];
34#if __LP64__
35 u32 _rc;
36#endif
37} CFRuntimeBase;
38
Alexander Potapenko31f78fd2013-07-16 09:29:48 +000039enum MacosVersion {
40 MACOS_VERSION_UNINITIALIZED = 0,
41 MACOS_VERSION_UNKNOWN,
Alexander Potapenkod079db62012-07-06 11:58:54 +000042 MACOS_VERSION_LEOPARD,
43 MACOS_VERSION_SNOW_LEOPARD,
Alexander Potapenko4e0e50a2012-10-16 16:48:51 +000044 MACOS_VERSION_LION,
Alexander Potapenkoad2ae542013-07-16 08:35:42 +000045 MACOS_VERSION_MOUNTAIN_LION,
46 MACOS_VERSION_MAVERICKS
Alexander Potapenkod079db62012-07-06 11:58:54 +000047};
48
Alexander Potapenko37c48532012-08-15 12:23:36 +000049// Used by asan_malloc_mac.cc and asan_mac.cc
50extern "C" void __CFInitialize();
51
Alexander Potapenkod079db62012-07-06 11:58:54 +000052namespace __asan {
53
Alexander Potapenko31f78fd2013-07-16 09:29:48 +000054MacosVersion GetMacosVersion();
Alexander Potapenkoec3a5a22012-10-24 09:35:23 +000055void MaybeReplaceCFAllocator();
Alexander Potapenkod079db62012-07-06 11:58:54 +000056
57} // namespace __asan
58
Evgeniy Stepanov24e13722013-03-19 14:33:38 +000059#endif // ASAN_MAC_H