From 1969c929e1b9a6815f778f902890e84d614d8845 Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Sat, 16 Jul 2016 07:55:09 -0400 Subject: [PATCH] Fixups, I guess. Can't port to newer citra: physically impossible --- Makefile | 4 +-- source/citraimport/common/thread.h | 48 ++++++++++++++---------------- source/hardware/HID.cpp | 4 +-- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 2f676ed..3032ae2 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,8 @@ UTIL_FILES := source/util/*.cpp #COMMON_FILES := source/Bootloader.cpp source/arm/*.cpp $(ARM_FILES) $(KERNEL_FILES) $(HARDWARE_FILES) $(PROCESS9_FILES) $(UTIL_FILES) SOURCE_FILES := source/citraimport/glad/src/glad.o external/imgui/imgui.o external/imgui/examples/opengl3_example/imgui_impl_glfw_gl3.o $(shell for file in `find source -name *.cpp`; do echo $$file ; done) -CFLAGS := -I$(PWD)/include -Isource/citraimport -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors -CXXFLAGS := -I$(PWD)/include -Isource/citraimport -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c++11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors +CFLAGS := -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c11 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors +CXXFLAGS := -I$(PWD)/include -I$(PWD)/source/citraimport -I$(PWD)/source/citraimport/GPU -I$(PWD)/external/gl3w/include -I$(PWD)/external/imgui -g --std=c++14 $(ARM_FLAGS) -mtune=native -msse4.1 -Wfatal-errors -fpermissive LDFLAGS := -L/opt/local/lib -Lexternal/gl3w -lpthread -lX11 -lXxf86vm -lXrender -lXcursor -lXrandr -lXinerama -lglfw3 -lgl3w -lGL -ldl COMMON_FILES := $(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$(SOURCE_FILES))) diff --git a/source/citraimport/common/thread.h b/source/citraimport/common/thread.h index f7992e1..bbfa8be 100644 --- a/source/citraimport/common/thread.h +++ b/source/citraimport/common/thread.h @@ -9,7 +9,7 @@ #include #include -#include "citraimport/common/common_types.h" +#include "common/common_types.h" // Support for C++11's thread_local keyword was surprisingly spotty in compilers until very // recently. Fortunately, thread local variables have been well supported for compilers for a while, @@ -30,8 +30,7 @@ # endif #endif -namespace Common -{ +namespace Common { int CurrentThreadId(); @@ -43,55 +42,55 @@ public: Event() : is_set(false) {} void Set() { - std::lock_guard lk(m_mutex); + std::lock_guard lk(mutex); if (!is_set) { is_set = true; - m_condvar.notify_one(); + condvar.notify_one(); } } void Wait() { - std::unique_lock lk(m_mutex); - m_condvar.wait(lk, [&]{ return is_set; }); + std::unique_lock lk(mutex); + condvar.wait(lk, [&]{ return is_set; }); is_set = false; } void Reset() { - std::unique_lock lk(m_mutex); + std::unique_lock lk(mutex); // no other action required, since wait loops on the predicate and any lingering signal will get cleared on the first iteration is_set = false; } private: bool is_set; - std::condition_variable m_condvar; - std::mutex m_mutex; + std::condition_variable condvar; + std::mutex mutex; }; class Barrier { public: - Barrier(size_t count) : m_count(count), m_waiting(0) {} + explicit Barrier(size_t count_) : count(count_), waiting(0), generation(0) {} /// Blocks until all "count" threads have called Sync() void Sync() { - std::unique_lock lk(m_mutex); + std::unique_lock lk(mutex); + const size_t current_generation = generation; - // TODO: broken when next round of Sync()s - // is entered before all waiting threads return from the notify_all - - if (++m_waiting == m_count) { - m_waiting = 0; - m_condvar.notify_all(); + if (++waiting == count) { + generation++; + waiting = 0; + condvar.notify_all(); } else { - m_condvar.wait(lk, [&]{ return m_waiting == 0; }); + condvar.wait(lk, [this, current_generation]{ return current_generation != generation; }); } } private: - std::condition_variable m_condvar; - std::mutex m_mutex; - const size_t m_count; - size_t m_waiting; + std::condition_variable condvar; + std::mutex mutex; + const size_t count; + size_t waiting; + size_t generation; // Incremented once each time the barrier is used }; void SleepCurrentThread(int ms); @@ -100,8 +99,7 @@ void SwitchCurrentThread(); // On Linux, this is equal to sleep 1ms // Use this function during a spin-wait to make the current thread // relax while another thread is working. This may be more efficient // than using events because event functions use kernel calls. -inline void YieldCPU() -{ +inline void YieldCPU() { std::this_thread::yield(); } diff --git a/source/hardware/HID.cpp b/source/hardware/HID.cpp index 5506d37..fc93656 100644 --- a/source/hardware/HID.cpp +++ b/source/hardware/HID.cpp @@ -1,8 +1,8 @@ #include "Kernel.h" #include "Hardware.h" - extern "C" int citraPressedkey; + HID::HID(KKernel * kernel) : m_kernel(kernel), m_IO(0), m_DIR(0) { } @@ -44,4 +44,4 @@ void HID::Write16(u32 addr, u16 data) void HID::Write32(u32 addr, u32 data) { LOG("HID unknown write %08x to %08x", data, addr); -} \ No newline at end of file +} -- 2.39.5