chromium/third_party/pdfium/core/fxcrt/byteorder.h

// Copyright 2019 The PDFium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CORE_FXCRT_BYTEORDER_H_
#define CORE_FXCRT_BYTEORDER_H_

#include <stdint.h>

#include "build/build_config.h"
#include "core/fxcrt/span.h"

#if defined(COMPILER_MSVC)
#include <stdlib.h>
#endif

namespace fxcrt {

namespace internal {

#if defined(COMPILER_MSVC) && !defined(__clang__)
// TODO(thestig): See
// https://developercommunity.visualstudio.com/t/Mark-some-built-in-functions-as-constexp/362558
// https://developercommunity.visualstudio.com/t/constexpr-byte-swapping-optimization/983963
#define FXCRT_BYTESWAPS_CONSTEXPR
#else
#define FXCRT_BYTESWAPS_CONSTEXPR
#endif

// Returns a value with all bytes in |x| swapped, i.e. reverses the endianness.
// TODO(thestig): Once C++23 is available, replace with std::byteswap.
inline FXCRT_BYTESWAPS_CONSTEXPR uint16_t ByteSwap(uint16_t x) {}

inline FXCRT_BYTESWAPS_CONSTEXPR uint32_t ByteSwap(uint32_t x) {}

#undef FXCRT_BYTESWAPS_CONSTEXPR

}  // namespace internal

// NOTE: Prefer From*() methods when data is known to be aligned.

// Converts the bytes in |x| from host order (endianness) to little endian, and
// returns the result.
inline uint16_t FromLE16(uint16_t x) {}

inline uint32_t FromLE32(uint32_t x) {}

// Converts the bytes in |x| from host order (endianness) to big endian, and
// returns the result.
inline uint16_t FromBE16(uint16_t x) {}

inline uint32_t FromBE32(uint32_t x) {}

// Transfer to/from spans irrespective of alignments.
inline uint16_t GetUInt16MSBFirst(pdfium::span<const uint8_t, 2> span) {}

inline uint32_t GetUInt32MSBFirst(pdfium::span<const uint8_t, 4> span) {}

inline uint16_t GetUInt16LSBFirst(pdfium::span<const uint8_t, 2> span) {}

inline uint32_t GetUInt32LSBFirst(pdfium::span<const uint8_t, 4> span) {}

inline void PutUInt16MSBFirst(uint16_t value, pdfium::span<uint8_t, 2> span) {}

inline void PutUInt32MSBFirst(uint32_t value, pdfium::span<uint8_t, 4> span) {}

inline void PutUInt16LSBFirst(uint16_t value, pdfium::span<uint8_t, 2> span) {}

inline void PutUInt32LSBFirst(uint32_t value, pdfium::span<uint8_t, 4> span) {}

}  // namespace fxcrt

#endif  // CORE_FXCRT_BYTEORDER_H_