llvm/compiler-rt/lib/orc/endianness.h

//===- endian.h - Endianness support ----------------------------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file declares generic and optimized functions to swap the byte order of
// an integral type.
//
//===----------------------------------------------------------------------===//

#ifndef ORC_RT_ENDIAN_H
#define ORC_RT_ENDIAN_H

#include <cstddef>
#include <cstdint>
#include <type_traits>
#if defined(_MSC_VER) && !defined(_DEBUG)
#include <stdlib.h>
#endif

#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) ||            \
    defined(__Fuchsia__) || defined(__EMSCRIPTEN__)
#include <endian.h>
#elif defined(_AIX)
#include <sys/machine.h>
#elif defined(__sun)
/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
#include <sys/types.h>
#define BIG_ENDIAN
#define LITTLE_ENDIAN
#if defined(_BIG_ENDIAN)
#define BYTE_ORDER
#else
#define BYTE_ORDER
#endif
#elif defined(__MVS__)
#define BIG_ENDIAN
#define LITTLE_ENDIAN
#define BYTE_ORDER
#else
#if !defined(BYTE_ORDER) && !defined(_WIN32)
#include <machine/endian.h>
#endif
#endif

namespace __orc_rt {

/// ByteSwap_16 - This function returns a byte-swapped representation of
/// the 16-bit argument.
inline uint16_t ByteSwap_16(uint16_t value) {}

/// This function returns a byte-swapped representation of the 32-bit argument.
inline uint32_t ByteSwap_32(uint32_t value) {}

/// This function returns a byte-swapped representation of the 64-bit argument.
inline uint64_t ByteSwap_64(uint64_t value) {}

#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
constexpr bool IsBigEndianHost = true;
#else
constexpr bool IsBigEndianHost =;
#endif

static const bool IsLittleEndianHost =;

inline unsigned char getSwappedBytes(unsigned char C) {}
inline signed char getSwappedBytes(signed char C) {}
inline char getSwappedBytes(char C) {}

inline unsigned short getSwappedBytes(unsigned short C) {}
inline signed short getSwappedBytes(signed short C) {}

inline unsigned int getSwappedBytes(unsigned int C) {}
inline signed int getSwappedBytes(signed int C) {}

inline unsigned long getSwappedBytes(unsigned long C) {}
inline signed long getSwappedBytes(signed long C) {}

inline unsigned long long getSwappedBytes(unsigned long long C) {}
inline signed long long getSwappedBytes(signed long long C) {}

template <typename T>
inline std::enable_if_t<std::is_enum<T>::value, T> getSwappedBytes(T C) {}

template <typename T> inline void swapByteOrder(T &Value) {}

} // end namespace __orc_rt

#endif // ORC_RT_ENDIAN_H