summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Endian.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Support/Endian.h')
-rw-r--r--include/llvm/Support/Endian.h28
1 files changed, 21 insertions, 7 deletions
diff --git a/include/llvm/Support/Endian.h b/include/llvm/Support/Endian.h
index a4d3f4ff793d..d8be94427d7e 100644
--- a/include/llvm/Support/Endian.h
+++ b/include/llvm/Support/Endian.h
@@ -1,9 +1,8 @@
//===- Endian.h - Utilities for IO with endian specific data ----*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
@@ -204,10 +203,14 @@ inline void writeAtBitAlignment(void *memory, value_type value,
namespace detail {
-template<typename value_type,
- endianness endian,
- std::size_t alignment>
+template<typename ValueType,
+ endianness Endian,
+ std::size_t Alignment>
struct packed_endian_specific_integral {
+ using value_type = ValueType;
+ static constexpr endianness endian = Endian;
+ static constexpr std::size_t alignment = Alignment;
+
packed_endian_specific_integral() = default;
explicit packed_endian_specific_integral(value_type val) { *this = val; }
@@ -335,6 +338,17 @@ using unaligned_int32_t =
using unaligned_int64_t =
detail::packed_endian_specific_integral<int64_t, native, unaligned>;
+template <typename T>
+using little_t = detail::packed_endian_specific_integral<T, little, unaligned>;
+template <typename T>
+using big_t = detail::packed_endian_specific_integral<T, big, unaligned>;
+
+template <typename T>
+using aligned_little_t =
+ detail::packed_endian_specific_integral<T, little, aligned>;
+template <typename T>
+using aligned_big_t = detail::packed_endian_specific_integral<T, big, aligned>;
+
namespace endian {
template <typename T> inline T read(const void *P, endianness E) {