Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 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 | |
Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 17 | #include "sanitizer_common/sanitizer_common.h" |
| 18 | |
Kostya Kortchinsky | 4a0ebbf | 2017-11-03 23:48:25 +0000 | [diff] [blame] | 19 | #include <string.h> |
| 20 | |
Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 21 | namespace __scudo { |
| 22 | |
| 23 | template <class Dest, class Source> |
Kostya Kortchinsky | 0207b6f | 2017-11-22 18:30:44 +0000 | [diff] [blame] | 24 | INLINE Dest bit_cast(const Source& source) { |
Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 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 | |
Kostya Serebryany | 8b4904f | 2016-08-02 23:23:13 +0000 | [diff] [blame] | 31 | void NORETURN dieWithMessage(const char *Format, ...); |
Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 32 | |
Kostya Kortchinsky | 0207b6f | 2017-11-22 18:30:44 +0000 | [diff] [blame] | 33 | bool hasHardwareCRC32(); |
Kostya Kortchinsky | 9fcb91b | 2017-12-08 16:36:37 +0000 | [diff] [blame^] | 34 | |
Kostya Kortchinsky | 1148dc5 | 2016-11-30 17:32:20 +0000 | [diff] [blame] | 35 | } // namespace __scudo |
Kostya Serebryany | 712fc98 | 2016-06-07 01:20:26 +0000 | [diff] [blame] | 36 | |
| 37 | #endif // SCUDO_UTILS_H_ |