From 74d2df20040c9dff3c64546c22540e92a3693c68 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 15 Jul 2015 23:02:04 -0700 Subject: [PATCH] libxenia-base can now compile with clang. --- build/Xenia.Cpp.x64.Clang.props | 14 ++++++++++++++ build/Xenia.Cpp.x64.Common.props | 2 +- libxenia-base.vcxproj | 14 ++++++++++++++ src/xenia/base/byte_order.h | 4 ++-- src/xenia/base/clock_win.cc | 2 +- src/xenia/base/math.h | 12 ++++++------ src/xenia/base/memory.h | 4 ++-- xenia.sln | 27 +++++++++++++++++++++++++++ 8 files changed, 67 insertions(+), 12 deletions(-) create mode 100644 build/Xenia.Cpp.x64.Clang.props diff --git a/build/Xenia.Cpp.x64.Clang.props b/build/Xenia.Cpp.x64.Clang.props new file mode 100644 index 000000000..7c3b4ede3 --- /dev/null +++ b/build/Xenia.Cpp.x64.Clang.props @@ -0,0 +1,14 @@ + + + + + + + + false + + false + + + + \ No newline at end of file diff --git a/build/Xenia.Cpp.x64.Common.props b/build/Xenia.Cpp.x64.Common.props index 0124f7ef7..24ed4a356 100644 --- a/build/Xenia.Cpp.x64.Common.props +++ b/build/Xenia.Cpp.x64.Common.props @@ -9,7 +9,7 @@ true - $(SolutionDir)third_party\flatbuffers\include\;$(SolutionDir)third_party\turbobadger\src\;$(SolutionDir)third_party\gflags\src\;$(SolutionDir)third_party\elemental-forms\src\;$(SolutionDir)src\;$(SolutionDir)third_party;$(SolutionDir) + $(SolutionDir)third_party\flatbuffers\include;$(SolutionDir)third_party\turbobadger\src;$(SolutionDir)third_party\gflags\src;$(SolutionDir)third_party\elemental-forms\src;$(SolutionDir)src;$(SolutionDir)third_party;$(SolutionDir) GLEW_STATIC=1;GLEW_MX=1;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;WIN32;_WIN64=1;_AMD64=1;MICROPROFILE_MAX_THREADS=128;CAPSTONE_X86_ATT_DISABLE;CAPSTONE_DIET_NO;CAPSTONE_X86_REDUCE_NO;CAPSTONE_HAS_X86;CAPSTONE_USE_SYS_DYN_MEM;XBYAK_NO_OP_NAMES;%(PreprocessorDefinitions) Level4 true diff --git a/libxenia-base.vcxproj b/libxenia-base.vcxproj index 29bc2dfd2..f0ac061d0 100644 --- a/libxenia-base.vcxproj +++ b/libxenia-base.vcxproj @@ -5,6 +5,10 @@ Checked x64 + + Clang + x64 + Debug x64 @@ -60,6 +64,7 @@ {93533067-6449-4691-88A8-026EBCFDCA97} Win32Proj libxeniabase + 8.1 @@ -81,6 +86,10 @@ true Unicode + + LLVM-vs2014 + StaticLibrary + @@ -102,6 +111,11 @@ + + + + + diff --git a/src/xenia/base/byte_order.h b/src/xenia/base/byte_order.h index bb0fc145d..7cd842c38 100644 --- a/src/xenia/base/byte_order.h +++ b/src/xenia/base/byte_order.h @@ -21,7 +21,7 @@ namespace xe { -#if XE_COMPILER_MSVC +#if XE_PLATFORM_WIN32 #define XENIA_BASE_BYTE_SWAP_16 _byteswap_ushort #define XENIA_BASE_BYTE_SWAP_32 _byteswap_ulong #define XENIA_BASE_BYTE_SWAP_64 _byteswap_uint64 @@ -33,7 +33,7 @@ namespace xe { #define XENIA_BASE_BYTE_SWAP_16 __bswap_16 #define XENIA_BASE_BYTE_SWAP_32 __bswap_32 #define XENIA_BASE_BYTE_SWAP_64 __bswap_64 -#endif // XE_COMPILER_MSVC +#endif // XE_PLATFORM_WIN32 inline int8_t byte_swap(int8_t value) { return value; } inline uint8_t byte_swap(uint8_t value) { return value; } diff --git a/src/xenia/base/clock_win.cc b/src/xenia/base/clock_win.cc index a9bf53eb5..ba62e0008 100644 --- a/src/xenia/base/clock_win.cc +++ b/src/xenia/base/clock_win.cc @@ -14,7 +14,7 @@ namespace xe { uint64_t Clock::host_tick_frequency() { - static LARGE_INTEGER frequency = {0}; + static LARGE_INTEGER frequency = {{0}}; if (!frequency.QuadPart) { QueryPerformanceFrequency(&frequency); } diff --git a/src/xenia/base/math.h b/src/xenia/base/math.h index 0bf11e7af..2ed2de0f7 100644 --- a/src/xenia/base/math.h +++ b/src/xenia/base/math.h @@ -60,7 +60,7 @@ T next_pow2(T value) { // The number of leading zero bits in the value parameter. If value is zero, the // return value is the size of the input operand (8, 16, 32, or 64). If the most // significant bit of value is one, the return value is zero. -#if XE_COMPILER_MSVC +#if XE_PLATFORM_WIN32 // TODO(benvanik): runtime magic so these point to an appropriate implementation // at runtime based on CPU features #if 0 @@ -109,7 +109,7 @@ inline uint8_t lzcnt(uint32_t v) { inline uint8_t lzcnt(uint64_t v) { return static_cast(__builtin_clzll(v)); } -#endif // XE_COMPILER_MSVC +#endif // XE_PLATFORM_WIN32 inline uint8_t lzcnt(int8_t v) { return lzcnt(static_cast(v)); } inline uint8_t lzcnt(int16_t v) { return lzcnt(static_cast(v)); } inline uint8_t lzcnt(int32_t v) { return lzcnt(static_cast(v)); } @@ -119,7 +119,7 @@ inline uint8_t lzcnt(int64_t v) { return lzcnt(static_cast(v)); } // Search the value from least significant bit (LSB) to the most significant bit // (MSB) for a set bit (1). // Returns false if no bits are set and the output index is invalid. -#if XE_COMPILER_MSVC +#if XE_PLATFORM_WIN32 inline bool bit_scan_forward(uint32_t v, uint32_t* out_first_set_index) { return _BitScanForward(reinterpret_cast(out_first_set_index), v) != 0; @@ -139,7 +139,7 @@ inline bool bit_scan_forward(uint64_t v, uint32_t* out_first_set_index) { *out_first_set_index = i; return i != 0; } -#endif // XE_COMPILER_MSVC +#endif // XE_PLATFORM_WIN32 inline bool bit_scan_forward(int32_t v, uint32_t* out_first_set_index) { return bit_scan_forward(static_cast(v), out_first_set_index); } @@ -160,7 +160,7 @@ template inline T rotate_left(T v, uint8_t sh) { return (T(v) << sh) | (T(v) >> ((sizeof(T) * 8) - sh)); } -#if XE_COMPILER_MSVC +#if XE_PLATFORM_WIN32 template <> inline uint8_t rotate_left(uint8_t v, uint8_t sh) { return _rotl8(v, sh); @@ -177,7 +177,7 @@ template <> inline uint64_t rotate_left(uint64_t v, uint8_t sh) { return _rotl64(v, sh); } -#endif // XE_COMPILER_MSVC +#endif // XE_PLATFORM_WIN32 // Utilities for SSE values. template diff --git a/src/xenia/base/memory.h b/src/xenia/base/memory.h index c0a678d42..ee29359db 100644 --- a/src/xenia/base/memory.h +++ b/src/xenia/base/memory.h @@ -80,8 +80,8 @@ size_t hash_combine(size_t seed, const T& v, const Ts&... vs) { // TODO(benvanik): move into xe::memory:: -constexpr void* low_address(void* address) { - return (void*)(uint64_t(address) & 0xFFFFFFFF); +inline void* low_address(void* address) { + return reinterpret_cast(uint64_t(address) & 0xFFFFFFFF); } void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src, diff --git a/xenia.sln b/xenia.sln index db7d23ddd..555094e71 100644 --- a/xenia.sln +++ b/xenia.sln @@ -70,84 +70,111 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Checked|x64 = Checked|x64 + Clang|x64 = Clang|x64 Debug|x64 = Debug|x64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {88F908AF-79A3-4ED4-87C7-A76368205264}.Checked|x64.ActiveCfg = Checked|x64 {88F908AF-79A3-4ED4-87C7-A76368205264}.Checked|x64.Build.0 = Checked|x64 + {88F908AF-79A3-4ED4-87C7-A76368205264}.Clang|x64.ActiveCfg = Debug|x64 + {88F908AF-79A3-4ED4-87C7-A76368205264}.Clang|x64.Build.0 = Debug|x64 {88F908AF-79A3-4ED4-87C7-A76368205264}.Debug|x64.ActiveCfg = Debug|x64 {88F908AF-79A3-4ED4-87C7-A76368205264}.Debug|x64.Build.0 = Debug|x64 {88F908AF-79A3-4ED4-87C7-A76368205264}.Release|x64.ActiveCfg = Release|x64 {88F908AF-79A3-4ED4-87C7-A76368205264}.Release|x64.Build.0 = Release|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Checked|x64.ActiveCfg = Checked|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Checked|x64.Build.0 = Checked|x64 + {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Clang|x64.ActiveCfg = Debug|x64 + {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Clang|x64.Build.0 = Debug|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Debug|x64.ActiveCfg = Debug|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Debug|x64.Build.0 = Debug|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Release|x64.ActiveCfg = Release|x64 {0CE149F6-41C3-4224-9E57-C02E8C7CD312}.Release|x64.Build.0 = Release|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Checked|x64.ActiveCfg = Checked|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Checked|x64.Build.0 = Checked|x64 + {AE4AF147-715A-4C24-8BFA-136332DED28F}.Clang|x64.ActiveCfg = Debug|x64 + {AE4AF147-715A-4C24-8BFA-136332DED28F}.Clang|x64.Build.0 = Debug|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Debug|x64.ActiveCfg = Debug|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Debug|x64.Build.0 = Debug|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Release|x64.ActiveCfg = Release|x64 {AE4AF147-715A-4C24-8BFA-136332DED28F}.Release|x64.Build.0 = Release|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Checked|x64.ActiveCfg = Checked|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Checked|x64.Build.0 = Checked|x64 + {838020F9-94AA-4314-996D-69B923C45D39}.Clang|x64.ActiveCfg = Debug|x64 + {838020F9-94AA-4314-996D-69B923C45D39}.Clang|x64.Build.0 = Debug|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Debug|x64.ActiveCfg = Debug|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Debug|x64.Build.0 = Debug|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Release|x64.ActiveCfg = Release|x64 {838020F9-94AA-4314-996D-69B923C45D39}.Release|x64.Build.0 = Release|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Checked|x64.ActiveCfg = Checked|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Checked|x64.Build.0 = Checked|x64 + {CE3A80D4-12DB-4164-A050-67E5796A019B}.Clang|x64.ActiveCfg = Debug|x64 + {CE3A80D4-12DB-4164-A050-67E5796A019B}.Clang|x64.Build.0 = Debug|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Debug|x64.ActiveCfg = Debug|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Debug|x64.Build.0 = Debug|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Release|x64.ActiveCfg = Release|x64 {CE3A80D4-12DB-4164-A050-67E5796A019B}.Release|x64.Build.0 = Release|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Checked|x64.ActiveCfg = Checked|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Checked|x64.Build.0 = Checked|x64 + {D3069A06-62FC-479F-9F5C-23B4377481B0}.Clang|x64.ActiveCfg = Debug|x64 + {D3069A06-62FC-479F-9F5C-23B4377481B0}.Clang|x64.Build.0 = Debug|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Debug|x64.ActiveCfg = Debug|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Debug|x64.Build.0 = Debug|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Release|x64.ActiveCfg = Release|x64 {D3069A06-62FC-479F-9F5C-23B4377481B0}.Release|x64.Build.0 = Release|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Checked|x64.ActiveCfg = Checked|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Checked|x64.Build.0 = Checked|x64 + {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Clang|x64.ActiveCfg = Debug|x64 + {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Clang|x64.Build.0 = Debug|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Debug|x64.ActiveCfg = Debug|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Debug|x64.Build.0 = Debug|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Release|x64.ActiveCfg = Release|x64 {6EC54AD0-4F5B-48D9-B820-43DF2F0DC83C}.Release|x64.Build.0 = Release|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Checked|x64.ActiveCfg = Checked|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Checked|x64.Build.0 = Checked|x64 + {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Clang|x64.ActiveCfg = Debug|x64 + {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Clang|x64.Build.0 = Debug|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Debug|x64.ActiveCfg = Debug|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Debug|x64.Build.0 = Debug|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Release|x64.ActiveCfg = Release|x64 {9B8AC22F-9147-490F-BE03-3B8BA31990A8}.Release|x64.Build.0 = Release|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Checked|x64.ActiveCfg = Debug|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Checked|x64.Build.0 = Debug|x64 + {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Clang|x64.ActiveCfg = Debug|x64 + {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Clang|x64.Build.0 = Debug|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Debug|x64.ActiveCfg = Debug|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Debug|x64.Build.0 = Debug|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.ActiveCfg = Release|x64 {21DDCB81-68A3-4AB2-8CB0-C2B051B9FDDC}.Release|x64.Build.0 = Release|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Checked|x64.ActiveCfg = Debug|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Checked|x64.Build.0 = Debug|x64 + {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Clang|x64.ActiveCfg = Debug|x64 + {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Clang|x64.Build.0 = Debug|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Debug|x64.ActiveCfg = Debug|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Debug|x64.Build.0 = Debug|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Release|x64.ActiveCfg = Release|x64 {C5BA52F0-C86B-4817-921C-CCA257FC04BE}.Release|x64.Build.0 = Release|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Checked|x64.ActiveCfg = Checked|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Checked|x64.Build.0 = Checked|x64 + {93533067-6449-4691-88A8-026EBCFDCA97}.Clang|x64.ActiveCfg = Clang|x64 + {93533067-6449-4691-88A8-026EBCFDCA97}.Clang|x64.Build.0 = Clang|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Debug|x64.ActiveCfg = Debug|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Debug|x64.Build.0 = Debug|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Release|x64.ActiveCfg = Release|x64 {93533067-6449-4691-88A8-026EBCFDCA97}.Release|x64.Build.0 = Release|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Checked|x64.ActiveCfg = Checked|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Checked|x64.Build.0 = Checked|x64 + {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Clang|x64.ActiveCfg = Debug|x64 + {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Clang|x64.Build.0 = Debug|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Debug|x64.ActiveCfg = Debug|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Debug|x64.Build.0 = Debug|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Release|x64.ActiveCfg = Release|x64 {156102D7-F2DD-4618-B2EB-2DFE607EE6DD}.Release|x64.Build.0 = Release|x64 {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Checked|x64.ActiveCfg = Checked|x64 {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Checked|x64.Build.0 = Checked|x64 + {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Clang|x64.ActiveCfg = Debug|x64 + {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Clang|x64.Build.0 = Debug|x64 {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Debug|x64.ActiveCfg = Debug|x64 {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Debug|x64.Build.0 = Debug|x64 {C3FDE1FE-1FCB-4156-BB37-2E38F5C2DFE7}.Release|x64.ActiveCfg = Release|x64