Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixups #6267

Merged
merged 3 commits into from Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Utilities/AtomicPtr.h
@@ -1,6 +1,6 @@
#pragma once

#include "Atomic.h"
#include "util/atomic.hpp"
#include <memory>
#include <cstddef>

Expand Down
2 changes: 1 addition & 1 deletion Utilities/Log.h
@@ -1,7 +1,7 @@
#pragma once

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"
#include "StrFmt.h"
#include <climits>

Expand Down
2 changes: 1 addition & 1 deletion Utilities/Thread.h
@@ -1,7 +1,7 @@
#pragma once

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"

#include <string>
#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion Utilities/bit_set.h
Expand Up @@ -22,7 +22,7 @@ Intersection (&) and symmetric difference (^) is also available.
*/

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"

template <typename T>
class atomic_bs_t;
Expand Down
24 changes: 12 additions & 12 deletions Utilities/cfmt.h
Expand Up @@ -412,10 +412,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
}

const u64 mask =
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
u64{std::numeric_limits<get_int_t<8>>::max()};
ctx.type == 1 ? 0xff :
ctx.type == 2 ? 0xffff :
ctx.type == 4 ? 0xffff'ffffu :
0xffff'ffff'ffff'ffffu;

// Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask;
Expand Down Expand Up @@ -469,10 +469,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
}

const u64 mask =
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
u64{std::numeric_limits<get_int_t<8>>::max()};
ctx.type == 1 ? 0xff :
ctx.type == 2 ? 0xffff :
ctx.type == 4 ? 0xffff'ffffu :
0xffff'ffff'ffff'ffffu;

// Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask;
Expand Down Expand Up @@ -533,10 +533,10 @@ std::size_t cfmt_append(Dst& out, const Char* fmt, Src&& src)
}

const u64 mask =
ctx.type == 1 ? u64{std::numeric_limits<get_int_t<1>>::max()} :
ctx.type == 2 ? u64{std::numeric_limits<get_int_t<2>>::max()} :
ctx.type == 4 ? u64{std::numeric_limits<get_int_t<4>>::max()} :
u64{std::numeric_limits<get_int_t<8>>::max()};
ctx.type == 1 ? 0xff :
ctx.type == 2 ? 0xffff :
ctx.type == 4 ? 0xffff'ffffu :
0xffff'ffff'ffff'ffffu;

// Trunc sign-extended signed types
const u64 val = src.template get<u64>(ctx.args) & mask;
Expand Down
2 changes: 1 addition & 1 deletion Utilities/cond.h
@@ -1,7 +1,7 @@
#pragma once

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"
#include <shared_mutex>
#include "asm.h"

Expand Down
2 changes: 1 addition & 1 deletion Utilities/event.h
Expand Up @@ -4,7 +4,7 @@
#include <deque>
#include <list>

#include "Atomic.h"
#include "util/atomic.hpp"

template <typename T, T Mod = T::__state_enum_max, typename Under = std::underlying_type_t<T>>
T operator ++(T& value, int)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/lockless.h
@@ -1,7 +1,7 @@
#pragma once

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"

//! Simple sizeless array base for concurrent access. Cannot shrink, only growths automatically.
//! There is no way to know the current size. The smaller index is, the faster it's accessed.
Expand Down
27 changes: 16 additions & 11 deletions Utilities/mutex.cpp
@@ -1,7 +1,4 @@
#include "mutex.h"
#include "sync.h"

#include <climits>

void shared_mutex::imp_lock_shared(u32 val)
{
Expand Down Expand Up @@ -122,24 +119,32 @@ void shared_mutex::imp_unlock_vip(u32 old)

void shared_mutex::imp_wait()
{
while (!balanced_wait_until(m_value, -1, [&](u32& value, auto...)
while (true)
{
if (value >= c_sig)
const auto [old, ok] = m_value.fetch_op([](u32& value)
{
value -= c_sig;
return true;
if (value >= c_sig)
{
value -= c_sig;
return true;
}

return false;
});

if (ok)
{
break;
}

return false;
}))
{
m_value.wait(old);
}
}

void shared_mutex::imp_signal()
{
m_value += c_sig;
balanced_awaken(m_value, 1);
m_value.notify_one();
}

void shared_mutex::imp_lock(u32 val)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/mutex.h
Expand Up @@ -2,7 +2,7 @@

#include <mutex>
#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"

// Shared mutex with small size (u32).
class shared_mutex final
Expand Down
20 changes: 3 additions & 17 deletions Utilities/sema.cpp
@@ -1,5 +1,4 @@
#include "sema.h"
#include "sync.h"

void semaphore_base::imp_wait()
{
Expand All @@ -15,14 +14,6 @@ void semaphore_base::imp_wait()
}
}

#ifdef _WIN32
const s32 value = m_value.fetch_sub(1);

if (value <= 0)
{
NtWaitForKeyedEvent(nullptr, &m_value, false, nullptr);
}
#else
while (true)
{
// Try hard way
Expand Down Expand Up @@ -51,24 +42,19 @@ void semaphore_base::imp_wait()
if (value >= 0)
{
// Signal other waiter to wake up or to restore sign bit
futex(&m_value, FUTEX_WAKE_PRIVATE, 1);
m_value.notify_one();
return;
}

futex(&m_value, FUTEX_WAIT_PRIVATE, value);
m_value.wait(value);
}
#endif
}

void semaphore_base::imp_post(s32 _old)
{
verify("semaphore_base: overflow" HERE), _old < 0;

#ifdef _WIN32
NtReleaseKeyedEvent(nullptr, &m_value, false, nullptr);
#else
futex(&m_value, FUTEX_WAKE_PRIVATE, 1);
#endif
m_value.notify_one();
}

bool semaphore_base::try_post(s32 _max)
Expand Down
2 changes: 1 addition & 1 deletion Utilities/sema.h
Expand Up @@ -2,7 +2,7 @@

#include <mutex>
#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"

// Lightweight semaphore helper class
class semaphore_base
Expand Down
2 changes: 1 addition & 1 deletion Utilities/sync.h
Expand Up @@ -3,7 +3,7 @@
/* For internal use. Don't include. */

#include "types.h"
#include "Atomic.h"
#include "util/atomic.hpp"
#include "dynamic_library.h"

#ifdef _WIN32
Expand Down
2 changes: 1 addition & 1 deletion Utilities/typemap.h
Expand Up @@ -3,7 +3,7 @@
#include "types.h"
#include "mutex.h"
#include "cond.h"
#include "Atomic.h"
#include "util/atomic.hpp"
#include "VirtualMemory.h"
#include <memory>

Expand Down
31 changes: 19 additions & 12 deletions Utilities/types.h
Expand Up @@ -131,38 +131,45 @@ using steady_clock = std::conditional<
std::chrono::high_resolution_clock::is_steady,
std::chrono::high_resolution_clock, std::chrono::steady_clock>::type;

// Get unsigned integral type from type size
template<size_t N>
// Get integral type from type size
template <std::size_t N>
struct get_int_impl
{
};

template<>
template <>
struct get_int_impl<sizeof(u8)>
{
using type = u8;
using utype = u8;
using stype = s8;
};

template<>
template <>
struct get_int_impl<sizeof(u16)>
{
using type = u16;
using utype = u16;
using stype = s16;
};

template<>
template <>
struct get_int_impl<sizeof(u32)>
{
using type = u32;
using utype = u32;
using stype = s32;
};

template<>
template <>
struct get_int_impl<sizeof(u64)>
{
using type = u64;
using utype = u64;
using stype = s64;
};

template <size_t N>
using get_int_t = typename get_int_impl<N>::type;
template <std::size_t N>
using get_uint_t = typename get_int_impl<N>::utype;

template <std::size_t N>
using get_sint_t = typename get_int_impl<N>::stype;

namespace gsl
{
Expand Down
17 changes: 16 additions & 1 deletion rpcs3/CMakeLists.txt
Expand Up @@ -35,7 +35,22 @@ include(${CMAKE_SOURCE_DIR}/3rdparty/qt5.cmake)
add_subdirectory(Emu)
add_subdirectory(rpcs3qt)

file(GLOB RPCS3_SRC "*.cpp")
set(RPCS3_SRC
basic_keyboard_handler.cpp
basic_mouse_handler.cpp
ds3_pad_handler.cpp
ds4_pad_handler.cpp
evdev_joystick_handler.cpp
keyboard_pad_handler.cpp
main.cpp
mm_joystick_handler.cpp
pad_thread.cpp
rpcs3_app.cpp
rpcs3_version.cpp
stb_image.cpp
stdafx.cpp
xinput_pad_handler.cpp
)

if(WIN32)
add_executable(rpcs3 WIN32 ${RPCS3_SRC})
Expand Down