Endian.h 864 B

123456789101112131415161718192021222324252627282930313233
  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. #ifndef LLDB_UTILITY_ENDIAN_H
  9. #define LLDB_UTILITY_ENDIAN_H
  10. #include "lldb/lldb-enumerations.h"
  11. #include <cstdint>
  12. namespace lldb_private {
  13. namespace endian {
  14. static union EndianTest {
  15. uint32_t num;
  16. uint8_t bytes[sizeof(uint32_t)];
  17. } const endianTest = {0x01020304};
  18. inline lldb::ByteOrder InlHostByteOrder() {
  19. return static_cast<lldb::ByteOrder>(endianTest.bytes[0]);
  20. }
  21. // ByteOrder const InlHostByteOrder = (ByteOrder)endianTest.bytes[0];
  22. }
  23. }
  24. #endif // LLDB_UTILITY_ENDIAN_H