1 //===-- sanitizer_mac.h -----------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file is shared between various sanitizers' runtime libraries and
10 // provides definitions for OSX-specific functions.
11 //===----------------------------------------------------------------------===//
12 #ifndef SANITIZER_APPLE_H
13 #define SANITIZER_APPLE_H
15 #include "sanitizer_common.h"
16 #include "sanitizer_platform.h"
18 #include "sanitizer_posix.h"
20 namespace __sanitizer
{
22 struct MemoryMappingLayoutData
{
26 ModuleArch current_arch
;
27 u8 current_uuid
[kModuleUUIDSize
];
28 int current_load_cmd_count
;
29 const char *current_load_cmd_addr
;
30 bool current_instrumented
;
33 template <typename VersionType
>
38 VersionBase(u16 major
, u16 minor
) : major(major
), minor(minor
) {}
40 bool operator==(const VersionType
&other
) const {
41 return major
== other
.major
&& minor
== other
.minor
;
43 bool operator>=(const VersionType
&other
) const {
44 return major
> other
.major
||
45 (major
== other
.major
&& minor
>= other
.minor
);
47 bool operator<(const VersionType
&other
) const { return !(*this >= other
); }
50 struct MacosVersion
: VersionBase
<MacosVersion
> {
51 MacosVersion(u16 major
, u16 minor
) : VersionBase(major
, minor
) {}
54 struct DarwinKernelVersion
: VersionBase
<DarwinKernelVersion
> {
55 DarwinKernelVersion(u16 major
, u16 minor
) : VersionBase(major
, minor
) {}
58 MacosVersion
GetMacosAlignedVersion();
59 DarwinKernelVersion
GetDarwinKernelVersion();
63 void RestrictMemoryToMaxAddress(uptr max_address
);
65 using ThreadEventCallback
= void (*)(uptr thread
);
66 using ThreadCreateEventCallback
= void (*)(uptr thread
, bool gcd_worker
);
67 struct ThreadEventCallbacks
{
68 ThreadCreateEventCallback create
;
69 ThreadEventCallback start
;
70 ThreadEventCallback terminate
;
71 ThreadEventCallback destroy
;
74 void InstallPthreadIntrospectionHook(const ThreadEventCallbacks
&callbacks
);
76 } // namespace __sanitizer
78 #endif // SANITIZER_APPLE
79 #endif // SANITIZER_APPLE_H