Common: Move byte swapping utilities into their own header

This moves all the byte swapping utilities into a header named Swap.h.

A dedicated header is much more preferable here due to the size of the
code itself. In general usage throughout the codebase, CommonFuncs.h was
generally only included for these functions anyway. These being in their
own header avoids dumping the lesser used utilities into scope. As well
as providing a localized area for more utilities related to byte
swapping in the future (should they be needed). This also makes it nicer
to identify which files depend on the byte swapping utilities in
particular.

Since this is a completely new header, moving the code uncovered a few
indirect includes, as well as making some other inclusions unnecessary.
This commit is contained in:
Lioncash 2017-03-03 14:43:52 -05:00
parent 51e932b4ec
commit 552c0d8404
88 changed files with 347 additions and 296 deletions

View File

@ -2,14 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "AudioCommon/Mixer.h"
#include <cstring>
#include "AudioCommon/AudioCommon.h"
#include "AudioCommon/Mixer.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
#if _M_SSE >= 0x301 && !(defined __GNUC__ && !defined __SSSE3__)

View File

@ -2,15 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "AudioCommon/WaveFile.h"
#include <string>
#include "AudioCommon/WaveFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
constexpr size_t WaveFileWriter::BUFFER_SIZE;

View File

@ -3,7 +3,7 @@
// Refer to the license.txt file included.
#include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h"
#include "Common/Swap.h"
namespace ColorUtil
{

View File

@ -134,6 +134,7 @@
<ClInclude Include="Semaphore.h" />
<ClInclude Include="SettingsHandler.h" />
<ClInclude Include="StringUtil.h" />
<ClInclude Include="Swap.h" />
<ClInclude Include="SymbolDB.h" />
<ClInclude Include="SysConf.h" />
<ClInclude Include="Thread.h" />

View File

@ -63,6 +63,7 @@
<ClInclude Include="SDCardUtil.h" />
<ClInclude Include="SettingsHandler.h" />
<ClInclude Include="StringUtil.h" />
<ClInclude Include="Swap.h" />
<ClInclude Include="SymbolDB.h" />
<ClInclude Include="SysConf.h" />
<ClInclude Include="Thread.h" />

View File

@ -4,12 +4,7 @@
#pragma once
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#endif
#include <cstddef>
#include <cstring>
#include <string>
#include "Common/CommonTypes.h"
@ -29,13 +24,6 @@ constexpr size_t ArraySize(T (&arr)[N])
#ifndef _WIN32
#include <errno.h>
#ifdef __linux__
#include <byteswap.h>
#elif defined __FreeBSD__
#include <sys/endian.h>
#endif
// go to debugger mode
#define Crash() \
{ \
@ -103,153 +91,3 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
// This function might change the error code.
// Defined in Misc.cpp.
std::string GetLastErrorMsg();
namespace Common
{
inline u8 swap8(u8 _data)
{
return _data;
}
inline u32 swap24(const u8* _data)
{
return (_data[0] << 16) | (_data[1] << 8) | _data[2];
}
#if defined(ANDROID) || defined(__OpenBSD__)
#undef swap16
#undef swap32
#undef swap64
#endif
#ifdef _WIN32
inline u16 swap16(u16 _data)
{
return _byteswap_ushort(_data);
}
inline u32 swap32(u32 _data)
{
return _byteswap_ulong(_data);
}
inline u64 swap64(u64 _data)
{
return _byteswap_uint64(_data);
}
#elif __linux__
inline u16 swap16(u16 _data)
{
return bswap_16(_data);
}
inline u32 swap32(u32 _data)
{
return bswap_32(_data);
}
inline u64 swap64(u64 _data)
{
return bswap_64(_data);
}
#elif __APPLE__
inline __attribute__((always_inline)) u16 swap16(u16 _data)
{
return OSSwapInt16(_data);
}
inline __attribute__((always_inline)) u32 swap32(u32 _data)
{
return OSSwapInt32(_data);
}
inline __attribute__((always_inline)) u64 swap64(u64 _data)
{
return OSSwapInt64(_data);
}
#elif __FreeBSD__
inline u16 swap16(u16 _data)
{
return bswap16(_data);
}
inline u32 swap32(u32 _data)
{
return bswap32(_data);
}
inline u64 swap64(u64 _data)
{
return bswap64(_data);
}
#else
// Slow generic implementation.
inline u16 swap16(u16 data)
{
return (data >> 8) | (data << 8);
}
inline u32 swap32(u32 data)
{
return (swap16(data) << 16) | swap16(data >> 16);
}
inline u64 swap64(u64 data)
{
return ((u64)swap32(data) << 32) | swap32(data >> 32);
}
#endif
inline u16 swap16(const u8* data)
{
u16 value;
std::memcpy(&value, data, sizeof(u16));
return swap16(value);
}
inline u32 swap32(const u8* data)
{
u32 value;
std::memcpy(&value, data, sizeof(u32));
return swap32(value);
}
inline u64 swap64(const u8* data)
{
u64 value;
std::memcpy(&value, data, sizeof(u64));
return swap64(value);
}
template <int count>
void swap(u8*);
template <>
inline void swap<1>(u8* data)
{
}
template <>
inline void swap<2>(u8* data)
{
const u16 value = swap16(data);
std::memcpy(data, &value, sizeof(u16));
}
template <>
inline void swap<4>(u8* data)
{
const u32 value = swap32(data);
std::memcpy(data, &value, sizeof(u32));
}
template <>
inline void swap<8>(u8* data)
{
const u64 value = swap64(data);
std::memcpy(data, &value, sizeof(u64));
}
template <typename T>
inline T FromBigEndian(T data)
{
static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types");
swap<sizeof(data)>(reinterpret_cast<u8*>(&data));
return data;
}
} // Namespace Common

View File

@ -3,20 +3,17 @@
// Refer to the license.txt file included.
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
namespace Common
{

View File

@ -14,7 +14,6 @@
#include <windows.h>
#include <mmsystem.h>
#include <sys/timeb.h>
#include "Common/CommonFuncs.h" // snprintf
#endif
#include "Common/CommonTypes.h"

167
Source/Core/Common/Swap.h Normal file
View File

@ -0,0 +1,167 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <cstring>
#include <type_traits>
#ifdef __APPLE__
#include <libkern/OSByteOrder.h>
#elif defined(__linux__)
#include <byteswap.h>
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#endif
#include "Common/CommonTypes.h"
namespace Common
{
inline u8 swap8(u8 data)
{
return data;
}
inline u32 swap24(const u8* data)
{
return (data[0] << 16) | (data[1] << 8) | data[2];
}
#if defined(ANDROID) || defined(__OpenBSD__)
#undef swap16
#undef swap32
#undef swap64
#endif
#ifdef _WIN32
inline u16 swap16(u16 data)
{
return _byteswap_ushort(data);
}
inline u32 swap32(u32 data)
{
return _byteswap_ulong(data);
}
inline u64 swap64(u64 data)
{
return _byteswap_uint64(data);
}
#elif __linux__
inline u16 swap16(u16 data)
{
return bswap_16(data);
}
inline u32 swap32(u32 data)
{
return bswap_32(data);
}
inline u64 swap64(u64 data)
{
return bswap_64(data);
}
#elif __APPLE__
inline __attribute__((always_inline)) u16 swap16(u16 data)
{
return OSSwapInt16(data);
}
inline __attribute__((always_inline)) u32 swap32(u32 data)
{
return OSSwapInt32(data);
}
inline __attribute__((always_inline)) u64 swap64(u64 data)
{
return OSSwapInt64(data);
}
#elif __FreeBSD__
inline u16 swap16(u16 data)
{
return bswap16(data);
}
inline u32 swap32(u32 data)
{
return bswap32(data);
}
inline u64 swap64(u64 data)
{
return bswap64(data);
}
#else
// Slow generic implementation.
inline u16 swap16(u16 data)
{
return (data >> 8) | (data << 8);
}
inline u32 swap32(u32 data)
{
return (swap16(data) << 16) | swap16(data >> 16);
}
inline u64 swap64(u64 data)
{
return ((u64)swap32(data) << 32) | swap32(data >> 32);
}
#endif
inline u16 swap16(const u8* data)
{
u16 value;
std::memcpy(&value, data, sizeof(u16));
return swap16(value);
}
inline u32 swap32(const u8* data)
{
u32 value;
std::memcpy(&value, data, sizeof(u32));
return swap32(value);
}
inline u64 swap64(const u8* data)
{
u64 value;
std::memcpy(&value, data, sizeof(u64));
return swap64(value);
}
template <int count>
void swap(u8*);
template <>
inline void swap<1>(u8* data)
{
}
template <>
inline void swap<2>(u8* data)
{
const u16 value = swap16(data);
std::memcpy(data, &value, sizeof(u16));
}
template <>
inline void swap<4>(u8* data)
{
const u32 value = swap32(data);
std::memcpy(data, &value, sizeof(u32));
}
template <>
inline void swap<8>(u8* data)
{
const u64 value = swap64(data);
std::memcpy(data, &value, sizeof(u64));
}
template <typename T>
inline T FromBigEndian(T data)
{
static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types");
swap<sizeof(data)>(reinterpret_cast<u8*>(&data));
return data;
}
} // Namespace Common

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Common/SysConf.h"
#include <algorithm>
#include <cinttypes>
#include <cstdio>
@ -9,13 +11,10 @@
#include <string>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/SysConf.h"
#include "Common/Swap.h"
#include "Core/Movie.h"
SysConf::SysConf(const Common::FromWhichRoot root_type)

View File

@ -6,6 +6,8 @@
// GCNcrypt - GameCube AR Crypto Program
// Copyright (C) 2003-2004 Parasyte
#include "Core/ARDecrypt.h"
#include <algorithm>
#include <cstring>
@ -16,7 +18,7 @@
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Core/ARDecrypt.h"
#include "Common/Swap.h"
namespace ActionReplay
{

View File

@ -4,6 +4,7 @@
#pragma once
#include <string>
#include <vector>
#include "Common/CommonTypes.h"

View File

@ -2,14 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/Boot/Boot_DOL.h"
#include <cstring>
#include <string>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "Core/Boot/Boot_DOL.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
CDolLoader::CDolLoader(const std::vector<u8>& buffer)

View File

@ -4,8 +4,8 @@
#include <memory>
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "Common/Swap.h"
#include "Core/Boot/Boot.h"
#include "Core/Boot/ElfReader.h"
#include "Core/HLE/HLE.h"

View File

@ -6,10 +6,10 @@
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/PPCSymbolDB.h"

View File

@ -9,11 +9,9 @@
#include <array>
#include <memory>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Event.h"
#include "Common/Hash.h"
#include "Common/Logging/Log.h"
#include "Common/MemoryUtil.h"
#include "Common/MsgHandler.h"

View File

@ -6,10 +6,11 @@
#include "Core/DSP/DSPHWInterface.h"
#include "Common/CPUDetect.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Intrinsics.h"
#include "Common/Logging/Log.h"
#include "Common/MemoryUtil.h"
#include "Common/Swap.h"
#include "Core/DSP/DSPAccelerator.h"
#include "Core/DSP/DSPCore.h"

View File

@ -2,14 +2,16 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/FifoPlayer/FifoAnalyzer.h"
#include <algorithm>
#include <numeric>
#include "Core/FifoPlayer/FifoAnalyzer.h"
#include "Common/Assert.h"
#include "Core/Core.h"
#include "Common/Swap.h"
#include "Core/FifoPlayer/FifoRecordAnalyzer.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoader_Normal.h"

View File

@ -5,11 +5,11 @@
#include "Core/HW/DSPHLE/UCodes/AX.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/Swap.h"
#include "Core/HW/DSP.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/MailHandler.h"

View File

@ -7,11 +7,10 @@
#include "Core/HW/DSPHLE/UCodes/AXWii.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/MailHandler.h"
#include "Core/HW/DSPHLE/UCodes/AXStructs.h"

View File

@ -5,7 +5,6 @@
#include "Core/HW/DSPHLE/UCodes/GBA.h"
#include "Common/Align.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Core/HW/DSP.h"

View File

@ -12,12 +12,12 @@
#endif
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Hash.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/UCodes/AX.h"

View File

@ -7,9 +7,9 @@
#include <array>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/HW/DSP.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/MailHandler.h"

View File

@ -11,7 +11,6 @@
#include <vector>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"

View File

@ -14,6 +14,7 @@
#include "Common/Logging/Log.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Common/Timer.h"
#include "Core/ConfigManager.h"

View File

@ -2,18 +2,21 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/HW/GCMemcard.h"
#include <algorithm>
#include <cinttypes>
#include <cstring>
#include <vector>
#include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Core/HW/GCMemcard.h"
#include "Common/Swap.h"
static void ByteSwap(u8* valueA, u8* valueB)
{

View File

@ -7,10 +7,10 @@
#include <algorithm>
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/NandPaths.h"
#include "Common/NonCopyable.h"
#include "Common/Swap.h"
#include "Common/Timer.h"
#include "Core/HW/EXI/EXI_DeviceIPL.h"

View File

@ -2,12 +2,13 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/HW/GPFifo.h"
#include <cstring>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Core/HW/GPFifo.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/ProcessorInterface.h"
#include "Core/PowerPC/JitInterface.h"

View File

@ -11,10 +11,10 @@
#include <memory>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MemArena.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
#include "Core/HW/AudioInterface.h"
#include "Core/HW/DSP.h"

View File

@ -9,6 +9,7 @@
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "Core/PowerPC/PowerPC.h"
// Global declarations

View File

@ -3,9 +3,11 @@
// Refer to the license.txt file included.
#include "Core/HW/Sram.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
// english

View File

@ -7,6 +7,8 @@
// Licensed under the terms of the GNU GPL, version 2
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#include "Core/HW/WiiSaveCrypted.h"
#include <cinttypes>
#include <cstddef>
#include <cstdio>
@ -19,7 +21,6 @@
#include <vector>
#include "Common/Align.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Crypto/ec.h"
#include "Common/FileUtil.h"
@ -27,8 +28,7 @@
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/HW/WiiSaveCrypted.h"
#include "Common/Swap.h"
const u8 CWiiSaveCrypted::s_sd_key[16] = {0xAB, 0x01, 0xB9, 0xD8, 0xE1, 0x62, 0x2B, 0x08,
0xAF, 0xBA, 0xD8, 0x4D, 0xBF, 0xC2, 0xA5, 0x5D};

View File

@ -25,6 +25,7 @@
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "Core/Core.h"
#include "Core/HW/WiimoteEmu/Attachment/Attachment.h"
#include "Core/HW/WiimoteEmu/WiimoteEmu.h"

View File

@ -2,17 +2,18 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <unordered_set>
#include "Core/HW/WiimoteReal/WiimoteReal.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/IniFile.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Common/Thread.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/ES/ES.h"
#include <algorithm>
#include <cinttypes>
#include <cstdio>
@ -15,23 +17,18 @@
#include "Common/Align.h"
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/Swap.h"
#include "Core/Boot/Boot.h"
#include "Core/Boot/Boot_DOL.h"
#include "Core/ConfigManager.h"
#include "Core/HLE/HLE.h"
#include "Core/HW/DVDInterface.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/ES/ES.h"
#include "Core/IOS/ES/Formats.h"
#include "Core/PatchEngine.h"
#include "Core/PowerPC/PPCSymbolDB.h"
#include "Core/PowerPC/PowerPC.h"
#include "Core/WiiRoot.h"
#include "Core/ec_wii.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/Volume.h"

View File

@ -11,9 +11,9 @@
#include <vector>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Crypto/AES.h"
#include "Common/Swap.h"
namespace IOS
{

View File

@ -6,12 +6,12 @@
#include <utility>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/Swap.h"
#include "Core/Boot/Boot.h"
#include "Core/Boot/ElfReader.h"
#include "Core/ConfigManager.h"

View File

@ -6,11 +6,11 @@
#include <cstring>
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
namespace IOS
{

View File

@ -7,10 +7,10 @@
#include <cstring>
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Network.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Network/MACUtils.h"

View File

@ -2,19 +2,17 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/Bluetooth/BTBase.h"
#include <memory>
#include <string>
#include <vector>
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/SysConf.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/Bluetooth/BTBase.h"
namespace IOS
{

View File

@ -15,12 +15,12 @@
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/LibusbContext.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Network.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Common/Thread.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"

View File

@ -8,8 +8,8 @@
#include <map>
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "Core/IOS/USB/Bluetooth/hci.h"
class PointerWrap;

View File

@ -2,15 +2,16 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/Common.h"
#include <algorithm>
#include "Common/Align.h"
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/Common.h"
namespace IOS
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/OH0/OH0.h"
#include <algorithm>
#include <cstring>
#include <istream>
@ -9,15 +11,12 @@
#include <tuple>
#include <utility>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/Common.h"
#include "Core/IOS/USB/OH0/OH0.h"
#include "Core/IOS/USB/USBV0.h"
namespace IOS

View File

@ -2,13 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/USBV0.h"
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Device.h"
#include "Core/IOS/USB/USBV0.h"
namespace IOS
{

View File

@ -2,15 +2,16 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/USBV4.h"
#include <algorithm>
#include <locale>
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Device.h"
#include "Core/IOS/USB/USBV4.h"
namespace IOS
{

View File

@ -2,19 +2,20 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/USB_HID/HIDv4.h"
#include <cstring>
#include <utility>
#include "Common/Align.h"
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/CoreTiming.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Device.h"
#include "Core/IOS/USB/Common.h"
#include "Core/IOS/USB/USBV4.h"
#include "Core/IOS/USB/USB_HID/HIDv4.h"
namespace IOS
{

View File

@ -2,16 +2,17 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/USB_KBD.h"
#include <cstring>
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h" // Local core functions
#include "Core/HW/Memmap.h"
#include "Core/IOS/USB/USB_KBD.h"
#ifdef _WIN32
#include <windows.h>

View File

@ -2,17 +2,19 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/USB/USB_VEN/VEN.h"
#include <cstring>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/CoreTiming.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Device.h"
#include "Core/IOS/USB/Common.h"
#include "Core/IOS/USB/USBV5.h"
#include "Core/IOS/USB/USB_VEN/VEN.h"
namespace IOS
{

View File

@ -21,7 +21,6 @@
#include <vector>
#include "Common/Assert.h"
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/IniFile.h"
#include "Common/StringUtil.h"
@ -33,8 +32,6 @@
#include "Core/PatchEngine.h"
#include "Core/PowerPC/PowerPC.h"
using namespace Common;
namespace PatchEngine
{
const char* PatchTypeStrings[] = {

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "Core/PowerPC/Interpreter/Interpreter.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"

View File

@ -6,6 +6,7 @@
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
#include "Core/PowerPC/Interpreter/Interpreter.h"

View File

@ -9,12 +9,12 @@
#include <string>
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/GekkoDisassembler.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Common/x64Reg.h"
#include "Core/HW/Memmap.h"
#include "Core/MachineContext.h"

View File

@ -9,6 +9,7 @@
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/JitArm64/Jit.h"

View File

@ -7,7 +7,7 @@
#include <cstring>
#include "Common/ChunkFile.h"
#include "Common/CommonFuncs.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "Core/PowerPC/JitInterface.h"
#include "Core/PowerPC/PowerPC.h"

View File

@ -10,14 +10,15 @@
#include "Core/ec_wii.h"
#include <cstdio>
#include <string.h>
#include <cstring>
#include <mbedtls/sha1.h>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Crypto/ec.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
constexpr u32 default_NG_id = 0x0403AC68;
constexpr u32 default_NG_key_id = 0x6AAB8C59;

View File

@ -17,8 +17,9 @@
#include <array>
#include <memory>
#include <string>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
namespace DiscIO
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DiscIO/NANDContentLoader.h"
#include <algorithm>
#include <array>
#include <cinttypes>
@ -15,7 +17,6 @@
#include <vector>
#include "Common/Align.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Crypto/AES.h"
#include "Common/FileUtil.h"
@ -23,9 +24,8 @@
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "DiscIO/Enums.h"
#include "DiscIO/NANDContentLoader.h"
#include "DiscIO/WiiWad.h"
namespace DiscIO

View File

@ -2,13 +2,14 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DiscIO/TGCBlob.h"
#include <memory>
#include <string>
#include <utility>
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "DiscIO/TGCBlob.h"
#include "Common/Swap.h"
namespace
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DiscIO/Volume.h"
#include <algorithm>
#include <map>
#include <string>
@ -9,12 +11,12 @@
#include <vector>
#include "Common/ColorUtil.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "DiscIO/Enums.h"
#include "DiscIO/Volume.h"
namespace DiscIO
{

View File

@ -9,9 +9,9 @@
#include <string>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Core/IOS/ES/Formats.h"
#include "DiscIO/Enums.h"

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DiscIO/VolumeWiiCrypted.h"
#include <cstddef>
#include <cstring>
#include <map>
@ -12,18 +14,17 @@
#include <utility>
#include <vector>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "DiscIO/Blob.h"
#include "DiscIO/Enums.h"
#include "DiscIO/FileMonitor.h"
#include "DiscIO/Filesystem.h"
#include "DiscIO/Volume.h"
#include "DiscIO/VolumeCreator.h"
#include "DiscIO/VolumeGC.h"
#include "DiscIO/VolumeWiiCrypted.h"
namespace DiscIO
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DiscIO/WbfsBlob.h"
#include <algorithm>
#include <cstdio>
#include <cstring>
@ -12,12 +14,10 @@
#include "Common/Align.h"
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "DiscIO/WbfsBlob.h"
#include "Common/Swap.h"
namespace DiscIO
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/Cheats/CheatSearchTab.h"
#include <algorithm>
#include <array>
#include <cstring>
@ -17,13 +19,13 @@
#include <wx/textctrl.h>
#include <wx/timer.h>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/StringUtil.h"
#include "Core/ActionReplay.h"
#include "Common/Swap.h"
#include "Core/Core.h"
#include "Core/HW/Memmap.h"
#include "DolphinWX/Cheats/CheatSearchTab.h"
#include "DolphinWX/Cheats/CreateCodeDialog.h"
#include "DolphinWX/WxUtils.h"

View File

@ -8,6 +8,8 @@
#include <wx/panel.h>
#include <wx/timer.h>
#include "Common/CommonTypes.h"
class wxButton;
class wxChoice;
class wxFocusEvent;

View File

@ -17,14 +17,14 @@
#include <wx/sizer.h>
#include <wx/stattext.h>
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/FileSearch.h"
#include "Common/FileUtil.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/HotkeyManager.h"
#include "DolphinWX/Frame.h"
#include "DolphinWX/Input/InputConfigDiag.h"
#include "DolphinWX/WxUtils.h"

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "DolphinWX/FifoPlayerDlg.h"
#include <algorithm>
#include <cstddef>
#include <mutex>
@ -27,11 +29,11 @@
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "Core/FifoPlayer/FifoDataFile.h"
#include "Core/FifoPlayer/FifoPlaybackAnalyzer.h"
#include "Core/FifoPlayer/FifoPlayer.h"
#include "Core/FifoPlayer/FifoRecorder.h"
#include "DolphinWX/FifoPlayerDlg.h"
#include "DolphinWX/WxUtils.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/OpcodeDecoding.h"

View File

@ -2,12 +2,12 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoBackends/OGL/SamplerCache.h"
#include <memory>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/GL/GLInterfaceBase.h"
#include "VideoBackends/OGL/SamplerCache.h"
#include "VideoCommon/SamplerCommon.h"
#include "VideoCommon/VideoConfig.h"

View File

@ -6,17 +6,16 @@
#include <cstring>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/SWRenderer.h"
#include "VideoBackends/Software/TextureSampler.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/Fifo.h"
#include "VideoCommon/ImageWrite.h"
#include "VideoCommon/Statistics.h"
#include "VideoCommon/VideoConfig.h"

View File

@ -8,9 +8,10 @@
#include <cstddef>
#include <cstring>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/PerfQueryBase.h"

View File

@ -2,13 +2,15 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoBackends/Software/TextureEncoder.h"
#include "Common/Align.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "VideoBackends/Software/EfbInterface.h"
#include "VideoBackends/Software/TextureEncoder.h"
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/LookUpTables.h"

View File

@ -8,11 +8,11 @@
#include <cmath>
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "VideoBackends/Software/NativeVertexFormat.h"
#include "VideoBackends/Software/Vec3.h"

View File

@ -5,9 +5,10 @@
#pragma once
#include <cstring>
#include "Common/Common.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
class DataReader
{

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/HiresTextures.h"
#include <SOIL/SOIL.h>
#include <algorithm>
#include <cinttypes>
@ -22,10 +24,10 @@
#include "Common/Logging/Log.h"
#include "Common/MemoryUtil.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
#include "Common/Thread.h"
#include "Common/Timer.h"
#include "Core/ConfigManager.h"
#include "VideoCommon/HiresTextures.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/VideoConfig.h"

View File

@ -5,9 +5,10 @@
#include <algorithm>
#include <cmath>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/TextureDecoder_Util.h"

View File

@ -6,8 +6,9 @@
#include <cmath>
#include "Common/CPUDetect.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/TextureDecoder.h"
#include "VideoCommon/TextureDecoder_Util.h"

View File

@ -7,10 +7,10 @@
#include <cstring>
#include "Common/CPUDetect.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Intrinsics.h"
#include "Common/MsgHandler.h"
#include "Common/Swap.h"
#include "VideoCommon/LookUpTables.h"
#include "VideoCommon/TextureDecoder.h"

View File

@ -4,8 +4,9 @@
#include <cstring>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexLoaderUtils.h"

View File

@ -2,17 +2,18 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/VertexLoader_Normal.h"
#include <cmath>
#include <type_traits>
#include "Common/Common.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexLoaderUtils.h"
#include "VideoCommon/VertexLoader_Normal.h"
// warning: mapping buffer should be disabled to use this
#define LOG_NORM() // PRIM_LOG("norm: %f %f %f, ", ((float*)g_vertex_manager_write_ptr)[-3],

View File

@ -5,6 +5,7 @@
#pragma once
#include "Common/CommonTypes.h"
#include "VideoCommon/VertexLoader.h"
class VertexLoader_Normal
{

View File

@ -2,16 +2,18 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/VertexLoader_Position.h"
#include <limits>
#include <type_traits>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexLoaderUtils.h"
#include "VideoCommon/VertexLoader_Position.h"
#include "VideoCommon/VideoCommon.h"
template <typename T>

View File

@ -5,6 +5,7 @@
#pragma once
#include "Common/CommonTypes.h"
#include "VideoCommon/VertexLoader.h"
class VertexLoader_Position
{

View File

@ -2,15 +2,17 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "VideoCommon/VertexLoader_TextCoord.h"
#include <type_traits>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Swap.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/VertexLoader.h"
#include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexLoaderUtils.h"
#include "VideoCommon/VertexLoader_TextCoord.h"
template <int N>
void LOG_TEX();

View File

@ -5,6 +5,7 @@
#pragma once
#include "Common/CommonTypes.h"
#include "VideoCommon/VertexLoader.h"
class VertexLoader_TextCoord
{

View File

@ -2,10 +2,12 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
#include "Core/HW/Memmap.h"
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/DataReader.h"
#include "VideoCommon/Fifo.h"

View File

@ -11,4 +11,5 @@ add_dolphin_test(FlagTest FlagTest.cpp)
add_dolphin_test(MathUtilTest MathUtilTest.cpp)
add_dolphin_test(NandPathsTest NandPathsTest.cpp)
add_dolphin_test(StringUtilTest StringUtilTest.cpp)
add_dolphin_test(SwapTest SwapTest.cpp)
add_dolphin_test(x64EmitterTest x64EmitterTest.cpp)

View File

@ -30,11 +30,3 @@ TEST(CommonFuncs, CrashMacro)
{
EXPECT_DEATH({ Crash(); }, "");
}
TEST(CommonFuncs, Swap)
{
EXPECT_EQ(0xf0, Common::swap8(0xf0));
EXPECT_EQ(0x1234, Common::swap16(0x3412));
EXPECT_EQ(0x12345678u, Common::swap32(0x78563412));
EXPECT_EQ(0x123456789abcdef0ull, Common::swap64(0xf0debc9a78563412ull));
}

View File

@ -0,0 +1,15 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <gtest/gtest.h>
#include "Common/Swap.h"
TEST(Swap, SwapByValue)
{
EXPECT_EQ(0xf0, Common::swap8(0xf0));
EXPECT_EQ(0x1234, Common::swap16(0x3412));
EXPECT_EQ(0x12345678u, Common::swap32(0x78563412));
EXPECT_EQ(0x123456789abcdef0ull, Common::swap64(0xf0debc9a78563412ull));
}