]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/scudo/scudo_utils.h
Merge compiler-rt trunk r366426, resolve conflicts, and add
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / scudo / scudo_utils.h
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
20 namespace __scudo {
21
22 template <class Dest, class Source>
23 INLINE 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
30 void NORETURN dieWithMessage(const char *Format, ...);
31
32 bool hasHardwareCRC32();
33
34 }  // namespace __scudo
35
36 #endif  // SCUDO_UTILS_H_