sanitizer_mac.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //===-- sanitizer_mac.h -----------------------------------------*- C++ -*-===//
  2. //
  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
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file is shared between various sanitizers' runtime libraries and
  10. // provides definitions for OSX-specific functions.
  11. //===----------------------------------------------------------------------===//
  12. #ifndef SANITIZER_MAC_H
  13. #define SANITIZER_MAC_H
  14. #include "sanitizer_common.h"
  15. #include "sanitizer_platform.h"
  16. #if SANITIZER_MAC
  17. #include "sanitizer_posix.h"
  18. namespace __sanitizer {
  19. struct MemoryMappingLayoutData {
  20. int current_image;
  21. u32 current_magic;
  22. u32 current_filetype;
  23. ModuleArch current_arch;
  24. u8 current_uuid[kModuleUUIDSize];
  25. int current_load_cmd_count;
  26. const char *current_load_cmd_addr;
  27. bool current_instrumented;
  28. };
  29. template <typename VersionType>
  30. struct VersionBase {
  31. u16 major;
  32. u16 minor;
  33. VersionBase(u16 major, u16 minor) : major(major), minor(minor) {}
  34. bool operator==(const VersionType &other) const {
  35. return major == other.major && minor == other.minor;
  36. }
  37. bool operator>=(const VersionType &other) const {
  38. return major > other.major ||
  39. (major == other.major && minor >= other.minor);
  40. }
  41. bool operator<(const VersionType &other) const { return !(*this >= other); }
  42. };
  43. struct MacosVersion : VersionBase<MacosVersion> {
  44. MacosVersion(u16 major, u16 minor) : VersionBase(major, minor) {}
  45. };
  46. struct DarwinKernelVersion : VersionBase<DarwinKernelVersion> {
  47. DarwinKernelVersion(u16 major, u16 minor) : VersionBase(major, minor) {}
  48. };
  49. MacosVersion GetMacosAlignedVersion();
  50. DarwinKernelVersion GetDarwinKernelVersion();
  51. char **GetEnviron();
  52. void RestrictMemoryToMaxAddress(uptr max_address);
  53. } // namespace __sanitizer
  54. #endif // SANITIZER_MAC
  55. #endif // SANITIZER_MAC_H