Rename cpu_detect.h to platform.h and add OS

This commit is contained in:
Connor McLaughlin 2021-04-04 13:01:05 +10:00
parent d41b5be908
commit 2ac6f60bbb
12 changed files with 75 additions and 49 deletions

View file

@ -24,7 +24,6 @@ add_library(common
cd_subchannel_replacement.h
cd_xa.cpp
cd_xa.h
cpu_detect.h
crash_handler.cpp
crash_handler.h
dimensional_array.h
@ -66,6 +65,7 @@ add_library(common
memory_arena.h
page_fault_handler.cpp
page_fault_handler.h
platform.h
pbp_types.h
progress_callback.cpp
progress_callback.h

View file

@ -6,11 +6,11 @@
#include "assert.h"
#include "cd_image.h"
#include "cd_subchannel_replacement.h"
#include "cpu_detect.h"
#include "error.h"
#include "file_system.h"
#include "libchdr/chd.h"
#include "log.h"
#include "platform.h"
#include <algorithm>
#include <cerrno>
#include <cstdio>

View file

@ -59,7 +59,6 @@
<ClInclude Include="byte_stream.h" />
<ClInclude Include="cd_image.h" />
<ClInclude Include="cd_image_hasher.h" />
<ClInclude Include="cpu_detect.h" />
<ClInclude Include="crash_handler.h" />
<ClInclude Include="d3d11\shader_cache.h" />
<ClInclude Include="d3d11\shader_compiler.h" />
@ -94,6 +93,7 @@
<ClInclude Include="md5_digest.h" />
<ClInclude Include="null_audio_stream.h" />
<ClInclude Include="pbp_types.h" />
<ClInclude Include="platform.h" />
<ClInclude Include="progress_callback.h" />
<ClInclude Include="memory_arena.h" />
<ClInclude Include="page_fault_handler.h" />

View file

@ -45,7 +45,6 @@
<ClInclude Include="file_system.h" />
<ClInclude Include="string_util.h" />
<ClInclude Include="md5_digest.h" />
<ClInclude Include="cpu_detect.h" />
<ClInclude Include="d3d11\shader_cache.h">
<Filter>d3d11</Filter>
</ClInclude>
@ -112,6 +111,7 @@
<ClInclude Include="easing.h" />
<ClInclude Include="pbp_types.h" />
<ClInclude Include="error.h" />
<ClInclude Include="platform.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="jit_code_buffer.cpp" />

View file

@ -1,35 +0,0 @@
#pragma once
#if defined(_MSC_VER)
#if defined(_M_X64)
#define CPU_X64 1
#elif defined(_M_IX86)
#define CPU_X86 1
#elif defined(_M_ARM64)
#define CPU_AARCH64 1
#elif defined(_M_ARM)
#define CPU_AARCH32 1
#else
#error Unknown architecture.
#endif
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__)
#define CPU_X64 1
#elif defined(__i386__)
#define CPU_X86 1
#elif defined(__aarch64__)
#define CPU_AARCH64 1
#elif defined(__arm__)
#define CPU_AARCH32 1
#else
#error Unknown architecture.
#endif
#else
#error Unknown compiler.
#endif

View file

@ -1,8 +1,8 @@
#include "jit_code_buffer.h"
#include "align.h"
#include "assert.h"
#include "common/log.h"
#include "cpu_detect.h"
#include "log.h"
#include "platform.h"
#include <algorithm>
Log_SetChannel(JitCodeBuffer);

View file

@ -1,6 +1,6 @@
#include "page_fault_handler.h"
#include "common/cpu_detect.h"
#include "common/log.h"
#include "log.h"
#include "platform.h"
#include <algorithm>
#include <cstring>
#include <mutex>
@ -8,7 +8,7 @@
Log_SetChannel(Common::PageFaultHandler);
#if defined(WIN32)
#include "common/windows_headers.h"
#include "windows_headers.h"
#elif defined(__linux__) || defined(__ANDROID__)
#include <signal.h>
#include <ucontext.h>

61
src/common/platform.h Normal file
View file

@ -0,0 +1,61 @@
#pragma once
#if defined(_MSC_VER)
#if defined(_M_X64)
#define CPU_X64 1
#elif defined(_M_IX86)
#define CPU_X86 1
#elif defined(_M_ARM64)
#define CPU_AARCH64 1
#elif defined(_M_ARM)
#define CPU_AARCH32 1
#else
#error Unknown architecture.
#endif
#elif defined(__GNUC__) || defined(__clang__)
#if defined(__x86_64__)
#define CPU_X64 1
#elif defined(__i386__)
#define CPU_X86 1
#elif defined(__aarch64__)
#define CPU_AARCH64 1
#elif defined(__arm__)
#define CPU_AARCH32 1
#else
#error Unknown architecture.
#endif
#else
#error Unknown compiler.
#endif
#if defined(CPU_X64)
#define CPU_ARCH_STR "x64"
#elif defined(CPU_X86)
#define CPU_ARCH_STR "x86"
#elif defined(CPU_AARCH32)
#define CPU_ARCH_STR "AArch32"
#elif defined(CPU_AARCH64)
#define CPU_ARCH_STR "AArch64"
#else
#define CPU_ARCH_STR "Unknown"
#endif
#if defined(_WIN32)
#define SYSTEM_STR "Windows"
#elif defined(__ANDROID__)
#define SYSTEM_STR "Android"
#elif defined(__linux__)
#define SYSTEM_STR "Linux"
#elif defined(__FreeBSD__)
#define SYSTEM_STR "FreeBSD"
#elif defined(__APPLE__)
#define SYSTEM_STR "macOS"
#else
#define SYSTEM_STR "Unknown"
#endif

View file

@ -1,8 +1,8 @@
#include "cdrom.h"
#include "common/align.h"
#include "common/cd_image.h"
#include "common/cpu_detect.h"
#include "common/log.h"
#include "common/platform.h"
#include "common/state_wrapper.h"
#include "dma.h"
#include "interrupt_controller.h"

View file

@ -1,5 +1,5 @@
#pragma once
#include "common/cpu_detect.h"
#include "common/platform.h"
#include "cpu_types.h"
#if defined(CPU_X64)

View file

@ -1,9 +1,9 @@
#include "gpu_sw.h"
#include "common/align.h"
#include "common/assert.h"
#include "common/cpu_detect.h"
#include "common/log.h"
#include "common/make_array.h"
#include "common/platform.h"
#include "host_display.h"
#include "system.h"
#include <algorithm>

View file

@ -1,7 +1,7 @@
#include "texture_replacements.h"
#include "common/cpu_detect.h"
#include "common/file_system.h"
#include "common/log.h"
#include "common/platform.h"
#include "common/string_util.h"
#include "common/timer.h"
#include "host_interface.h"