scudo_utils.h 999 B

123456789101112131415161718192021222324252627282930313233343536
  1. //===-- scudo_utils.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. /// Header for scudo_utils.cpp.
  10. ///
  11. //===----------------------------------------------------------------------===//
  12. #ifndef SCUDO_UTILS_H_
  13. #define SCUDO_UTILS_H_
  14. #include "sanitizer_common/sanitizer_common.h"
  15. #include <string.h>
  16. namespace __scudo {
  17. template <class Dest, class Source>
  18. inline Dest bit_cast(const Source& source) {
  19. static_assert(sizeof(Dest) == sizeof(Source), "Sizes are not equal!");
  20. Dest dest;
  21. memcpy(&dest, &source, sizeof(dest));
  22. return dest;
  23. }
  24. void dieWithMessage(const char *Format, ...) NORETURN FORMAT(1, 2);
  25. bool hasHardwareCRC32();
  26. } // namespace __scudo
  27. #endif // SCUDO_UTILS_H_