libxenia-base can now compile with clang.

This commit is contained in:
Ben Vanik 2015-07-15 23:02:04 -07:00
parent f520d3a2a4
commit 74d2df2004
8 changed files with 67 additions and 12 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup>
<ClCompile>
<MultiProcessorCompilation>false</MultiProcessorCompilation>
<MinimalRebuild />
<ExceptionHandling>false</ExceptionHandling>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

View File

@ -9,7 +9,7 @@
<ItemDefinitionGroup>
<ClCompile>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(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)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>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)</PreprocessorDefinitions>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>

View File

@ -5,6 +5,10 @@
<Configuration>Checked</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Clang|x64">
<Configuration>Clang</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
@ -60,6 +64,7 @@
<ProjectGuid>{93533067-6449-4691-88A8-026EBCFDCA97}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>libxeniabase</RootNamespace>
<TargetPlatformVersion>8.1</TargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
@ -81,6 +86,10 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Clang|x64'">
<PlatformToolset>LLVM-vs2014</PlatformToolset>
<ConfigurationType>StaticLibrary</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
@ -102,6 +111,11 @@
<Import Project="build\Xenia.Cpp.$(Platform).Common.props" />
<Import Project="build\Xenia.Cpp.$(Platform).$(Configuration).props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Clang|x64'">
<Import Project="build\Xenia.Cpp.x64.Common.props" />
<Import Project="build\Xenia.Cpp.x64.Debug.props" />
<Import Project="build\Xenia.Cpp.x64.Clang.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">

View File

@ -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; }

View File

@ -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);
}

View File

@ -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<uint8_t>(__builtin_clzll(v));
}
#endif // XE_COMPILER_MSVC
#endif // XE_PLATFORM_WIN32
inline uint8_t lzcnt(int8_t v) { return lzcnt(static_cast<uint8_t>(v)); }
inline uint8_t lzcnt(int16_t v) { return lzcnt(static_cast<uint16_t>(v)); }
inline uint8_t lzcnt(int32_t v) { return lzcnt(static_cast<uint32_t>(v)); }
@ -119,7 +119,7 @@ inline uint8_t lzcnt(int64_t v) { return lzcnt(static_cast<uint64_t>(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<unsigned long*>(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<uint32_t>(v), out_first_set_index);
}
@ -160,7 +160,7 @@ template <typename T>
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 <int N>

View File

@ -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<void*>(uint64_t(address) & 0xFFFFFFFF);
}
void copy_and_swap_16_aligned(uint16_t* dest, const uint16_t* src,

View File

@ -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