Merge pull request #6273 from leoetlino/c++17

Enable C++17
This commit is contained in:
Léo Lam
2019-05-05 10:24:18 +02:00
committed by GitHub
43 changed files with 118 additions and 3629 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
########################################
# General setup
#
cmake_minimum_required(VERSION 3.5.0)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_OSX_ARCHITECTURES "x86_64")
# Minimum OS X version.
# This is inserted into the Info.plist as well.
@@ -203,8 +203,8 @@ endif()
# Enforce minimum GCC version
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0)
message(FATAL_ERROR "Dolphin requires at least GCC 6.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
message(FATAL_ERROR "Dolphin requires at least GCC 7.0 (found ${CMAKE_CXX_COMPILER_VERSION})")
endif()
if(CMAKE_GENERATOR MATCHES "Ninja")
+1
View File
@@ -60,6 +60,7 @@ android {
externalNativeBuild {
cmake {
path "../../../CMakeLists.txt"
version "3.10.2"
}
}
+3 -20
View File
@@ -9,26 +9,9 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
if(CMAKE_C_COMPILER_ID MATCHES "MSVC")
# enable the latest C++ standard feature set,
# and also disable MSVC specific extensions
# to be even more standards compliant.
check_and_add_flag(CPPLATEST /std:c++latest)
check_and_add_flag(STANDARD_COMPLIANCE /permissive-)
else()
# Enable C++17, but fall back to C++14 if it isn't available.
# CMAKE_CXX_STANDARD cannot be used here because we require C++14 or newer, not any standard.
check_and_add_flag(CXX17 -std=c++17)
if(NOT FLAG_CXX_CXX17)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
# These compat headers must not be in the include path when building with MSVC,
# because it currently does not support __has_include_next / #include_next.
include_directories(SYSTEM Core/Common/Compat)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# These aren't actually needed for C11/C++11
# but some dependencies require them (LLVM, libav).
+5 -5
View File
@@ -4,13 +4,13 @@
#include "AudioCommon/Mixer.h"
#include <algorithm>
#include <cmath>
#include <cstring>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/Swap.h"
#include "Core/ConfigManager.h"
@@ -86,14 +86,14 @@ unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples,
int sampleL = ((l1 << 16) + (l2 - l1) * (u16)m_frac) >> 16;
sampleL = (sampleL * lvolume) >> 8;
sampleL += samples[currentSample + 1];
samples[currentSample + 1] = MathUtil::Clamp(sampleL, -32767, 32767);
samples[currentSample + 1] = std::clamp(sampleL, -32767, 32767);
s16 r1 = Common::swap16(m_buffer[(indexR + 1) & INDEX_MASK]); // current
s16 r2 = Common::swap16(m_buffer[(indexR2 + 1) & INDEX_MASK]); // next
int sampleR = ((r1 << 16) + (r2 - r1) * (u16)m_frac) >> 16;
sampleR = (sampleR * rvolume) >> 8;
sampleR += samples[currentSample];
samples[currentSample] = MathUtil::Clamp(sampleR, -32767, 32767);
samples[currentSample] = std::clamp(sampleR, -32767, 32767);
m_frac += ratio;
indexR += 2 * (u16)(m_frac >> 16);
@@ -111,8 +111,8 @@ unsigned int Mixer::MixerFifo::Mix(short* samples, unsigned int numSamples,
s[1] = (s[1] * lvolume) >> 8;
for (; currentSample < numSamples * 2; currentSample += 2)
{
int sampleR = MathUtil::Clamp(s[0] + samples[currentSample + 0], -32767, 32767);
int sampleL = MathUtil::Clamp(s[1] + samples[currentSample + 1], -32767, 32767);
int sampleR = std::clamp(s[0] + samples[currentSample + 0], -32767, 32767);
int sampleL = std::clamp(s[1] + samples[currentSample + 1], -32767, 32767);
samples[currentSample + 0] = sampleR;
samples[currentSample + 1] = sampleL;
-45
View File
@@ -1,45 +0,0 @@
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
// MPark.Variant
//
// Copyright Michael Park, 2015-2017
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
#include <cstddef>
namespace mpark
{
struct in_place_t
{
explicit in_place_t() = default;
};
template <std::size_t I>
struct in_place_index_t
{
explicit in_place_index_t() = default;
};
template <typename T>
struct in_place_type_t
{
explicit in_place_type_t() = default;
};
#ifdef MPARK_VARIABLE_TEMPLATES
constexpr in_place_t in_place{};
template <std::size_t I>
constexpr in_place_index_t<I> in_place_index{};
template <typename T>
constexpr in_place_type_t<T> in_place_type{};
#endif
} // namespace mpark
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
-9
View File
@@ -4,15 +4,6 @@
#pragma once
// TODO: Replace this with [[maybe_unused]] directly when GCC 7 and clang 3.9
// are hard requirements.
#if defined(__GNUC__) || __clang__
// Disable "unused function" warnings for the ones manually marked as such.
#define DOLPHIN_UNUSED __attribute__((unused))
#else
#define DOLPHIN_UNUSED [[maybe_unused]]
#endif
#ifdef _WIN32
#define DOLPHIN_FORCE_INLINE __forceinline
#else
+1 -1
View File
@@ -173,7 +173,7 @@ private:
};
// y**2 + x*y = x**3 + x + b
DOLPHIN_UNUSED static const u8 ec_b[30] = {
[[maybe_unused]] static const u8 ec_b[30] = {
0x00, 0x66, 0x64, 0x7e, 0xde, 0x6c, 0x33, 0x2c, 0x7f, 0x8c, 0x09, 0x23, 0xbb, 0x58, 0x21,
0x3b, 0x33, 0x3b, 0x20, 0xe9, 0xce, 0x42, 0x81, 0xfe, 0x11, 0x5f, 0x7d, 0x8f, 0x90, 0xad};
+8 -14
View File
@@ -18,12 +18,6 @@ namespace MathUtil
constexpr double TAU = 6.2831853071795865;
constexpr double PI = TAU / 2;
template <class T>
constexpr T Clamp(const T val, const T& min, const T& max)
{
return std::max(min, std::min(max, val));
}
template <typename T>
constexpr auto Sign(const T& val) -> decltype((T{} < val) - (val < T{}))
{
@@ -81,20 +75,20 @@ struct Rectangle
// this Clamp.
void ClampLL(T x1, T y1, T x2, T y2)
{
left = Clamp(left, x1, x2);
right = Clamp(right, x1, x2);
top = Clamp(top, y2, y1);
bottom = Clamp(bottom, y2, y1);
left = std::clamp(left, x1, x2);
right = std::clamp(right, x1, x2);
top = std::clamp(top, y2, y1);
bottom = std::clamp(bottom, y2, y1);
}
// If the rectangle is in a coordinate system with an upper-left origin,
// use this Clamp.
void ClampUL(T x1, T y1, T x2, T y2)
{
left = Clamp(left, x1, x2);
right = Clamp(right, x1, x2);
top = Clamp(top, y1, y2);
bottom = Clamp(bottom, y1, y2);
left = std::clamp(left, x1, x2);
right = std::clamp(right, x1, x2);
top = std::clamp(top, y1, y2);
bottom = std::clamp(bottom, y1, y2);
}
};
+3 -2
View File
@@ -2,12 +2,13 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include "Core/DSP/DSPAccelerator.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
namespace DSP
{
@@ -89,7 +90,7 @@ u16 Accelerator::Read(const s16* coefs)
temp -= 16;
s32 val32 = (scale * temp) + ((0x400 + coef1 * m_yn1 + coef2 * m_yn2) >> 11);
val = static_cast<s16>(MathUtil::Clamp<s32>(val32, -0x7FFF, 0x7FFF));
val = static_cast<s16>(std::clamp<s32>(val32, -0x7FFF, 0x7FFF));
step_size_bytes = 2;
m_yn2 = m_yn1;
+4 -3
View File
@@ -2,6 +2,8 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include "Core/HW/DSPHLE/UCodes/AX.h"
#include "Common/ChunkFile.h"
@@ -9,7 +11,6 @@
#include "Common/File.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"
@@ -535,8 +536,8 @@ void AXUCode::OutputSamples(u32 lr_addr, u32 surround_addr)
// Output samples clamped to 16 bits and interlaced RLRLRLRLRL...
for (u32 i = 0; i < 5 * 32; ++i)
{
int left = MathUtil::Clamp(m_samples_left[i], -32767, 32767);
int right = MathUtil::Clamp(m_samples_right[i], -32767, 32767);
int left = std::clamp(m_samples_left[i], -32767, 32767);
int right = std::clamp(m_samples_right[i], -32767, 32767);
buffer[2 * i + 0] = Common::swap16(right);
buffer[2 * i + 1] = Common::swap16(left);
+4 -4
View File
@@ -12,11 +12,11 @@
#error AXVoice.h included without specifying version
#endif
#include <algorithm>
#include <functional>
#include <memory>
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
#include "Core/DSP/DSPAccelerator.h"
#include "Core/HW/DSP.h"
#include "Core/HW/DSPHLE/UCodes/AX.h"
@@ -413,7 +413,7 @@ void MixAdd(int* out, const s16* input, u32 count, u16* pvol, s16* dpop, bool ra
s64 sample = input[i];
sample *= volume;
sample >>= 15;
sample = MathUtil::Clamp((s32)sample, -32767, 32767); // -32768 ?
sample = std::clamp((s32)sample, -32767, 32767); // -32768 ?
out[i] += (s16)sample;
volume += volume_delta;
@@ -447,8 +447,8 @@ void ProcessVoice(PB_TYPE& pb, const AXBuffers& buffers, u16 count, AXMixControl
// Apply a global volume ramp using the volume envelope parameters.
for (u32 i = 0; i < count; ++i)
{
samples[i] = MathUtil::Clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767,
32767); // -32768 ?
samples[i] = std::clamp(((s32)samples[i] * pb.vol_env.cur_volume) >> 15, -32767,
32767); // -32768 ?
pb.vol_env.cur_volume += pb.vol_env.cur_volume_delta;
}
+5 -4
View File
@@ -4,12 +4,13 @@
//
#define AX_WII // Used in AXVoice.
#include <algorithm>
#include "Core/HW/DSPHLE/UCodes/AXWii.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Common/Swap.h"
#include "Core/HW/DSPHLE/DSPHLE.h"
#include "Core/HW/DSPHLE/MailHandler.h"
@@ -602,8 +603,8 @@ void AXWiiUCode::OutputSamples(u32 lr_addr, u32 surround_addr, u16 volume, bool
left = ((s64)left * volume_ramp[i]) >> 15;
right = ((s64)right * volume_ramp[i]) >> 15;
m_samples_left[i] = MathUtil::Clamp(left, -32767, 32767);
m_samples_right[i] = MathUtil::Clamp(right, -32767, 32767);
m_samples_left[i] = std::clamp(left, -32767, 32767);
m_samples_right[i] = std::clamp(right, -32767, 32767);
}
for (u32 i = 0; i < 3 * 32; ++i)
@@ -626,7 +627,7 @@ void AXWiiUCode::OutputWMSamples(u32* addresses)
u16* out = (u16*)HLEMemory_Get_Pointer(addresses[i]);
for (u32 j = 0; j < 3 * 6; ++j)
{
int sample = MathUtil::Clamp(in[j], -32767, 32767);
int sample = std::clamp(in[j], -32767, 32767);
out[j] = Common::swap16((u16)sample);
}
}
+4 -3
View File
@@ -4,6 +4,7 @@
#include "Core/HW/DSPHLE/UCodes/Zelda.h"
#include <algorithm>
#include <array>
#include <map>
@@ -1086,7 +1087,7 @@ void ZeldaAudioRenderer::ApplyReverb(bool post_rendering)
for (u16 j = 0; j < 8; ++j)
sample += (s32)buffer[i + j] * rpb.filter_coeffs[j];
sample >>= 15;
buffer[i] = MathUtil::Clamp(sample, -0x8000, 0x7FFF);
buffer[i] = std::clamp(sample, -0x8000, 0x7FFF);
}
};
@@ -1526,7 +1527,7 @@ void ZeldaAudioRenderer::Resample(VPB* vpb, const s16* src, MixingBuffer* dst)
dst_sample_unclamped += (s64)2 * coeffs[i] * input[i];
dst_sample_unclamped >>= 16;
dst_sample = (s16)MathUtil::Clamp<s64>(dst_sample_unclamped, -0x8000, 0x7FFF);
dst_sample = (s16)std::clamp<s64>(dst_sample_unclamped, -0x8000, 0x7FFF);
pos += ratio;
}
@@ -1764,7 +1765,7 @@ void ZeldaAudioRenderer::DecodeAFC(VPB* vpb, s16* dst, size_t block_count)
s32 sample =
delta * nibbles[i] + yn1 * m_afc_coeffs[idx * 2] + yn2 * m_afc_coeffs[idx * 2 + 1];
sample >>= 11;
sample = MathUtil::Clamp(sample, -0x8000, 0x7fff);
sample = std::clamp(sample, -0x8000, 0x7fff);
*dst++ = (s16)sample;
yn2 = yn1;
yn1 = sample;
+3 -3
View File
@@ -4,10 +4,10 @@
#pragma once
#include <algorithm>
#include <array>
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
namespace DSP
@@ -54,7 +54,7 @@ private:
s32 tmp = (u32)(*buf)[i] * (u32)vol;
tmp >>= 16 - B;
(*buf)[i] = (s16)MathUtil::Clamp(tmp, -0x8000, 0x7FFF);
(*buf)[i] = (s16)std::clamp(tmp, -0x8000, 0x7FFF);
}
}
template <size_t N>
@@ -96,7 +96,7 @@ private:
while (count--)
{
s32 vol_src = ((s32)*src++ * (s32)vol) >> 15;
*dst++ += MathUtil::Clamp(vol_src, -0x8000, 0x7FFF);
*dst++ += std::clamp(vol_src, -0x8000, 0x7FFF);
}
}
+2 -3
View File
@@ -15,7 +15,6 @@
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/File.h"
#include "Common/MathUtil.h"
#include "Common/MsgHandler.h"
#include "Common/StringUtil.h"
#include "Common/Swap.h"
@@ -609,8 +608,8 @@ u16 BlockAlloc::NextFreeBlock(u16 MaxBlock, u16 StartingBlock) const
{
if (m_free_blocks > 0)
{
StartingBlock = MathUtil::Clamp<u16>(StartingBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
MaxBlock = MathUtil::Clamp<u16>(MaxBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
StartingBlock = std::clamp<u16>(StartingBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
MaxBlock = std::clamp<u16>(MaxBlock, MC_FST_BLOCKS, BAT_SIZE + MC_FST_BLOCKS);
for (u16 i = StartingBlock; i < MaxBlock; ++i)
if (m_map[i - MC_FST_BLOCKS] == 0)
return i;
+2 -2
View File
@@ -314,9 +314,9 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int length)
m_last_cmd = buffer[0];
m_timestamp_sent = CoreTiming::GetTicks();
m_next_action = NextAction::WaitTransferTime;
[[fallthrough]];
}
// [[fallthrough]]b
case NextAction::WaitTransferTime:
{
int elapsed_time = static_cast<int>(CoreTiming::GetTicks() - m_timestamp_sent);
@@ -324,9 +324,9 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int length)
if (GetTransferTime(m_last_cmd) > elapsed_time)
return 0;
m_next_action = NextAction::ReceiveResponse;
[[fallthrough]];
}
// [[fallthrough]]
case NextAction::ReceiveResponse:
{
int num_data_received = m_sock_server.Receive(buffer);
+4 -3
View File
@@ -4,11 +4,12 @@
// Adapted from in_cube by hcs & destop
#include <algorithm>
#include "Core/HW/StreamADPCM.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
namespace StreamADPCM
{
@@ -30,7 +31,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
hist = (hist1 * 0x62) - (hist2 * 0x37);
break;
}
hist = MathUtil::Clamp((hist + 0x20) >> 6, -0x200000, 0x1fffff);
hist = std::clamp((hist + 0x20) >> 6, -0x200000, 0x1fffff);
s32 cur = (((s16)(bits << 12) >> (q & 0xf)) << 6) + hist;
@@ -38,7 +39,7 @@ static s16 ADPDecodeSample(s32 bits, s32 q, s32& hist1, s32& hist2)
hist1 = cur;
cur >>= 6;
cur = MathUtil::Clamp(cur, -0x8000, 0x7fff);
cur = std::clamp(cur, -0x8000, 0x7fff);
return (s16)cur;
}
+2 -2
View File
@@ -4,6 +4,7 @@
#include "Core/HW/VideoInterface.h"
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
@@ -12,7 +13,6 @@
#include "Common/CommonTypes.h"
#include "Common/Config/Config.h"
#include "Common/Logging/Log.h"
#include "Common/MathUtil.h"
#include "Core/Config/MainSettings.h"
#include "Core/Config/SYSCONFSettings.h"
@@ -328,7 +328,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
u16 value = static_cast<u16>(1 + m_HTiming0.HLW *
(CoreTiming::GetTicks() - s_ticks_last_line_start) /
(GetTicksPerHalfLine()));
return MathUtil::Clamp(value, static_cast<u16>(1), static_cast<u16>(m_HTiming0.HLW * 2));
return std::clamp<u16>(value, 1, m_HTiming0.HLW * 2);
}),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
WARN_LOG(VIDEOINTERFACE,

Some files were not shown because too many files have changed in this diff Show More