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
13#ifndef SCUDO_UTILS_H_
14#define SCUDO_UTILS_H_
15
16#include "sanitizer_common/sanitizer_common.h"
17
18#include <string.h>
19
20namespace __scudo {
21
22template <class Dest, class Source>
23INLINE Dest bit_cast(const Source& source) {
24  static_assert(sizeof(Dest) == sizeof(Source), "Sizes are not equal!");
25  Dest dest;
26  memcpy(&dest, &source, sizeof(dest));
27  return dest;
28}
29
30void NORETURN dieWithMessage(const char *Format, ...);
31
32bool hasHardwareCRC32();
33
34}  // namespace __scudo
35
36#endif  // SCUDO_UTILS_H_
37