blob: 43448e0831e83def62c08700b7bc8d620740ece9 [file] [log] [blame]
Kostya Serebryany712fc982016-06-07 01:20:26 +00001//===-- 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
Kostya Serebryany712fc982016-06-07 01:20:26 +000017#include "sanitizer_common/sanitizer_common.h"
18
Kostya Kortchinsky4a0ebbf2017-11-03 23:48:25 +000019#include <string.h>
20
Kostya Serebryany712fc982016-06-07 01:20:26 +000021namespace __scudo {
22
23template <class Dest, class Source>
Kostya Kortchinsky0207b6f2017-11-22 18:30:44 +000024INLINE Dest bit_cast(const Source& source) {
Kostya Serebryany712fc982016-06-07 01:20:26 +000025 static_assert(sizeof(Dest) == sizeof(Source), "Sizes are not equal!");
26 Dest dest;
27 memcpy(&dest, &source, sizeof(dest));
28 return dest;
29}
30
Kostya Serebryany8b4904f2016-08-02 23:23:13 +000031void NORETURN dieWithMessage(const char *Format, ...);
Kostya Serebryany712fc982016-06-07 01:20:26 +000032
Kostya Kortchinsky0207b6f2017-11-22 18:30:44 +000033bool hasHardwareCRC32();
Kostya Kortchinsky9fcb91b2017-12-08 16:36:37 +000034
Kostya Kortchinsky1148dc52016-11-30 17:32:20 +000035} // namespace __scudo
Kostya Serebryany712fc982016-06-07 01:20:26 +000036
37#endif // SCUDO_UTILS_H_