]> Chaos Git - console/XDS.git/commitdiff
Fixups, I guess. Can't port to newer citra: physically impossible
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 16 Jul 2016 11:55:09 +0000 (07:55 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 16 Jul 2016 11:55:09 +0000 (07:55 -0400)
Makefile
source/citraimport/common/thread.h
source/hardware/HID.cpp

index 2f676ed34c8e773da8e1f199d4eb446dc29e1442..3032ae2c0356b9e12f2487528df6a6aa2d47a5f8 100644 (file)
--- 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)))
index f7992e1996b5cc47eee751201ede4a5e2595b8d1..bbfa8befae9abbcd249cc99efd4f35d8583ccf40 100644 (file)
@@ -9,7 +9,7 @@
 #include <condition_variable>
 #include <mutex>
 
-#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<std::mutex> lk(m_mutex);
+        std::lock_guard<std::mutex> lk(mutex);
         if (!is_set) {
             is_set = true;
-            m_condvar.notify_one();
+            condvar.notify_one();
         }
     }
 
     void Wait() {
-        std::unique_lock<std::mutex> lk(m_mutex);
-        m_condvar.wait(lk, [&]{ return is_set; });
+        std::unique_lock<std::mutex> lk(mutex);
+        condvar.wait(lk, [&]{ return is_set; });
         is_set = false;
     }
 
     void Reset() {
-        std::unique_lock<std::mutex> lk(m_mutex);
+        std::unique_lock<std::mutex> 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<std::mutex> lk(m_mutex);
+        std::unique_lock<std::mutex> 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();
 }
 
index 5506d37beca4f430e24bb7a4573325dcc575cd13..fc93656ae706bbb2bfda5b6b390dcbab8db0111b 100644 (file)
@@ -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
+}