]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/sanitizer_common/sanitizer_mac.h
Vendor import of compiler-rt trunk r321017:
[FreeBSD/FreeBSD.git] / lib / sanitizer_common / sanitizer_mac.h
1 //===-- sanitizer_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 shared between various sanitizers' runtime libraries and
11 // provides definitions for OSX-specific functions.
12 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_MAC_H
14 #define SANITIZER_MAC_H
15
16 #include "sanitizer_common.h"
17 #include "sanitizer_platform.h"
18 #if SANITIZER_MAC
19 #include "sanitizer_posix.h"
20
21 namespace __sanitizer {
22
23 struct MemoryMappingLayoutData {
24   int current_image;
25   u32 current_magic;
26   u32 current_filetype;
27   ModuleArch current_arch;
28   u8 current_uuid[kModuleUUIDSize];
29   int current_load_cmd_count;
30   const char *current_load_cmd_addr;
31   bool current_instrumented;
32 };
33
34 enum MacosVersion {
35   MACOS_VERSION_UNINITIALIZED = 0,
36   MACOS_VERSION_UNKNOWN,
37   MACOS_VERSION_LEOPARD,
38   MACOS_VERSION_SNOW_LEOPARD,
39   MACOS_VERSION_LION,
40   MACOS_VERSION_MOUNTAIN_LION,
41   MACOS_VERSION_MAVERICKS,
42   MACOS_VERSION_YOSEMITE,
43   MACOS_VERSION_UNKNOWN_NEWER
44 };
45
46 MacosVersion GetMacosVersion();
47
48 char **GetEnviron();
49
50 void RestrictMemoryToMaxAddress(uptr max_address);
51
52 }  // namespace __sanitizer
53
54 extern "C" {
55 static char __crashreporter_info_buff__[__sanitizer::kErrorMessageBufferSize] =
56   {};
57 static const char *__crashreporter_info__ __attribute__((__used__)) =
58   &__crashreporter_info_buff__[0];
59 asm(".desc ___crashreporter_info__, 0x10");
60 } // extern "C"
61
62 namespace __sanitizer {
63 static BlockingMutex crashreporter_info_mutex(LINKER_INITIALIZED);
64
65 INLINE void CRAppendCrashLogMessage(const char *msg) {
66   BlockingMutexLock l(&crashreporter_info_mutex);
67   internal_strlcat(__crashreporter_info_buff__, msg,
68                    sizeof(__crashreporter_info_buff__)); }
69 }  // namespace __sanitizer
70
71 #endif  // SANITIZER_MAC
72 #endif  // SANITIZER_MAC_H