summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.travis-build.sh2
-rw-r--r--.travis-deps.sh2
-rw-r--r--CMakeLists.txt39
-rw-r--r--externals/qhexedit/CMakeLists.txt15
-rw-r--r--externals/qhexedit/qhexedit_p.cpp4
-rw-r--r--externals/qhexedit/qhexedit_p.h3
-rw-r--r--src/citra_qt/CMakeLists.txt60
-rw-r--r--src/citra_qt/bootmanager.cpp8
-rw-r--r--src/citra_qt/bootmanager.hxx4
-rw-r--r--src/citra_qt/main.cpp5
-rw-r--r--src/citra_qt/main.hxx2
-rw-r--r--src/common/atomic.h5
-rw-r--r--src/common/atomic_gcc.h5
-rw-r--r--src/common/atomic_win32.h5
-rw-r--r--src/common/break_points.h5
-rw-r--r--src/common/chunk_file.h5
-rw-r--r--src/common/common.h11
-rw-r--r--src/common/common_funcs.h5
-rw-r--r--src/common/common_paths.h5
-rw-r--r--src/common/common_types.h2
-rw-r--r--src/common/console_listener.cpp10
-rw-r--r--src/common/console_listener.h5
-rw-r--r--src/common/cpu_detect.h5
-rw-r--r--src/common/debug_interface.h7
-rw-r--r--src/common/extended_trace.cpp3
-rw-r--r--src/common/extended_trace.h5
-rw-r--r--src/common/fifo_queue.h6
-rw-r--r--src/common/file_search.h7
-rw-r--r--src/common/file_util.cpp4
-rw-r--r--src/common/file_util.h6
-rw-r--r--src/common/fixed_size_queue.h7
-rw-r--r--src/common/hash.h5
-rw-r--r--src/common/linear_disk_cache.h6
-rw-r--r--src/common/log.h5
-rw-r--r--src/common/log_manager.h7
-rw-r--r--src/common/math_util.h13
-rw-r--r--src/common/mem_arena.cpp47
-rw-r--r--src/common/mem_arena.h5
-rw-r--r--src/common/memory_util.cpp17
-rw-r--r--src/common/memory_util.h6
-rw-r--r--src/common/msg_handler.cpp2
-rw-r--r--src/common/msg_handler.h5
-rw-r--r--src/common/platform.h5
-rw-r--r--src/common/std_condition_variable.h4
-rw-r--r--src/common/std_mutex.h5
-rw-r--r--src/common/std_thread.h5
-rw-r--r--src/common/string_util.cpp6
-rw-r--r--src/common/string_util.h12
-rw-r--r--src/common/symbols.cpp2
-rw-r--r--src/common/symbols.h4
-rw-r--r--src/common/thread.h9
-rw-r--r--src/common/thunk.h5
-rw-r--r--src/common/timer.h5
-rw-r--r--src/common/utf8.cpp8
-rw-r--r--src/core/arm/interpreter/vfp/vfpdouble.cpp2
-rw-r--r--src/core/arm/interpreter/vfp/vfpsingle.cpp2
-rw-r--r--src/core/hle/function_wrappers.h60
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp4
-rw-r--r--src/core/hle/kernel/archive.cpp6
-rw-r--r--src/core/hle/kernel/event.cpp4
-rw-r--r--src/core/hle/kernel/kernel.cpp7
-rw-r--r--src/core/hle/kernel/kernel.h13
-rw-r--r--src/core/hle/kernel/mutex.cpp4
-rw-r--r--src/core/hle/kernel/shared_memory.cpp2
-rw-r--r--src/core/hle/kernel/thread.cpp17
-rw-r--r--src/core/hle/service/apt.h2
-rw-r--r--src/core/hle/service/fs.h2
-rw-r--r--src/core/hle/service/gsp.h2
-rw-r--r--src/core/hle/service/hid.h2
-rw-r--r--src/core/hle/service/ndm.h2
-rw-r--r--src/core/hle/service/service.h10
-rw-r--r--src/core/hle/service/srv.h2
-rw-r--r--src/core/hle/svc.cpp22
-rw-r--r--src/core/mem_map_funcs.cpp12
74 files changed, 282 insertions, 340 deletions
diff --git a/.travis-build.sh b/.travis-build.sh
index 35a908bfb..672d282cc 100644
--- a/.travis-build.sh
+++ b/.travis-build.sh
@@ -5,7 +5,7 @@ set -e
#if OS is linux or is not set
if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
mkdir build && cd build
- cmake ..
+ cmake -DUSE_QT5=OFF ..
make -j4
elif [ "$TRAVIS_OS_NAME" = osx ]; then
mkdir build && cd build
diff --git a/.travis-deps.sh b/.travis-deps.sh
index 326ba2d09..04450a4c8 100644
--- a/.travis-deps.sh
+++ b/.travis-deps.sh
@@ -14,5 +14,5 @@ if [ "$TRAVIS_OS_NAME" = linux -o -z "$TRAVIS_OS_NAME" ]; then
cd -
elif [ "$TRAVIS_OS_NAME" = osx ]; then
brew tap homebrew/versions
- brew install glew qt glfw3 pkgconfig
+ brew install glew qt5 glfw3 pkgconfig
fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c7d98347..56f5d02b0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 2.6)
+cmake_minimum_required(VERSION 2.8.7)
project(citra)
@@ -33,17 +33,29 @@ include_directories(${GLEW_INCLUDE_PATH})
# workaround for GLFW linking on OSX
link_directories(${GLFW_LIBRARY_DIRS})
-option(DISABLE_QT4 "Disable Qt4 GUI" OFF)
-if(NOT DISABLE_QT4)
- include(FindQt4)
- find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
-
- if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND)
- include(${QT_USE_FILE})
- include_directories(${QT_INCLUDES})
- include_directories(externals/qhexedit)
- else()
- message("Qt4 libraries not found! Disabling Qt4 GUI")
+option(DISABLE_QT "Disable Qt GUI" OFF)
+option(USE_QT5 "Use Qt5 when available" ON)
+if (NOT DISABLE_QT)
+ if(USE_QT5)
+ find_package(Qt5Gui)
+ find_package(Qt5Widgets)
+ find_package(Qt5OpenGL)
+ if(NOT Qt5Gui_FOUND OR NOT Qt5Widgets_FOUND OR NOT Qt5OpenGL_FOUND)
+ message("Qt5 libraries not found! Using Qt4 instead.")
+ set(USE_QT5 OFF)
+ endif()
+ endif()
+ if(NOT USE_QT5)
+ include(FindQt4)
+ find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL)
+
+ if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND)
+ include(${QT_USE_FILE})
+ include_directories(${QT_INCLUDES})
+ else()
+ message("Qt4 libraries not found! Disabling Qt GUI")
+ set(DISABLE_QT ON)
+ endif()
endif()
endif()
@@ -57,7 +69,8 @@ git_branch_name(GIT_BRANCH)
include_directories(src)
# process subdirectories
-if(QT4_FOUND AND QT_QTCORE_FOUND AND QT_QTGUI_FOUND AND QT_QTOPENGL_FOUND AND NOT DISABLE_QT4)
+if(NOT DISABLE_QT)
+ include_directories(externals/qhexedit)
add_subdirectory(externals/qhexedit)
endif()
add_subdirectory(src)
diff --git a/externals/qhexedit/CMakeLists.txt b/externals/qhexedit/CMakeLists.txt
index cfe168ef3..b1f631f95 100644
--- a/externals/qhexedit/CMakeLists.txt
+++ b/externals/qhexedit/CMakeLists.txt
@@ -1,13 +1,18 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
set(SRCS
commands.cpp
qhexedit.cpp
qhexedit_p.cpp
xbytearray.cpp)
-qt4_wrap_cpp(MOC_SRCS
- qhexedit.h
- qhexedit_p.h)
+set(HEADERS
+ qhexedit.h
+ qhexedit_p.h)
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
+add_library(qhexedit STATIC ${SRCS} ${HEADERS})
+if(USE_QT5)
+ target_link_libraries(qhexedit Qt5::Core Qt5::Widgets)
+endif()
-add_library(qhexedit STATIC ${SRCS} ${MOC_SRCS})
diff --git a/externals/qhexedit/qhexedit_p.cpp b/externals/qhexedit/qhexedit_p.cpp
index c16f4ce4d..2a6885de8 100644
--- a/externals/qhexedit/qhexedit_p.cpp
+++ b/externals/qhexedit/qhexedit_p.cpp
@@ -1,5 +1,3 @@
-#include <QtGui>
-
#include "qhexedit_p.h"
#include "commands.h"
@@ -437,7 +435,7 @@ void QHexEditPrivate::keyPressEvent(QKeyEvent *event)
if (!_readOnly)
{
/* Hex input */
- int key = int(event->text()[0].toAscii());
+ int key = int(event->text()[0].toLatin1());
if ((key>='0' && key<='9') || (key>='a' && key <= 'f'))
{
if (getSelectionBegin() != getSelectionEnd())
diff --git a/externals/qhexedit/qhexedit_p.h b/externals/qhexedit/qhexedit_p.h
index 138139b90..1c2c11cc2 100644
--- a/externals/qhexedit/qhexedit_p.h
+++ b/externals/qhexedit/qhexedit_p.h
@@ -5,6 +5,9 @@
#include <QtGui>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QtWidgets>
+#endif
#include "xbytearray.h"
class QHexEditPrivate : public QWidget
diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt
index 7f880df8b..ff1fbc460 100644
--- a/src/citra_qt/CMakeLists.txt
+++ b/src/citra_qt/CMakeLists.txt
@@ -1,3 +1,6 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
set(SRCS
bootmanager.cpp
debugger/callstack.cpp
@@ -10,7 +13,8 @@ set(SRCS
main.cpp
config/controller_config.cpp
config/controller_config_util.cpp)
-set (HEADERS
+
+set(HEADERS
bootmanager.hxx
debugger/callstack.hxx
debugger/disassembler.hxx
@@ -18,46 +22,34 @@ set (HEADERS
debugger/registers.hxx
hotkeys.hxx
main.hxx
- ui_callstack.h
- ui_controller_config.h
- ui_disassembler.h
- ui_hotkeys.h
- ui_main.h
- ui_registers.h
version.h
config/controller_config.hxx
config/controller_config_util.hxx)
-qt4_wrap_ui(UI_HDRS
- debugger/callstack.ui
- debugger/disassembler.ui
- debugger/registers.ui
- hotkeys.ui
- main.ui
- config/controller_config.ui)
+set(UIS
+ debugger/callstack.ui
+ debugger/disassembler.ui
+ debugger/registers.ui
+ hotkeys.ui
+ main.ui
+ config/controller_config.ui)
-qt4_wrap_cpp(MOC_SRCS
- bootmanager.hxx
- debugger/callstack.hxx
- debugger/disassembler.hxx
- debugger/graphics.hxx
- debugger/graphics_cmdlists.hxx
- debugger/registers.hxx
- debugger/ramview.hxx
- hotkeys.hxx
- main.hxx
- config/controller_config.hxx
- config/controller_config_util.hxx)
-
-# add uic results to include directories
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-include_directories(./)
+if(USE_QT5)
+ qt5_wrap_ui(UI_HDRS ${UIS})
+else()
+ qt4_wrap_ui(UI_HDRS ${UIS})
+endif()
-add_executable(citra-qt ${SRCS} ${HEADERS} ${MOC_SRCS} ${UI_HDRS})
-if (APPLE)
- target_link_libraries(citra-qt core common video_core qhexedit iconv ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${GLEW_LIBRARY} ${OPENGL_LIBRARIES})
+add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS})
+if(APPLE)
+ set(ICONV_LIBRARY iconv)
else()
- target_link_libraries(citra-qt core common video_core qhexedit ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${SDL2_LIBRARY} rt GLEW ${GLFW_LIBRARIES})
+ set(RT_LIBRARY rt)
+endif()
+
+target_link_libraries(citra-qt core common video_core qhexedit ${ICONV_LIBRARY} ${COREFOUNDATION_LIBRARY} ${QT_LIBRARIES} ${OPENGL_LIBRARIES} ${RT_LIBRARY} ${GLEW_LIBRARY})
+if(USE_QT5)
+ target_link_libraries(citra-qt Qt5::Gui Qt5::Widgets Qt5::OpenGL)
endif()
#install(TARGETS citra-qt RUNTIME DESTINATION ${bindir})
diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp
index a162e6dfe..b0aa1e561 100644
--- a/src/citra_qt/bootmanager.cpp
+++ b/src/citra_qt/bootmanager.cpp
@@ -17,13 +17,15 @@
#define APP_TITLE APP_NAME " " APP_VERSION
#define COPYRIGHT "Copyright (C) 2013-2014 Citra Team"
-EmuThread::EmuThread(GRenderWindow* render_window) : exec_cpu_step(false), cpu_running(false), render_window(render_window)
+EmuThread::EmuThread(GRenderWindow* render_window) :
+ exec_cpu_step(false), cpu_running(false),
+ render_window(render_window), filename("")
{
}
-void EmuThread::SetFilename(const char* filename)
+void EmuThread::SetFilename(std::string filename)
{
- strcpy(this->filename, filename);
+ this->filename = filename;
}
void EmuThread::run()
diff --git a/src/citra_qt/bootmanager.hxx b/src/citra_qt/bootmanager.hxx
index 1001e1ee4..b4005ccbb 100644
--- a/src/citra_qt/bootmanager.hxx
+++ b/src/citra_qt/bootmanager.hxx
@@ -17,7 +17,7 @@ public:
* @param filename
* @warning Only call when not running!
*/
- void SetFilename(const char* filename);
+ void SetFilename(std::string filename);
/**
* Start emulation (on new thread)
@@ -62,7 +62,7 @@ private:
EmuThread(GRenderWindow* render_window);
- char filename[MAX_PATH];
+ std::string filename;
bool exec_cpu_step;
bool cpu_running;
diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp
index 997e82cc9..e5190d48a 100644
--- a/src/citra_qt/main.cpp
+++ b/src/citra_qt/main.cpp
@@ -123,7 +123,7 @@ GMainWindow::~GMainWindow()
delete render_window;
}
-void GMainWindow::BootGame(const char* filename)
+void GMainWindow::BootGame(std::string filename)
{
NOTICE_LOG(MASTER_LOG, "citra starting...\n");
@@ -134,8 +134,7 @@ void GMainWindow::BootGame(const char* filename)
}
// Load a game or die...
- std::string boot_filename = filename;
- if (Loader::ResultStatus::Success != Loader::LoadFile(boot_filename)) {
+ if (Loader::ResultStatus::Success != Loader::LoadFile(filename)) {
ERROR_LOG(BOOT, "Failed to load ROM!");
}
diff --git a/src/citra_qt/main.hxx b/src/citra_qt/main.hxx
index 6bcb37a30..a0b41f5f4 100644
--- a/src/citra_qt/main.hxx
+++ b/src/citra_qt/main.hxx
@@ -30,7 +30,7 @@ public:
~GMainWindow();
private:
- void BootGame(const char* filename);
+ void BootGame(std::string filename);
void closeEvent(QCloseEvent* event);
diff --git a/src/common/atomic.h b/src/common/atomic.h
index ff2fb23d3..941f5ad5e 100644
--- a/src/common/atomic.h
+++ b/src/common/atomic.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _ATOMIC_H_
-#define _ATOMIC_H_
+#pragma once
#ifdef _WIN32
@@ -15,5 +14,3 @@
#include "common/atomic_gcc.h"
#endif
-
-#endif
diff --git a/src/common/atomic_gcc.h b/src/common/atomic_gcc.h
index 953c82c6c..117e342f6 100644
--- a/src/common/atomic_gcc.h
+++ b/src/common/atomic_gcc.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _ATOMIC_GCC_H_
-#define _ATOMIC_GCC_H_
+#pragma once
#include "common/common.h"
@@ -109,5 +108,3 @@ LONG SyncInterlockedExchange(LONG *Dest, LONG Val)
#endif
}
#endif
-
-#endif
diff --git a/src/common/atomic_win32.h b/src/common/atomic_win32.h
index f8ec80520..0808905f0 100644
--- a/src/common/atomic_win32.h
+++ b/src/common/atomic_win32.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _ATOMIC_WIN32_H_
-#define _ATOMIC_WIN32_H_
+#pragma once
#include "common/common.h"
#include <intrin.h>
@@ -68,5 +67,3 @@ inline void AtomicStoreRelease(volatile u32& dest, u32 value) {
}
}
-
-#endif
diff --git a/src/common/break_points.h b/src/common/break_points.h
index da14ca7f3..cf3884fbc 100644
--- a/src/common/break_points.h
+++ b/src/common/break_points.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _DEBUGGER_BREAKPOINTS_H
-#define _DEBUGGER_BREAKPOINTS_H
+#pragma once
#include <vector>
#include <string>
@@ -98,5 +97,3 @@ public:
void Clear() { m_MemChecks.clear(); };
};
-
-#endif
diff --git a/src/common/chunk_file.h b/src/common/chunk_file.h
index 8c9f839da..2b0f120e6 100644
--- a/src/common/chunk_file.h
+++ b/src/common/chunk_file.h
@@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#ifndef _POINTERWRAP_H_
-#define _POINTERWRAP_H_
+#pragma once
// Extremely simple serialization framework.
@@ -871,5 +870,3 @@ private:
char GitVersion[32];
};
}; */
-
-#endif // _POINTERWRAP_H_
diff --git a/src/common/common.h b/src/common/common.h
index 09027cae1..cb69eabe4 100644
--- a/src/common/common.h
+++ b/src/common/common.h
@@ -2,15 +2,14 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _COMMON_H_
-#define _COMMON_H_
+#pragma once
// DO NOT EVER INCLUDE <windows.h> directly _or indirectly_ from this file
// since it slows down the build a lot.
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstdio>
+#include <cstring>
// Force enable logging in the right modes. For some reason, something had changed
// so that debugfast no longer logged.
@@ -200,5 +199,3 @@ inline double bswapd(double f) {
}
#include "swap.h"
-
-#endif // _COMMON_H_
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index dca4dc47f..c18afe119 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _COMMONFUNCS_H_
-#define _COMMONFUNCS_H_
+#pragma once
#ifdef _WIN32
#define SLEEP(x) Sleep(x)
@@ -233,5 +232,3 @@ inline T FromBigEndian(T data)
}
} // Namespace Common
-
-#endif // _COMMONFUNCS_H_
diff --git a/src/common/common_paths.h b/src/common/common_paths.h
index 252e93fa9..a36de9227 100644
--- a/src/common/common_paths.h
+++ b/src/common/common_paths.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _COMMON_PATHS_H_
-#define _COMMON_PATHS_H_
+#pragma once
// Make sure we pick up USER_DIR if set in config.h
#include "common/common.h"
@@ -75,5 +74,3 @@
// Files in the directory returned by GetUserPath(D_SYSCONF_IDX)
#define SYSCONF "SYSCONF"
-
-#endif // _COMMON_PATHS_H_
diff --git a/src/common/common_types.h b/src/common/common_types.h
index 402410507..9d41e5971 100644
--- a/src/common/common_types.h
+++ b/src/common/common_types.h
@@ -24,7 +24,7 @@
#pragma once
-#include <math.h>
+#include <cmath>
#include <xmmintrin.h> // data_types__m128.cpp
#ifdef _WIN32
diff --git a/src/common/console_listener.cpp b/src/common/console_listener.cpp
index db48abbf6..27697ef1f 100644
--- a/src/common/console_listener.cpp
+++ b/src/common/console_listener.cpp
@@ -2,15 +2,15 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <algorithm> // min
-#include <string> // System: To be able to add strings with "+"
-#include <stdio.h>
-#include <math.h>
+#include <algorithm>
+#include <cmath>
+#include <cstdio>
+#include <string>
#ifdef _WIN32
#include <windows.h>
#include <array>
#else
-#include <stdarg.h>
+#include <cstdarg>
#endif
#include "common/common.h"
diff --git a/src/common/console_listener.h b/src/common/console_listener.h
index 224d17017..3c0e420c6 100644
--- a/src/common/console_listener.h
+++ b/src/common/console_listener.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _CONSOLELISTENER_H
-#define _CONSOLELISTENER_H
+#pragma once
#include "common/log_manager.h"
@@ -37,5 +36,3 @@ private:
#endif
bool bUseColor;
};
-
-#endif // _CONSOLELISTENER_H
diff --git a/src/common/cpu_detect.h b/src/common/cpu_detect.h
index e93cf333a..def6afdee 100644
--- a/src/common/cpu_detect.h
+++ b/src/common/cpu_detect.h
@@ -4,8 +4,7 @@
// Detect the cpu, so we'll know which optimizations to use
-#ifndef _CPUDETECT_H_
-#define _CPUDETECT_H_
+#pragma once
#include <string>
@@ -77,5 +76,3 @@ private:
};
extern CPUInfo cpu_info;
-
-#endif // _CPUDETECT_H_
diff --git a/src/common/debug_interface.h b/src/common/debug_interface.h
index 49cc54a80..32f55cb59 100644
--- a/src/common/debug_interface.h
+++ b/src/common/debug_interface.h
@@ -1,8 +1,7 @@
-#ifndef _DEBUGINTERFACE_H
-#define _DEBUGINTERFACE_H
+#pragma once
+#include <cstring>
#include <string>
-#include <string.h>
class DebugInterface
{
@@ -35,5 +34,3 @@ public:
virtual int getColor(unsigned int /*address*/){return 0xFFFFFFFF;}
virtual std::string getDescription(unsigned int /*address*/) = 0;
};
-
-#endif
diff --git a/src/common/extended_trace.cpp b/src/common/extended_trace.cpp
index 0a1c6a67a..66dae4935 100644
--- a/src/common/extended_trace.cpp
+++ b/src/common/extended_trace.cpp
@@ -13,9 +13,8 @@
// --------------------------------------------------------------------------------------
#if defined(WIN32)
-
+#include <cstdio>
#include <windows.h>
-#include <stdio.h>
#include "common/extended_trace.h"
#include "common/string_util.h"
using namespace std;
diff --git a/src/common/extended_trace.h b/src/common/extended_trace.h
index 1552e901b..ed3113a24 100644
--- a/src/common/extended_trace.h
+++ b/src/common/extended_trace.h
@@ -12,8 +12,7 @@
//
// ----------------------------------------------------------------------------------------
-#ifndef _EXTENDEDTRACE_H_INCLUDED_
-#define _EXTENDEDTRACE_H_INCLUDED_
+#pragma once
#if defined(WIN32)
@@ -49,5 +48,3 @@ extern char g_uefbuf[UEFBUFSIZE];
#define STACKTRACE2(file, eip, esp, ebp) ((void)0)
#endif // WIN32
-
-#endif // _EXTENDEDTRACE_H_INCLUDED_
diff --git a/src/common/fifo_queue.h b/src/common/fifo_queue.h
index 4e80f53b4..78a8f561d 100644
--- a/src/common/fifo_queue.h
+++ b/src/common/fifo_queue.h
@@ -1,6 +1,4 @@
-
-#ifndef _FIFO_QUEUE_H_
-#define _FIFO_QUEUE_H_
+#pragma once
// a simple lockless thread-safe,
// single reader, single writer queue
@@ -111,5 +109,3 @@ private:
};
}
-
-#endif
diff --git a/src/common/file_search.h b/src/common/file_search.h
index 2a9ff801f..f966a008d 100644
--- a/src/common/file_search.h
+++ b/src/common/file_search.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _FILESEARCH_H_
-#define _FILESEARCH_H_
+#pragma once
#include <string>
#include <vector>
@@ -23,6 +21,3 @@ private:
XStringVector m_FileNames;
};
-
-#endif // _FILESEARCH_H_
-
diff --git a/src/common/file_util.cpp b/src/common/file_util.cpp
index 47ad964db..b6ff2e40b 100644
--- a/src/common/file_util.cpp
+++ b/src/common/file_util.cpp
@@ -16,11 +16,11 @@
#include <io.h>
#include <direct.h> // getcwd
#else
+#include <cerrno>
+#include <cstdlib>
#include <sys/param.h>
#include <sys/types.h>
#include <dirent.h>
-#include <errno.h>
-#include <stdlib.h>
#endif
#if defined(__APPLE__)
diff --git a/src/common/file_util.h b/src/common/file_util.h
index 5edb43f6a..0871734d4 100644
--- a/src/common/file_util.h
+++ b/src/common/file_util.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _FILEUTIL_H_
-#define _FILEUTIL_H_
+#pragma once
#include <fstream>
#include <cstdio>
@@ -220,5 +218,3 @@ void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmod
fstream.open(filename.c_str(), openmode);
#endif
}
-
-#endif
diff --git a/src/common/fixed_size_queue.h b/src/common/fixed_size_queue.h
index 1f507f4ae..1e3a5dea6 100644
--- a/src/common/fixed_size_queue.h
+++ b/src/common/fixed_size_queue.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _FIXED_SIZE_QUEUE_H_
-#define _FIXED_SIZE_QUEUE_H_
+#pragma once
// STL-look-a-like interface, but name is mixed case to distinguish it clearly from the
// real STL classes.
@@ -70,6 +68,3 @@ public:
return count;
}
};
-
-#endif // _FIXED_SIZE_QUEUE_H_
-
diff --git a/src/common/hash.h b/src/common/hash.h
index c69908415..29f699d7f 100644
--- a/src/common/hash.h
+++ b/src/common/hash.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _HASH_H_
-#define _HASH_H_
+#pragma once
#include "common/common.h"
@@ -17,4 +15,3 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples);
u64 GetMurmurHash3(const u8 *src, int len, u32 samples);
u64 GetHash64(const u8 *src, int len, u32 samples);
void SetHash64Function(bool useHiresTextures);
-#endif // _HASH_H_
diff --git a/src/common/linear_disk_cache.h b/src/common/linear_disk_cache.h
index a24687615..96dce3155 100644
--- a/src/common/linear_disk_cache.h
+++ b/src/common/linear_disk_cache.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _LINEAR_DISKCACHE
-#define _LINEAR_DISKCACHE
+#pragma once
#include "common/common.h"
#include <fstream>
@@ -187,5 +185,3 @@ private:
std::fstream m_file;
u32 m_num_entries;
};
-
-#endif // _LINEAR_DISKCACHE
diff --git a/src/common/log.h b/src/common/log.h
index e923224ed..f1f6ffae6 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _LOG_H_
-#define _LOG_H_
+#pragma once
#define LOGGING
@@ -160,5 +159,3 @@ void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int
#else // GEKKO
#define _assert_msg_(_t_, _a_, _fmt_, ...)
#endif
-
-#endif // _LOG_H_
diff --git a/src/common/log_manager.h b/src/common/log_manager.h
index 6d3d7c7ff..81d808825 100644
--- a/src/common/log_manager.h
+++ b/src/common/log_manager.h
@@ -2,16 +2,15 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _LOGMANAGER_H_
-#define _LOGMANAGER_H_
+#pragma once
#include "common/log.h"
#include "common/string_util.h"
#include "common/thread.h"
#include "common/file_util.h"
+#include <cstring>
#include <set>
-#include <string.h>
#define MAX_MESSAGES 8000
#define MAX_MSGLEN 1024
@@ -165,5 +164,3 @@ public:
static void Init();
static void Shutdown();
};
-
-#endif // _LOGMANAGER_H_
diff --git a/src/common/math_util.h b/src/common/math_util.h
index 9167d2012..b32e7bb14 100644
--- a/src/common/math_util.h
+++ b/src/common/math_util.h
@@ -2,17 +2,22 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _MATH_UTIL_H_
-#define _MATH_UTIL_H_
+#pragma once
#include "common/common.h"
+#include <algorithm>
#include <vector>
namespace MathUtil
{
+template<typename T>
+inline T Clamp(const T val, const T& min, const T& max)
+{
+ return std::max(min, std::min(max, val));
+}
+
static const u64 DOUBLE_SIGN = 0x8000000000000000ULL,
DOUBLE_EXP = 0x7FF0000000000000ULL,
DOUBLE_FRAC = 0x000FFFFFFFFFFFFFULL,
@@ -196,5 +201,3 @@ public:
float data[16];
};
-
-#endif // _MATH_UTIL_H_
diff --git a/src/common/mem_arena.cpp b/src/common/mem_arena.cpp
index b918eb568..b76ac92d3 100644
--- a/src/common/mem_arena.cpp
+++ b/src/common/mem_arena.cpp
@@ -19,6 +19,7 @@
#include "common/memory_util.h"
#include "common/mem_arena.h"
+#include "common/string_util.h"
#ifndef _WIN32
#include <sys/stat.h>
@@ -98,15 +99,7 @@ int ashmem_unpin_region(int fd, size_t offset, size_t len)
#endif // Android
-
-#ifndef _WIN32
-// do not make this "static"
-#if defined(MAEMO) || defined(MEEGO_EDITION_HARMATTAN)
-std::string ram_temp_file = "/home/user/gc_mem.tmp";
-#else
-std::string ram_temp_file = "/tmp/gc_mem.tmp";
-#endif
-#elif !defined(_XBOX)
+#if defined(_WIN32) && !defined(_XBOX)
SYSTEM_INFO sysInfo;
#endif
@@ -145,20 +138,26 @@ void MemArena::GrabLowMemSpace(size_t size)
return;
}
#else
- mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
- fd = open(ram_temp_file.c_str(), O_RDWR | O_CREAT, mode);
- if (fd < 0)
- {
- ERROR_LOG(MEMMAP, "Failed to grab memory space as a file: %s of size: %08x errno: %d", ram_temp_file.c_str(), (int)size, (int)(errno));
- return;
- }
- // delete immediately, we keep the fd so it still lives
- unlink(ram_temp_file.c_str());
- if (ftruncate(fd, size) != 0)
+ // Try to find a non-existing filename for our shared memory.
+ // In most cases the first one will be available, but it's nicer to search
+ // a bit more.
+ for (int i = 0; i < 10000; i++)
{
- ERROR_LOG(MEMMAP, "Failed to ftruncate %d to size %08x", (int)fd, (int)size);
+ std::string file_name = StringFromFormat("/citramem.%d", i);
+ fd = shm_open(file_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
+ if (fd != -1)
+ {
+ shm_unlink(file_name.c_str());
+ break;
+ }
+ else if (errno != EEXIST)
+ {
+ ERROR_LOG(MEMMAP, "shm_open failed: %s", strerror(errno));
+ return;
+ }
}
- return;
+ if (ftruncate(fd, size) < 0)
+ ERROR_LOG(MEMMAP, "Failed to allocate low memory space");
#endif
}
@@ -198,12 +197,12 @@ void *MemArena::CreateView(s64 offset, size_t size, void *base)
#elif defined(__FreeBSD__)
MAP_NOSYNC |
#endif
- ((base == 0) ? 0 : MAP_FIXED), fd, offset);
+ ((base == nullptr) ? 0 : MAP_FIXED), fd, offset);
if (retval == MAP_FAILED)
{
- NOTICE_LOG(MEMMAP, "mmap on %s (fd: %d) failed", ram_temp_file.c_str(), (int)fd);
- return 0;
+ NOTICE_LOG(MEMMAP, "mmap failed");
+ return nullptr;
}
return retval;
#endif
diff --git a/src/common/mem_arena.h b/src/common/mem_arena.h
index 667efbea9..b5f0aa890 100644
--- a/src/common/mem_arena.h
+++ b/src/common/mem_arena.h
@@ -15,8 +15,7 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-#ifndef _MEMARENA_H_
-#define _MEMARENA_H_
+#pragma once
#ifdef _WIN32
#include <windows.h>
@@ -77,5 +76,3 @@ struct MemoryView
// a passed-in list of MemoryView structures.
u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena *arena);
void MemoryMap_Shutdown(const MemoryView *views, int num_views, u32 flags, MemArena *arena);
-
-#endif // _MEMARENA_H_
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index 71ef159c3..e01e63175 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -11,8 +11,8 @@
#include <windows.h>
#include <psapi.h>
#else
-#include <errno.h>
-#include <stdio.h>
+#include <cerrno>
+#include <cstdio>
#endif
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
@@ -51,14 +51,14 @@ void* AllocateExecutableMemory(size_t size, bool low)
// printf("Mapped executable memory at %p (size %ld)\n", ptr,
// (unsigned long)size);
-#if defined(__FreeBSD__)
- if (ptr == MAP_FAILED)
+#ifdef _WIN32
+ if (ptr == nullptr)
{
- ptr = NULL;
#else
- if (ptr == NULL)
+ if (ptr == MAP_FAILED)
{
-#endif
+ ptr = nullptr;
+#endif
PanicAlert("Failed to allocate executable memory");
}
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
@@ -88,6 +88,9 @@ void* AllocateMemoryPages(size_t size)
#else
void* ptr = mmap(0, size, PROT_READ | PROT_WRITE,
MAP_ANON | MAP_PRIVATE, -1, 0);
+
+ if (ptr == MAP_FAILED)
+ ptr = nullptr;
#endif
// printf("Mapped memory at %p (size %ld)\n", ptr,
diff --git a/src/common/memory_util.h b/src/common/memory_util.h
index 49b2589da..922bd44b2 100644
--- a/src/common/memory_util.h
+++ b/src/common/memory_util.h
@@ -2,9 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-
-#ifndef _MEMORYUTIL_H
-#define _MEMORYUTIL_H
+#pragma once
#ifndef _WIN32
#include <sys/mman.h>
@@ -21,5 +19,3 @@ void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute = false);
std::string MemUsage();
inline int GetPageSize() { return 4096; }
-
-#endif
diff --git a/src/common/msg_handler.cpp b/src/common/msg_handler.cpp
index c1386cdaa..3e02ec4d7 100644
--- a/src/common/msg_handler.cpp
+++ b/src/common/msg_handler.cpp
@@ -2,7 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <stdio.h> // System
+#include <cstdio>
#include "common/common.h" // Local
#include "common/string_util.h"
diff --git a/src/common/msg_handler.h b/src/common/msg_handler.h
index bde2808fa..7c5319ec3 100644
--- a/src/common/msg_handler.h
+++ b/src/common/msg_handler.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _MSGHANDLER_H_
-#define _MSGHANDLER_H_
+#pragma once
#include <string>
@@ -69,5 +68,3 @@ void SetEnableAlert(bool enable);
#define AskYesNoT(format, ...) ;
#define CriticalAlertT(format, ...) ;
#endif
-
-#endif // _MSGHANDLER_H_
diff --git a/src/common/platform.h b/src/common/platform.h
index b02b52cd2..d9f095433 100644
--- a/src/common/platform.h
+++ b/src/common/platform.h
@@ -22,8 +22,7 @@
* http://code.google.com/p/gekko-gc-emu/
*/
-#ifndef COMMON_PLATFORM_H_
-#define COMMON_PLATFORM_H_
+#pragma once
#include "common/common_types.h"
@@ -110,5 +109,3 @@ typedef void EXCEPTION_POINTERS;
#define GCC_VERSION_AVAILABLE(major, minor) (defined(__GNUC__) && (__GNUC__ > (major) || \
(__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
-
-#endif // COMMON_PLATFORM_H_
diff --git a/src/common/std_condition_variable.h b/src/common/std_condition_variable.h
index 8964b4f6f..ad2022f5a 100644
--- a/src/common/std_condition_variable.h
+++ b/src/common/std_condition_variable.h
@@ -1,6 +1,5 @@
-#ifndef CONDITION_VARIABLE_H_
-#define CONDITION_VARIABLE_H_
+#pragma once
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
@@ -167,4 +166,3 @@ private:
}
#endif
-#endif
diff --git a/src/common/std_mutex.h b/src/common/std_mutex.h
index 26eb58b62..5711d791b 100644
--- a/src/common/std_mutex.h
+++ b/src/common/std_mutex.h
@@ -1,6 +1,4 @@
-
-#ifndef MUTEX_H_
-#define MUTEX_H_
+#pragma once
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
@@ -362,4 +360,3 @@ void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y)
}
#endif
-#endif
diff --git a/src/common/std_thread.h b/src/common/std_thread.h
index 9ed0072c3..ce1336ee7 100644
--- a/src/common/std_thread.h
+++ b/src/common/std_thread.h
@@ -1,6 +1,4 @@
-
-#ifndef STD_THREAD_H_
-#define STD_THREAD_H_
+#pragma once
#define GCC_VER(x,y,z) ((x) * 10000 + (y) * 100 + (z))
#define GCC_VERSION GCC_VER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
@@ -314,4 +312,3 @@ inline thread::id get_id()
#undef THREAD_HANDLE
#endif
-#endif
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp
index e5a9ba322..c1f22bda3 100644
--- a/src/common/string_util.cpp
+++ b/src/common/string_util.cpp
@@ -2,9 +2,9 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <stdlib.h>
-#include <stdio.h>
#include <algorithm>
+#include <cstdlib>
+#include <cstdio>
#include "common/common.h"
#include "common/common_paths.h"
@@ -13,8 +13,8 @@
#ifdef _WIN32
#include <Windows.h>
#else
+ #include <cerrno>
#include <iconv.h>
- #include <errno.h>
#endif
/// Make a string lowercase
diff --git a/src/common/string_util.h b/src/common/string_util.h
index b3c99a807..ba4cd363e 100644
--- a/src/common/string_util.h
+++ b/src/common/string_util.h
@@ -2,15 +2,13 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _STRINGUTIL_H_
-#define _STRINGUTIL_H_
+#pragma once
-#include <stdarg.h>
-
-#include <vector>
+#include <cstdarg>
+#include <iomanip>
#include <string>
#include <sstream>
-#include <iomanip>
+#include <vector>
#include "common/common.h"
@@ -113,5 +111,3 @@ inline std::string UTF8ToTStr(const std::string& str)
#endif
#endif
-
-#endif // _STRINGUTIL_H_
diff --git a/src/common/symbols.cpp b/src/common/symbols.cpp
index dcc9eeac5..d61f4c0c6 100644
--- a/src/common/symbols.cpp
+++ b/src/common/symbols.cpp
@@ -40,7 +40,7 @@ namespace Symbols
return symbol;
}
- const std::string& GetName(u32 _address)
+ const std::string GetName(u32 _address)
{
return GetSymbol(_address).name;
}
diff --git a/src/common/symbols.h b/src/common/symbols.h
index b76749654..b13a8001a 100644
--- a/src/common/symbols.h
+++ b/src/common/symbols.h
@@ -8,8 +8,6 @@
#include "common/common.h"
-class DebugInterface;
-
struct TSymbol
{
TSymbol() :
@@ -32,7 +30,7 @@ namespace Symbols
void Add(u32 _address, const std::string& _name, u32 _size, u32 _type);
TSymbol GetSymbol(u32 _address);
- const std::string& GetName(u32 _address);
+ const std::string GetName(u32 _address);
void Remove(u32 _address);
void Clear();
};
diff --git a/src/common/thread.h b/src/common/thread.h
index d72ac7b47..dbb9da53b 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _THREAD_H_
-#define _THREAD_H_
+#pragma once
#include "common/std_condition_variable.h"
#include "common/std_mutex.h"
@@ -11,8 +10,8 @@
// Don't include common.h here as it will break LogManager
#include "common/common_types.h"
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
// This may not be defined outside _WIN32
#ifndef _WIN32
@@ -152,5 +151,3 @@ inline void YieldCPU()
void SetCurrentThreadName(const char *name);
} // namespace Common
-
-#endif // _THREAD_H_
diff --git a/src/common/thunk.h b/src/common/thunk.h
index 2c2f23cd0..90c8be888 100644
--- a/src/common/thunk.h
+++ b/src/common/thunk.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _THUNK_H_
-#define _THUNK_H_
+#pragma once
#include <map>
@@ -41,5 +40,3 @@ private:
void Shutdown();
void Reset();
};
-
-#endif // _THUNK_H_
diff --git a/src/common/timer.h b/src/common/timer.h
index cfa5cf609..86418e7a7 100644
--- a/src/common/timer.h
+++ b/src/common/timer.h
@@ -2,8 +2,7 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#ifndef _TIMER_H_
-#define _TIMER_H_
+#pragma once
#include "common/common.h"
#include <string>
@@ -42,5 +41,3 @@ private:
};
} // Namespace Common
-
-#endif // _TIMER_H_
diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp
index fe5270183..c83824d35 100644
--- a/src/common/utf8.cpp
+++ b/src/common/utf8.cpp
@@ -18,10 +18,10 @@
#undef max
#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
+#include <cstdlib>
+#include <cstdio>
+#include <cstring>
+#include <cstdarg>
#include <algorithm>
#include <string>
diff --git a/src/core/arm/interpreter/vfp/vfpdouble.cpp b/src/core/arm/interpreter/vfp/vfpdouble.cpp
index 7f975cbeb..5ae99b88a 100644
--- a/src/core/arm/interpreter/vfp/vfpdouble.cpp
+++ b/src/core/arm/interpreter/vfp/vfpdouble.cpp
@@ -895,7 +895,7 @@ vfp_double_multiply(struct vfp_double *vdd, struct vfp_double *vdn,
#define NEG_SUBTRACT (1 << 1)
static u32
-vfp_double_multiply_accumulate(ARMul_State* state, int dd, int dn, int dm, u32 fpscr, u32 negate, char *func)
+vfp_double_multiply_accumulate(ARMul_State* state, int dd, int dn, int dm, u32 fpscr, u32 negate, const char *func)
{
struct vfp_double vdd, vdp, vdn, vdm;
u32 exceptions;
diff --git a/src/core/arm/interpreter/vfp/vfpsingle.cpp b/src/core/arm/interpreter/vfp/vfpsingle.cpp
index 602713cff..0fcc85266 100644
--- a/src/core/arm/interpreter/vfp/vfpsingle.cpp
+++ b/src/core/arm/interpreter/vfp/vfpsingle.cpp
@@ -917,7 +917,7 @@ vfp_single_multiply(struct vfp_single *vsd, struct vfp_single *vsn, struct vfp_s
#define NEG_SUBTRACT (1 << 1)
static u32
-vfp_single_multiply_accumulate(ARMul_State* state, int sd, int sn, s32 m, u32 fpscr, u32 negate, char *func)
+vfp_single_multiply_accumulate(ARMul_State* state, int sd, int sn, s32 m, u32 fpscr, u32 negate, const char *func)
{
struct vfp_single vsd, vsp, vsn, vsm;
u32 exceptions;
diff --git a/src/core/hle/function_wrappers.h b/src/core/hle/function_wrappers.h
index ea603a1bb..55eaf0621 100644
--- a/src/core/hle/function_wrappers.h
+++ b/src/core/hle/function_wrappers.h
@@ -11,24 +11,41 @@
namespace HLE {
#define PARAM(n) Core::g_app_core->GetReg(n)
-#define RETURN(n) Core::g_app_core->SetReg(0, n)
+
+/**
+ * HLE a function return from the current ARM11 userland process
+ * @param res Result to return
+ */
+static inline void FuncReturn(u32 res) {
+ Core::g_app_core->SetReg(0, res);
+}
+
+/**
+ * HLE a function return (64-bit) from the current ARM11 userland process
+ * @param res Result to return (64-bit)
+ * @todo Verify that this function is correct
+ */
+static inline void FuncReturn64(u64 res) {
+ Core::g_app_core->SetReg(0, (u32)(res & 0xFFFFFFFF));
+ Core::g_app_core->SetReg(1, (u32)((res >> 32) & 0xFFFFFFFF));
+}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type s32
template<s32 func(u32, u32, u32, u32)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3)));
}
template<s32 func(u32, u32, u32, u32, u32)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4)));
}
template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(0), PARAM(1), PARAM(2), PARAM(3), PARAM(4));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
@@ -36,57 +53,57 @@ template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
Core::g_app_core->SetReg(1, (u32)param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
// TODO(bunnei): Is this correct? Probably not - Last parameter looks wrong for ArbitrateAddress
template<s32 func(u32, u32, u32, u32, s64)> void Wrap() {
- RETURN(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))));
+ FuncReturn(func(PARAM(0), PARAM(1), PARAM(2), PARAM(3), (((s64)PARAM(5) << 32) | PARAM(4))));
}
template<s32 func(u32*)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1);
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32, s64)> void Wrap() {
- RETURN(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
+ FuncReturn(func(PARAM(0), (((s64)PARAM(3) << 32) | PARAM(2))));
}
template<s32 func(void*, void*, u32)> void Wrap(){
- RETURN(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
+ FuncReturn(func(Memory::GetPointer(PARAM(0)), Memory::GetPointer(PARAM(1)), PARAM(2)));
}
template<s32 func(s32*, u32)> void Wrap(){
s32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32, s32)> void Wrap() {
- RETURN(func(PARAM(0), (s32)PARAM(1)));
+ FuncReturn(func(PARAM(0), (s32)PARAM(1)));
}
template<s32 func(u32*, u32)> void Wrap(){
u32 param_1 = 0;
u32 retval = func(&param_1, PARAM(1));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
template<s32 func(u32)> void Wrap() {
- RETURN(func(PARAM(0)));
+ FuncReturn(func(PARAM(0)));
}
template<s32 func(void*)> void Wrap() {
- RETURN(func(Memory::GetPointer(PARAM(0))));
+ FuncReturn(func(Memory::GetPointer(PARAM(0))));
}
template<s32 func(s64*, u32, void*, s32)> void Wrap(){
- RETURN(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
+ FuncReturn(func((s64*)Memory::GetPointer(PARAM(0)), PARAM(1), Memory::GetPointer(PARAM(2)),
(s32)PARAM(3)));
}
@@ -94,14 +111,21 @@ template<s32 func(u32*, const char*)> void Wrap() {
u32 param_1 = 0;
u32 retval = func(&param_1, Memory::GetCharPointer(PARAM(1)));
Core::g_app_core->SetReg(1, param_1);
- RETURN(retval);
+ FuncReturn(retval);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// Function wrappers that return type u32
template<u32 func()> void Wrap() {
- RETURN(func());
+ FuncReturn(func());
+}
+
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Function wrappers that return type s64
+
+template<s64 func()> void Wrap() {
+ FuncReturn64(func());
}
////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -116,6 +140,6 @@ template<void func(const char*)> void Wrap() {
}
#undef PARAM
-#undef RETURN
+#undef FuncReturn
} // namespace HLE
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index bdf76e0c2..174d4cd6e 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -17,8 +17,8 @@ namespace Kernel {
class AddressArbiter : public Object {
public:
- const char* GetTypeName() const { return "Arbiter"; }
- const char* GetName() const { return name.c_str(); }
+ std::string GetTypeName() const { return "Arbiter"; }
+ std::string GetName() const { return name; }
static Kernel::HandleType GetStaticHandleType() { return HandleType::AddressArbiter; }
Kernel::HandleType GetHandleType() const { return HandleType::AddressArbiter; }
diff --git a/src/core/hle/kernel/archive.cpp b/src/core/hle/kernel/archive.cpp
index 76b2520da..5079fcb84 100644
--- a/src/core/hle/kernel/archive.cpp
+++ b/src/core/hle/kernel/archive.cpp
@@ -31,8 +31,8 @@ enum class FileCommand : u32 {
class Archive : public Object {
public:
- const char* GetTypeName() const { return "Archive"; }
- const char* GetName() const { return name.c_str(); }
+ std::string GetTypeName() const { return "Archive"; }
+ std::string GetName() const { return name; }
static Kernel::HandleType GetStaticHandleType() { return HandleType::Archive; }
Kernel::HandleType GetHandleType() const { return HandleType::Archive; }
@@ -110,7 +110,7 @@ Result MountArchive(Archive* archive) {
return -1;
}
g_archive_map[id_code] = archive->GetHandle();
- INFO_LOG(KERNEL, "Mounted archive %s", archive->GetName());
+ INFO_LOG(KERNEL, "Mounted archive %s", archive->GetName().c_str());
return 0;
}
diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp
index 1e417e09c..64f6a9649 100644
--- a/src/core/hle/kernel/event.cpp
+++ b/src/core/hle/kernel/event.cpp
@@ -16,8 +16,8 @@ namespace Kernel {
class Event : public Object {
public:
- const char* GetTypeName() const { return "Event"; }
- const char* GetName() const { return name.c_str(); }
+ std::string GetTypeName() const { return "Event"; }
+ std::string GetName() const { return name; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Event; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Event; }
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 7d9bd261e..a4a258875 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -17,7 +17,6 @@ Handle g_main_thread = 0;
ObjectPool g_object_pool;
ObjectPool::ObjectPool() {
- memset(occupied, 0, sizeof(bool) * MAX_COUNT);
next_id = INITIAL_NEXT_ID;
}
@@ -57,7 +56,7 @@ void ObjectPool::Clear() {
delete pool[i];
occupied[i] = false;
}
- memset(pool, 0, sizeof(Object*)*MAX_COUNT);
+ pool.fill(nullptr);
next_id = INITIAL_NEXT_ID;
}
@@ -71,8 +70,8 @@ void ObjectPool::List() {
for (int i = 0; i < MAX_COUNT; i++) {
if (occupied[i]) {
if (pool[i]) {
- INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName(),
- pool[i]->GetName());
+ INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(),
+ pool[i]->GetName().c_str());
}
}
}
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index d9afcdd25..0e7e5ff68 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -4,6 +4,8 @@
#pragma once
+#include <array>
+#include <string>
#include "common/common.h"
typedef u32 Handle;
@@ -33,7 +35,6 @@ enum class HandleType : u32 {
};
enum {
- MAX_NAME_LENGTH = 0x100,
DEFAULT_STACK_SIZE = 0x4000,
};
@@ -45,8 +46,8 @@ class Object : NonCopyable {
public:
virtual ~Object() {}
Handle GetHandle() const { return handle; }
- virtual const char* GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; }
- virtual const char* GetName() const { return "[UNKNOWN KERNEL OBJECT]"; }
+ virtual std::string GetTypeName() const { return "[BAD KERNEL OBJECT TYPE]"; }
+ virtual std::string GetName() const { return "[UNKNOWN KERNEL OBJECT]"; }
virtual Kernel::HandleType GetHandleType() const = 0;
/**
@@ -160,9 +161,9 @@ private:
INITIAL_NEXT_ID = 0x10,
};
- Object* pool[MAX_COUNT];
- bool occupied[MAX_COUNT];
- int next_id;
+ std::array<Object*, MAX_COUNT> pool;
+ std::array<bool, MAX_COUNT> occupied;
+ int next_id;
};
extern ObjectPool g_object_pool;
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp
index 055f503f9..5d7d65dd9 100644
--- a/src/core/hle/kernel/mutex.cpp
+++ b/src/core/hle/kernel/mutex.cpp
@@ -15,8 +15,8 @@ namespace Kernel {
class Mutex : public Object {
public:
- const char* GetTypeName() const { return "Mutex"; }
- const char* GetName() const { return name.c_str(); }
+ std::string GetTypeName() const { return "Mutex"; }
+ std::string GetName() const { return name; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Mutex; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Mutex; }
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 52823048f..2a6a483a1 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -11,7 +11,7 @@ namespace Kernel {
class SharedMemory : public Object {
public:
- const char* GetTypeName() const { return "SharedMemory"; }
+ std::string GetTypeName() const { return "SharedMemory"; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::SharedMemory; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::SharedMemory; }
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 1d7ded6f6..554ec9756 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -2,13 +2,12 @@
// Licensed under GPLv2
// Refer to the license.txt file included.
-#include <stdio.h>
-
-#include <list>
#include <algorithm>
-#include <vector>
+#include <cstdio>
+#include <list>
#include <map>
#include <string>
+#include <vector>
#include "common/common.h"
#include "common/thread_queue_list.h"
@@ -25,8 +24,8 @@ namespace Kernel {
class Thread : public Kernel::Object {
public:
- const char* GetName() const { return name; }
- const char* GetTypeName() const { return "Thread"; }
+ std::string GetName() const { return name; }
+ std::string GetTypeName() const { return "Thread"; }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Thread; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Thread; }
@@ -71,7 +70,7 @@ public:
std::vector<Handle> waiting_threads;
- char name[Kernel::MAX_NAME_LENGTH + 1];
+ std::string name;
};
// Lists all thread ids that aren't deleted/etc.
@@ -336,9 +335,7 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio
thread->processor_id = processor_id;
thread->wait_type = WAITTYPE_NONE;
thread->wait_handle = 0;
-
- strncpy(thread->name, name, Kernel::MAX_NAME_LENGTH);
- thread->name[Kernel::MAX_NAME_LENGTH] = '\0';
+ thread->name = name;
return thread;
}
diff --git a/src/core/hle/service/apt.h b/src/core/hle/service/apt.h
index dca3097ed..4c7dd07e7 100644
--- a/src/core/hle/service/apt.h
+++ b/src/core/hle/service/apt.h
@@ -29,7 +29,7 @@ public:
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "APT:U";
}
};
diff --git a/src/core/hle/service/fs.h b/src/core/hle/service/fs.h
index fabf5ac7e..36f3697d3 100644
--- a/src/core/hle/service/fs.h
+++ b/src/core/hle/service/fs.h
@@ -23,7 +23,7 @@ public:
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "fs:USER";
}
};
diff --git a/src/core/hle/service/gsp.h b/src/core/hle/service/gsp.h
index fccebef7e..b25dbb7bc 100644
--- a/src/core/hle/service/gsp.h
+++ b/src/core/hle/service/gsp.h
@@ -137,7 +137,7 @@ public:
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "gsp::Gpu";
}
diff --git a/src/core/hle/service/hid.h b/src/core/hle/service/hid.h
index 81c29eb2e..b17fcfa86 100644
--- a/src/core/hle/service/hid.h
+++ b/src/core/hle/service/hid.h
@@ -25,7 +25,7 @@ public:
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "hid:USER";
}
diff --git a/src/core/hle/service/ndm.h b/src/core/hle/service/ndm.h
index fbe88fb8f..d5ec28f5b 100644
--- a/src/core/hle/service/ndm.h
+++ b/src/core/hle/service/ndm.h
@@ -24,7 +24,7 @@ public:
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "ndm:u";
}
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index dcd525727..cb1ecde31 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -39,8 +39,8 @@ class Interface : public Kernel::Object {
friend class Manager;
public:
- const char *GetName() const { return GetPortName(); }
- const char *GetTypeName() const { return GetPortName(); }
+ std::string GetName() const { return GetPortName(); }
+ std::string GetTypeName() const { return GetPortName(); }
static Kernel::HandleType GetStaticHandleType() { return Kernel::HandleType::Service; }
Kernel::HandleType GetHandleType() const { return Kernel::HandleType::Service; }
@@ -57,7 +57,7 @@ public:
* Gets the string name used by CTROS for a service
* @return Port name of service
*/
- virtual const char *GetPortName() const {
+ virtual std::string GetPortName() const {
return "[UNKNOWN SERVICE PORT]";
}
@@ -86,7 +86,7 @@ public:
if (itr == m_functions.end()) {
ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X",
- GetPortName(), cmd_buff[0]);
+ GetPortName().c_str(), cmd_buff[0]);
// TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer();
@@ -95,7 +95,7 @@ public:
}
if (itr->second.func == nullptr) {
ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s",
- GetPortName(), itr->second.name.c_str());
+ GetPortName().c_str(), itr->second.name.c_str());
// TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer();
diff --git a/src/core/hle/service/srv.h b/src/core/hle/service/srv.h
index 81109a2a8..9451472de 100644
--- a/src/core/hle/service/srv.h
+++ b/src/core/hle/service/srv.h
@@ -22,7 +22,7 @@ public:
* Gets the string name used by CTROS for the service
* @return Port name of service
*/
- const char *GetPortName() const {
+ std::string GetPortName() const {
return "srv:";
}
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 19f717bd2..bdcfae6f5 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -5,6 +5,7 @@
#include <map>
#include <string>
+#include "common/string_util.h"
#include "common/symbols.h"
#include "core/mem_map.h"
@@ -91,7 +92,7 @@ Result SendSyncRequest(Handle handle) {
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
_assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
- DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName());
+ DEBUG_LOG(SVC, "called handle=0x%08X(%s)", handle, object->GetTypeName().c_str());
bool wait = false;
Result res = object->SyncRequest(&wait);
@@ -117,8 +118,8 @@ Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
- DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName(),
- object->GetName(), nano_seconds);
+ DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%d", handle, object->GetTypeName().c_str(),
+ object->GetName().c_str(), nano_seconds);
_assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
@@ -151,8 +152,8 @@ Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count, bool wa
_assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object "
"is nullptr!", handles[i]);
- DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName(),
- object->GetName());
+ DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
+ object->GetName().c_str());
Result res = object->WaitSynchronization(&wait);
@@ -220,9 +221,7 @@ Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top, u32 p
TSymbol symbol = Symbols::GetSymbol(entry_point);
name = symbol.name;
} else {
- char buff[100];
- sprintf(buff, "%s", "unknown-%08X", entry_point);
- name = buff;
+ name = StringFromFormat("unknown-%08x", entry_point);
}
Handle thread = Kernel::CreateThread(name.c_str(), entry_point, priority, arg, processor_id,
@@ -331,6 +330,11 @@ void SleepThread(s64 nanoseconds) {
DEBUG_LOG(SVC, "called nanoseconds=%d", nanoseconds);
}
+/// This returns the total CPU ticks elapsed since the CPU was powered-on
+s64 GetSystemTick() {
+ return (s64)Core::g_app_core->GetTicks();
+}
+
const HLE::FunctionDef SVC_Table[] = {
{0x00, nullptr, "Unknown"},
{0x01, HLE::Wrap<ControlMemory>, "ControlMemory"},
@@ -372,7 +376,7 @@ const HLE::FunctionDef SVC_Table[] = {
{0x25, HLE::Wrap<WaitSynchronizationN>, "WaitSynchronizationN"},
{0x26, nullptr, "SignalAndWait"},
{0x27, HLE::Wrap<DuplicateHandle>, "DuplicateHandle"},
- {0x28, nullptr, "GetSystemTick"},
+ {0x28, HLE::Wrap<GetSystemTick>, "GetSystemTick"},
{0x29, nullptr, "GetHandleInfo"},
{0x2A, nullptr, "GetSystemInfo"},
{0x2B, nullptr, "GetProcessInfo"},
diff --git a/src/core/mem_map_funcs.cpp b/src/core/mem_map_funcs.cpp
index 5772cca52..ecdaa06d7 100644
--- a/src/core/mem_map_funcs.cpp
+++ b/src/core/mem_map_funcs.cpp
@@ -289,11 +289,15 @@ void Write64(const u32 addr, const u64 data) {
void WriteBlock(const u32 addr, const u8* data, const int size) {
int offset = 0;
- while (offset < (size & ~3))
- Write32(addr + offset, *(u32*)&data[offset += 4]);
+ while (offset < (size & ~3)) {
+ Write32(addr + offset, *(u32*)&data[offset]);
+ offset += 4;
+ }
- if (size & 2)
- Write16(addr + offset, *(u16*)&data[offset += 2]);
+ if (size & 2) {
+ Write16(addr + offset, *(u16*)&data[offset]);
+ offset += 2;
+ }
if (size & 1)
Write8(addr + offset, data[offset]);