]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/compiler-rt/lib/scudo/scudo_utils.h
Merge compiler-rt trunk r321017 to contrib/compiler-rt.
[FreeBSD/FreeBSD.git] / contrib / compiler-rt / lib / scudo / scudo_utils.h
1 //===-- scudo_utils.h -------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// Header for scudo_utils.cpp.
11 ///
12 //===----------------------------------------------------------------------===//
13
14 #ifndef SCUDO_UTILS_H_
15 #define SCUDO_UTILS_H_
16
17 #include "sanitizer_common/sanitizer_common.h"
18
19 #include <string.h>
20
21 namespace __scudo {
22
23 template <class Dest, class Source>
24 INLINE Dest bit_cast(const Source& source) {
25   static_assert(sizeof(Dest) == sizeof(Source), "Sizes are not equal!");
26   Dest dest;
27   memcpy(&dest, &source, sizeof(dest));
28   return dest;
29 }
30
31 void NORETURN dieWithMessage(const char *Format, ...);
32
33 bool hasHardwareCRC32();
34
35 }  // namespace __scudo
36
37 #endif  // SCUDO_UTILS_H_