// SPDX-FileCopyrightText: 2002-2024 PCSX2 Dev Team // SPDX-License-Identifier: GPL-3.0+ #pragma once #include #include #ifdef _MSC_VER #include #endif template T ByteSwap(T value) { if constexpr (std::is_signed_v) { return static_cast(ByteSwap(std::make_unsigned_t(value))); } else if constexpr (std::is_same_v) { #ifdef _MSC_VER return _byteswap_ushort(value); #else return __builtin_bswap16(value); #endif } else if constexpr (std::is_same_v) { #ifdef _MSC_VER return _byteswap_ulong(value); #else return __builtin_bswap32(value); #endif } else if constexpr (std::is_same_v) { #ifdef _MSC_VER return _byteswap_uint64(value); #else return __builtin_bswap64(value); #endif } }