address_types.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2017 The Crashpad Authors. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef CRASHPAD_UTIL_MISC_ADDRESS_TYPES_H_
  15. #define CRASHPAD_UTIL_MISC_ADDRESS_TYPES_H_
  16. #include <stdint.h>
  17. #include <type_traits>
  18. #include "build/build_config.h"
  19. #if defined(OS_MACOSX)
  20. #include <mach/mach_types.h>
  21. #elif defined(OS_WIN)
  22. #include "util/win/address_types.h"
  23. #elif defined(OS_LINUX) || defined(OS_ANDROID)
  24. #include "util/linux/address_types.h"
  25. #else
  26. #error "Unhandled OS type"
  27. #endif
  28. namespace crashpad {
  29. #if DOXYGEN
  30. //! \brief Type used to represent an address in a process, potentially across
  31. //! bitness.
  32. using VMAddress = uint64_t;
  33. //! \brief Type used to represent the size of a memory range (with a
  34. //! VMAddress), potentially across bitness.
  35. using VMSize = uint64_t;
  36. #elif defined(OS_MACOSX)
  37. using VMAddress = mach_vm_address_t;
  38. using VMSize = mach_vm_size_t;
  39. #elif defined(OS_WIN)
  40. using VMAddress = WinVMAddress;
  41. using VMSize = WinVMSize;
  42. #elif defined(OS_LINUX) || defined(OS_ANDROID)
  43. using VMAddress = LinuxVMAddress;
  44. using VMSize = LinuxVMSize;
  45. #endif
  46. //! \brief Type used to represent an offset from a VMAddress, potentially
  47. //! across bitness.
  48. using VMOffset = std::make_signed<VMSize>::type;
  49. } // namespace crashpad
  50. #endif // CRASHPAD_UTIL_MISC_ADDRESS_TYPES_H_