Skip to content

Commit

Permalink
Fix Visual Studio 17.5.0 compilation
Browse files Browse the repository at this point in the history
For some reason there's an internal compiler error related to atomic wait.
I could work around this issue when I commented "mask = default_mask<X>;".
So after playing around a bit I had the suspicion that the VS parser can't handle some of the templatization.
Giving the decltype its own alias seems to fix this issue (and makes the code a bit more readable anyway in my opinion).
  • Loading branch information
Megamouse authored and Nekotekina committed Feb 25, 2023
1 parent 7cb3d30 commit 3ff4646
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
13 changes: 8 additions & 5 deletions rpcs3/util/atomic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,13 @@ namespace atomic_wait
}
} any_value;

template <typename X, typename T = decltype(std::declval<X>().observe())>
template <typename X>
using payload_type = decltype(std::declval<X>().observe());

template <typename X, typename T = payload_type<X>>
constexpr u128 default_mask = sizeof(T) <= 8 ? u128{u64{umax} >> ((64 - sizeof(T) * 8) & 63)} : u128(-1);

template <typename X, typename T = decltype(std::declval<X>().observe())>
template <typename X, typename T = payload_type<X>>
constexpr u128 get_value(X&, T value = T{}, ...)
{
static_assert((sizeof(T) & (sizeof(T) - 1)) == 0);
Expand All @@ -199,21 +202,21 @@ namespace atomic_wait
u128 old;
u128 mask;

template <typename X, typename T = decltype(std::declval<X>().observe())>
template <typename X, typename T = payload_type<X>>
constexpr void set_value(X& a, T value = T{})
{
old = get_value(a, value);
}

template <typename X, typename T = decltype(std::declval<X>().observe())>
template <typename X, typename T = payload_type<X>>
constexpr void set_mask(T value)
{
static_assert((sizeof(T) & (sizeof(T) - 1)) == 0);
static_assert(sizeof(T) <= 16);
mask = std::bit_cast<get_uint_t<sizeof(T)>, T>(value);
}

template <typename X, typename T = decltype(std::declval<X>().observe())>
template <typename X, typename T = payload_type<X>>
constexpr void set_mask()
{
mask = default_mask<X>;
Expand Down
3 changes: 0 additions & 3 deletions rpcs3/util/media_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include "stdafx.h"
#include "media_utils.h"
#include "logs.hpp"
#include "Utilities/StrUtil.h"
#include "Emu/Cell/Modules/cellSearch.h"
#include "Emu/System.h"

#include <random>
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/util/media_utils.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#pragma once

#include <unordered_map>
#include <atomic>
#include <deque>
#include <mutex>
#include <thread>
#include "Utilities/StrUtil.h"
#include "Utilities/Thread.h"
#include "util/video_provider.h"
#include "Emu/Cell/Modules/cellMusic.h"

#include <unordered_map>
#include <deque>
#include <mutex>
#include <thread>

namespace utils
{
std::string av_error_to_string(int error);
Expand Down

0 comments on commit 3ff4646

Please sign in to comment.