xref: /openbsd/gnu/llvm/lldb/include/lldb/Utility/Endian.h (revision be691f3b)
1 //===-- Endian.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 #ifndef LLDB_UTILITY_ENDIAN_H
10 #define LLDB_UTILITY_ENDIAN_H
11 
12 #include "lldb/lldb-enumerations.h"
13 
14 #include <cstdint>
15 
16 namespace lldb_private {
17 
18 namespace endian {
19 
20 static union EndianTest {
21   uint32_t num;
22   uint8_t bytes[sizeof(uint32_t)];
23 } const endianTest = {0x01020304};
24 
InlHostByteOrder()25 inline lldb::ByteOrder InlHostByteOrder() {
26   return static_cast<lldb::ByteOrder>(endianTest.bytes[0]);
27 }
28 
29 //    ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
30 }
31 }
32 
33 #endif // LLDB_UTILITY_ENDIAN_H
34