8#ifndef V8_BASE_NUMERICS_BYTE_CONVERSIONS_H_
9#define V8_BASE_NUMERICS_BYTE_CONVERSIONS_H_
18#include "build/build_config.h"
22static_assert(ARCH_CPU_LITTLE_ENDIAN);
29 requires(std::is_integral_v<T>)
46 std::span<const uint8_t, 1u> bytes) {
57 std::span<const uint8_t, 2u> bytes) {
68 std::span<const uint8_t, 4u> bytes) {
79 std::span<const uint8_t, 8u> bytes) {
94 return static_cast<int8_t
>(bytes[0]);
104 std::span<const uint8_t, 2u> bytes) {
115 std::span<const uint8_t, 4u> bytes) {
126 std::span<const uint8_t, 8u> bytes) {
138 std::span<const uint8_t, 4u> bytes) {
149 std::span<const uint8_t, 8u> bytes) {
166 std::span<const uint8_t, 1u> bytes) {
178 std::span<const uint8_t, 2u> bytes) {
190 std::span<const uint8_t, 4u> bytes) {
202 std::span<const uint8_t, 8u> bytes) {
218 return static_cast<int8_t
>(bytes[0]);
229 std::span<const uint8_t, 2u> bytes) {
241 std::span<const uint8_t, 4u> bytes) {
253 std::span<const uint8_t, 8u> bytes) {
265 std::span<const uint8_t, 4u> bytes) {
277 std::span<const uint8_t, 8u> bytes) {
337 return static_cast<int8_t
>(bytes[0]);
387 std::span<const uint8_t, 8u> bytes) {
439 return {
static_cast<uint8_t
>(val)};
545 return {
static_cast<uint8_t
>(val)};
656 return {
static_cast<uint8_t
>(val)};
constexpr T SwapBytes(T value)
constexpr T FromLittleEndian(std::span< const uint8_t, sizeof(T)> bytes)
constexpr std::array< uint8_t, sizeof(T)> ToLittleEndian(T val)
constexpr uint8_t U8FromLittleEndian(std::span< const uint8_t, 1u > bytes)
constexpr float FloatFromLittleEndian(std::span< const uint8_t, 4u > bytes)
constexpr uint8_t U8FromNativeEndian(std::span< const uint8_t, 1u > bytes)
constexpr uint32_t U32FromBigEndian(std::span< const uint8_t, 4u > bytes)
constexpr double DoubleFromNativeEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 4u > FloatToLittleEndian(float val)
constexpr uint16_t U16FromLittleEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 4u > FloatToBigEndian(float val)
constexpr int32_t I32FromNativeEndian(std::span< const uint8_t, 4u > bytes)
constexpr std::array< uint8_t, 4u > U32ToBigEndian(uint32_t val)
constexpr uint64_t U64FromNativeEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 8u > DoubleToBigEndian(double val)
constexpr std::array< uint8_t, 2u > U16ToNativeEndian(uint16_t val)
constexpr std::array< uint8_t, 4u > U32ToNativeEndian(uint32_t val)
constexpr int32_t I32FromBigEndian(std::span< const uint8_t, 4u > bytes)
constexpr uint64_t U64FromLittleEndian(std::span< const uint8_t, 8u > bytes)
constexpr int64_t I64FromBigEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 8u > U64ToNativeEndian(uint64_t val)
constexpr std::array< uint8_t, 1u > I8ToBigEndian(int8_t val)
constexpr uint32_t U32FromLittleEndian(std::span< const uint8_t, 4u > bytes)
constexpr int16_t I16FromLittleEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 1u > U8ToNativeEndian(uint8_t val)
constexpr std::array< uint8_t, 2u > I16ToBigEndian(int16_t val)
constexpr std::array< uint8_t, 1u > I8ToNativeEndian(int8_t val)
constexpr T ByteSwap(T value)
constexpr int64_t I64FromLittleEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 1u > I8ToLittleEndian(int8_t val)
constexpr std::array< uint8_t, 8u > U64ToBigEndian(uint64_t val)
constexpr std::array< uint8_t, 4u > U32ToLittleEndian(uint32_t val)
constexpr std::array< uint8_t, 1u > U8ToBigEndian(uint8_t val)
constexpr int16_t I16FromBigEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 4u > I32ToBigEndian(int32_t val)
constexpr std::array< uint8_t, 4u > FloatToNativeEndian(float val)
constexpr std::array< uint8_t, 2u > I16ToNativeEndian(int16_t val)
constexpr std::array< uint8_t, 8u > DoubleToNativeEndian(double val)
constexpr std::array< uint8_t, 1u > U8ToLittleEndian(uint8_t val)
constexpr int8_t I8FromLittleEndian(std::span< const uint8_t, 1u > bytes)
constexpr std::array< uint8_t, 8u > I64ToBigEndian(int64_t val)
constexpr float FloatFromNativeEndian(std::span< const uint8_t, 4u > bytes)
constexpr int16_t I16FromNativeEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 8u > I64ToNativeEndian(int64_t val)
constexpr int8_t I8FromNativeEndian(std::span< const uint8_t, 1u > bytes)
constexpr uint64_t U64FromBigEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 8u > U64ToLittleEndian(uint64_t val)
constexpr double DoubleFromBigEndian(std::span< const uint8_t, 8u > bytes)
constexpr uint8_t U8FromBigEndian(std::span< const uint8_t, 1u > bytes)
constexpr float FloatFromBigEndian(std::span< const uint8_t, 4u > bytes)
constexpr int64_t I64FromNativeEndian(std::span< const uint8_t, 8u > bytes)
constexpr int8_t I8FromBigEndian(std::span< const uint8_t, 1u > bytes)
constexpr double DoubleFromLittleEndian(std::span< const uint8_t, 8u > bytes)
constexpr std::array< uint8_t, 4u > I32ToLittleEndian(int32_t val)
constexpr int32_t I32FromLittleEndian(std::span< const uint8_t, 4u > bytes)
constexpr std::array< uint8_t, 8u > DoubleToLittleEndian(double val)
constexpr std::array< uint8_t, 8u > I64ToLittleEndian(int64_t val)
constexpr uint16_t U16FromNativeEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 4u > I32ToNativeEndian(int32_t val)
constexpr std::array< uint8_t, 2u > U16ToLittleEndian(uint16_t val)
constexpr std::array< uint8_t, 2u > I16ToLittleEndian(int16_t val)
constexpr uint16_t U16FromBigEndian(std::span< const uint8_t, 2u > bytes)
constexpr std::array< uint8_t, 2u > U16ToBigEndian(uint16_t val)
constexpr uint32_t U32FromNativeEndian(std::span< const uint8_t, 4u > bytes)