yuzu-emu
/
yuzu
Archived
1
0
Fork 0

Merge pull request #211 from linkmauve/master

Remove trailing spaces from the entire project
This commit is contained in:
bunnei 2014-11-19 15:24:46 -05:00
commit c0cd0fa78e
84 changed files with 459 additions and 459 deletions

View File

@ -28,23 +28,23 @@ Follow the indentation/whitespace style shown below. Do not use tabs, use 4-spac
namespace Example { namespace Example {
// Namespace contents are not indented // Namespace contents are not indented
// Declare globals at the top // Declare globals at the top
int g_foo = 0; int g_foo = 0;
char* g_some_pointer; // Notice the position of the * char* g_some_pointer; // Notice the position of the *
enum SomeEnum { enum SomeEnum {
COLOR_RED, COLOR_RED,
COLOR_GREEN, COLOR_GREEN,
COLOR_BLUE COLOR_BLUE
}; };
struct Position { struct Position {
int x, y; int x, y;
}; };
// Use "typename" rather than "class" here, just to be consistent // Use "typename" rather than "class" here, just to be consistent
template template
void FooBar() { void FooBar() {
int some_array[] = { int some_array[] = {
5, 5,
@ -52,29 +52,29 @@ void FooBar() {
7, 7,
42 42
}; };
if (note == the_space_after_the_if) { if (note == the_space_after_the_if) {
CallAfunction(); CallAfunction();
} else { } else {
// Use a space after the // when commenting // Use a space after the // when commenting
} }
// Comment directly above code when possible // Comment directly above code when possible
if (some_condition) single_statement(); if (some_condition) single_statement();
// Place a single space after the for loop semicolons // Place a single space after the for loop semicolons
for (int i = 0; i != 25; ++i) { for (int i = 0; i != 25; ++i) {
// This is how we write loops // This is how we write loops
} }
DoStuff(this, function, call, takes, up, multiple, DoStuff(this, function, call, takes, up, multiple,
lines, like, this); lines, like, this);
if (this || condition_takes_up_multiple && if (this || condition_takes_up_multiple &&
lines && like && this || everything || lines && like && this || everything ||
alright || then) { alright || then) {
} }
switch (var) { switch (var) {
// No indentation for case label // No indentation for case label
case 1: { case 1: {
@ -85,18 +85,18 @@ void FooBar() {
case 3: case 3:
DoSomething(var); DoSomething(var);
return; return;
default: default:
// Yes, even break for the last case // Yes, even break for the last case
break; break;
} }
std::vector std::vector
you_can_declare, you_can_declare,
a_few, a_few,
variables, variables,
like_this; like_this;
} }
} }
``` ```

View File

@ -23,7 +23,7 @@ int __cdecl main(int argc, char **argv) {
} }
Config config; Config config;
if (!Settings::values.enable_log) if (!Settings::values.enable_log)
LogManager::Shutdown(); LogManager::Shutdown();

View File

@ -16,8 +16,8 @@ public:
/// Swap buffers to display the next frame /// Swap buffers to display the next frame
void SwapBuffers() override; void SwapBuffers() override;
/// Polls window events /// Polls window events
void PollEvents() override; void PollEvents() override;
/// Makes the graphics context current for the caller thread /// Makes the graphics context current for the caller thread
void MakeCurrent() override; void MakeCurrent() override;

View File

@ -23,7 +23,7 @@
#define APP_TITLE APP_NAME " " APP_VERSION #define APP_TITLE APP_NAME " " APP_VERSION
#define COPYRIGHT "Copyright (C) 2013-2014 Citra Team" #define COPYRIGHT "Copyright (C) 2013-2014 Citra Team"
EmuThread::EmuThread(GRenderWindow* render_window) : EmuThread::EmuThread(GRenderWindow* render_window) :
filename(""), exec_cpu_step(false), cpu_running(false), filename(""), exec_cpu_step(false), cpu_running(false),
stop_run(false), render_window(render_window) stop_run(false), render_window(render_window)
{ {
@ -42,7 +42,7 @@ void EmuThread::run()
if (cpu_running) if (cpu_running)
{ {
Core::RunLoop(); Core::RunLoop();
} }
else if (exec_cpu_step) else if (exec_cpu_step)
{ {
exec_cpu_step = false; exec_cpu_step = false;
@ -274,5 +274,5 @@ void GRenderWindow::OnClientAreaResized(unsigned width, unsigned height)
} }
void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) { void GRenderWindow::OnMinimalClientAreaChangeRequest(const std::pair<unsigned,unsigned>& minimal_size) {
setMinimumSize(minimal_size.first, minimal_size.second); setMinimumSize(minimal_size.first, minimal_size.second);
} }

View File

@ -18,7 +18,7 @@ class EmuThread : public QThread
public: public:
/** /**
* Set image filename * Set image filename
* *
* @param filename * @param filename
* @warning Only call when not running! * @warning Only call when not running!
*/ */

View File

@ -48,7 +48,7 @@ void GKeyConfigButton::OnActivePortChanged(const common::Config::ControllerPort&
else if (config.keys.key_code[id] == Qt::Key_Control) text = tr("Control"); else if (config.keys.key_code[id] == Qt::Key_Control) text = tr("Control");
else if (config.keys.key_code[id] == Qt::Key_Alt) text = tr("Alt"); else if (config.keys.key_code[id] == Qt::Key_Alt) text = tr("Alt");
else if (config.keys.key_code[id] == Qt::Key_Meta) text = tr("Meta"); else if (config.keys.key_code[id] == Qt::Key_Meta) text = tr("Meta");
setText(text); setText(text);
} }
void GKeyConfigButton::OnClicked() void GKeyConfigButton::OnClicked()
@ -118,4 +118,4 @@ GButtonConfigGroup::GButtonConfigGroup(const QString& name, common::Config::Cont
setLayout(layout); setLayout(layout);
} }
*/ */

View File

@ -28,7 +28,7 @@ void CallstackWidget::OnCPUStepped()
u32 sp = app_core->GetReg(13); //stack pointer u32 sp = app_core->GetReg(13); //stack pointer
u32 addr, ret_addr, call_addr, func_addr; u32 addr, ret_addr, call_addr, func_addr;
int counter = 0; int counter = 0;
for (int addr = 0x10000000; addr >= sp; addr -= 4) for (int addr = 0x10000000; addr >= sp; addr -= 4)
{ {
@ -55,7 +55,7 @@ void CallstackWidget::OnCPUStepped()
callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0')))); callstack_model->setItem(counter, 0, new QStandardItem(QString("0x%1").arg(addr, 8, 16, QLatin1Char('0'))));
callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0')))); callstack_model->setItem(counter, 1, new QStandardItem(QString("0x%1").arg(ret_addr, 8, 16, QLatin1Char('0'))));
callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg(call_addr, 8, 16, QLatin1Char('0')))); callstack_model->setItem(counter, 2, new QStandardItem(QString("0x%1").arg(call_addr, 8, 16, QLatin1Char('0'))));
name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown"; name = Symbols::HasSymbol(func_addr) ? Symbols::GetSymbol(func_addr).name : "unknown";
callstack_model->setItem(counter, 3, new QStandardItem(QString("%1_%2").arg(QString::fromStdString(name)) callstack_model->setItem(counter, 3, new QStandardItem(QString("%1_%2").arg(QString::fromStdString(name))
.arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0'))))); .arg(QString("0x%1").arg(func_addr, 8, 16, QLatin1Char('0')))));
@ -63,4 +63,4 @@ void CallstackWidget::OnCPUStepped()
counter++; counter++;
} }
} }
} }

View File

@ -46,18 +46,18 @@ void RegistersWidget::OnCPUStepped()
CSPR->setText(1, QString("0x%1").arg(app_core->GetCPSR(), 8, 16, QLatin1Char('0'))); CSPR->setText(1, QString("0x%1").arg(app_core->GetCPSR(), 8, 16, QLatin1Char('0')));
CSPR->child(0)->setText(1, QString("b%1").arg(app_core->GetCPSR() & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode CSPR->child(0)->setText(1, QString("b%1").arg(app_core->GetCPSR() & 0x1F, 5, 2, QLatin1Char('0'))); // M - Mode
CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State CSPR->child(1)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 5) & 0x1)); // T - State
CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable CSPR->child(2)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 6) & 0x1)); // F - FIQ disable
CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable CSPR->child(3)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 7) & 0x1)); // I - IRQ disable
CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort CSPR->child(4)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 8) & 0x1)); // A - Imprecise abort
CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess CSPR->child(5)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 9) & 0x1)); // E - Data endianess
CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM) CSPR->child(6)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 10) & 0x3F)); // IT - If-Then state (DNM)
CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal CSPR->child(7)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 16) & 0xF)); // GE - Greater-than-or-Equal
CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify CSPR->child(8)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 20) & 0xF)); // DNM - Do not modify
CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state CSPR->child(9)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 24) & 0x1)); // J - Java state
CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow CSPR->child(10)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 27) & 0x1)); // Q - Sticky overflow
CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow CSPR->child(11)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 28) & 0x1)); // V - Overflow
CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend CSPR->child(12)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 29) & 0x1)); // C - Carry/Borrow/Extend
CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero CSPR->child(13)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 30) & 0x1)); // Z - Zero
CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than CSPR->child(14)->setText(1, QString("%1").arg((app_core->GetCPSR() >> 31) & 0x1)); // N - Negative/Less than
} }

View File

@ -16,10 +16,10 @@ public slots:
void OnCPUStepped(); void OnCPUStepped();
private: private:
Ui::ARMRegisters cpu_regs_ui; Ui::ARMRegisters cpu_regs_ui;
QTreeWidget* tree; QTreeWidget* tree;
QTreeWidgetItem* registers; QTreeWidgetItem* registers;
QTreeWidgetItem* CSPR; QTreeWidgetItem* CSPR;
}; };

View File

@ -51,7 +51,7 @@ public:
PointerWrapSection(PointerWrap &p, int ver, const char *title) : p_(p), ver_(ver), title_(title) { PointerWrapSection(PointerWrap &p, int ver, const char *title) : p_(p), ver_(ver), title_(title) {
} }
~PointerWrapSection(); ~PointerWrapSection();
bool operator == (const int &v) const { return ver_ == v; } bool operator == (const int &v) const { return ver_ == v; }
bool operator != (const int &v) const { return ver_ != v; } bool operator != (const int &v) const { return ver_ != v; }
bool operator <= (const int &v) const { return ver_ <= v; } bool operator <= (const int &v) const { return ver_ <= v; }
@ -196,7 +196,7 @@ public:
} }
(*ptr) += size; (*ptr) += size;
} }
template<class K, class T> template<class K, class T>
void Do(std::map<K, T *> &x) void Do(std::map<K, T *> &x)
{ {
@ -364,7 +364,7 @@ public:
if (vec_size > 0) if (vec_size > 0)
DoArray(&x[0], vec_size); DoArray(&x[0], vec_size);
} }
// Store deques. // Store deques.
template<class T> template<class T>
void Do(std::deque<T *> &x) void Do(std::deque<T *> &x)
@ -481,11 +481,11 @@ public:
} }
// Store strings. // Store strings.
void Do(std::string &x) void Do(std::string &x)
{ {
int stringLen = (int)x.length() + 1; int stringLen = (int)x.length() + 1;
Do(stringLen); Do(stringLen);
switch (mode) { switch (mode) {
case MODE_READ: x = (char*)*ptr; break; case MODE_READ: x = (char*)*ptr; break;
case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break; case MODE_WRITE: memcpy(*ptr, x.c_str(), stringLen); break;
@ -495,7 +495,7 @@ public:
(*ptr) += stringLen; (*ptr) += stringLen;
} }
void Do(std::wstring &x) void Do(std::wstring &x)
{ {
int stringLen = sizeof(wchar_t)*((int)x.length() + 1); int stringLen = sizeof(wchar_t)*((int)x.length() + 1);
Do(stringLen); Do(stringLen);
@ -534,7 +534,7 @@ public:
void Do(T &x) { void Do(T &x) {
DoHelper<T>::Do(this, x); DoHelper<T>::Do(this, x);
} }
template<class T> template<class T>
void DoPOD(T &x) { void DoPOD(T &x) {
DoHelper<T>::Do(this, x); DoHelper<T>::Do(this, x);

View File

@ -17,7 +17,7 @@ template<> struct CompileTimeAssert<true> {};
#define b2(x) ( (x) | ( (x) >> 1) ) #define b2(x) ( (x) | ( (x) >> 1) )
#define b4(x) ( b2(x) | ( b2(x) >> 2) ) #define b4(x) ( b2(x) | ( b2(x) >> 2) )
#define b8(x) ( b4(x) | ( b4(x) >> 4) ) #define b8(x) ( b4(x) | ( b4(x) >> 4) )
#define b16(x) ( b8(x) | ( b8(x) >> 8) ) #define b16(x) ( b8(x) | ( b8(x) >> 8) )
#define b32(x) (b16(x) | (b16(x) >>16) ) #define b32(x) (b16(x) | (b16(x) >>16) )
#define ROUND_UP_POW2(x) (b32(x - 1) + 1) #define ROUND_UP_POW2(x) (b32(x - 1) + 1)
@ -79,12 +79,12 @@ inline u64 _rotr64(u64 x, unsigned int shift){
#define unlink _unlink #define unlink _unlink
#define snprintf _snprintf #define snprintf _snprintf
#define vscprintf _vscprintf #define vscprintf _vscprintf
// Locale Cross-Compatibility // Locale Cross-Compatibility
#define locale_t _locale_t #define locale_t _locale_t
#define freelocale _free_locale #define freelocale _free_locale
#define newlocale(mask, locale, base) _create_locale(mask, locale) #define newlocale(mask, locale, base) _create_locale(mask, locale)
#define LC_GLOBAL_LOCALE ((locale_t)-1) #define LC_GLOBAL_LOCALE ((locale_t)-1)
#define LC_ALL_MASK LC_ALL #define LC_ALL_MASK LC_ALL
#define LC_COLLATE_MASK LC_COLLATE #define LC_COLLATE_MASK LC_COLLATE
@ -92,7 +92,7 @@ inline u64 _rotr64(u64 x, unsigned int shift){
#define LC_MONETARY_MASK LC_MONETARY #define LC_MONETARY_MASK LC_MONETARY
#define LC_NUMERIC_MASK LC_NUMERIC #define LC_NUMERIC_MASK LC_NUMERIC
#define LC_TIME_MASK LC_TIME #define LC_TIME_MASK LC_TIME
inline locale_t uselocale(locale_t new_locale) inline locale_t uselocale(locale_t new_locale)
{ {
// Retrieve the current per thread locale setting // Retrieve the current per thread locale setting
@ -168,8 +168,8 @@ inline u16 swap16(u16 _data) {return _byteswap_ushort(_data);}
inline u32 swap32(u32 _data) {return _byteswap_ulong (_data);} inline u32 swap32(u32 _data) {return _byteswap_ulong (_data);}
inline u64 swap64(u64 _data) {return _byteswap_uint64(_data);} inline u64 swap64(u64 _data) {return _byteswap_uint64(_data);}
#elif _M_ARM #elif _M_ARM
inline u16 swap16 (u16 _data) { u32 data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (u16)data;} inline u16 swap16 (u16 _data) { u32 data = _data; __asm__ ("rev16 %0, %1\n" : "=l" (data) : "l" (data)); return (u16)data;}
inline u32 swap32 (u32 _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;} inline u32 swap32 (u32 _data) {__asm__ ("rev %0, %1\n" : "=l" (_data) : "l" (_data)); return _data;}
inline u64 swap64(u64 _data) {return ((u64)swap32(_data) << 32) | swap32(_data >> 32);} inline u64 swap64(u64 _data) {return ((u64)swap32(_data) << 32) | swap32(_data >> 32);}
#elif __linux__ #elif __linux__
inline u16 swap16(u16 _data) {return bswap_16(_data);} inline u16 swap16(u16 _data) {return bswap_16(_data);}
@ -226,7 +226,7 @@ template <typename T>
inline T FromBigEndian(T data) inline T FromBigEndian(T data)
{ {
//static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types"); //static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types");
swap<sizeof(data)>(reinterpret_cast<u8*>(&data)); swap<sizeof(data)>(reinterpret_cast<u8*>(&data));
return data; return data;
} }

View File

@ -22,7 +22,7 @@
* http://code.google.com/p/gekko-gc-emu/ * http://code.google.com/p/gekko-gc-emu/
*/ */
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <cstdint> #include <cstdint>
@ -45,8 +45,8 @@ typedef double f64; ///< 64-bit floating point
/// Union for fast 16-bit type casting /// Union for fast 16-bit type casting
union t16 { union t16 {
u8 _u8[2]; ///< 8-bit unsigned char(s) u8 _u8[2]; ///< 8-bit unsigned char(s)
u16 _u16; ///< 16-bit unsigned shorts(s) u16 _u16; ///< 16-bit unsigned shorts(s)
}; };
/// Union for fast 32-bit type casting /// Union for fast 32-bit type casting

View File

@ -86,7 +86,7 @@ bool ConsoleListener::IsOpen()
/* /*
LetterSpace: SetConsoleScreenBufferSize and SetConsoleWindowInfo are LetterSpace: SetConsoleScreenBufferSize and SetConsoleWindowInfo are
dependent on each other, that's the reason for the additional checks. dependent on each other, that's the reason for the additional checks.
*/ */
void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst) void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
{ {
@ -225,7 +225,7 @@ void ConsoleListener::PixelSpace(int Left, int Top, int Width, int Height, bool
BytesWritten += cAttrWritten; BytesWritten += cAttrWritten;
coordScreen = GetCoordinates(BytesWritten, LBufWidth); coordScreen = GetCoordinates(BytesWritten, LBufWidth);
} }
const int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X; const int OldCursor = ConInfo.dwCursorPosition.Y * ConInfo.dwSize.X + ConInfo.dwCursorPosition.X;
COORD Coo = GetCoordinates(OldCursor, LBufWidth); COORD Coo = GetCoordinates(OldCursor, LBufWidth);
@ -296,23 +296,23 @@ void ConsoleListener::Log(LogTypes::LOG_LEVELS Level, const char *Text)
} }
// Clear console screen // Clear console screen
void ConsoleListener::ClearScreen(bool Cursor) void ConsoleListener::ClearScreen(bool Cursor)
{ {
#if defined(_WIN32) #if defined(_WIN32)
COORD coordScreen = { 0, 0 }; COORD coordScreen = { 0, 0 };
DWORD cCharsWritten; DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize; DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi); GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y; dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
// Write space to the entire console // Write space to the entire console
FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi); GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten);
// Reset cursor // Reset cursor
if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen); if (Cursor) SetConsoleCursorPosition(hConsole, coordScreen);
#endif #endif
} }

View File

@ -29,7 +29,7 @@ using namespace std;
void PCSTR2LPTSTR( PCSTR lpszIn, LPTSTR lpszOut ) void PCSTR2LPTSTR( PCSTR lpszIn, LPTSTR lpszOut )
{ {
#if defined(UNICODE)||defined(_UNICODE) #if defined(UNICODE)||defined(_UNICODE)
ULONG index = 0; ULONG index = 0;
PCSTR lpAct = lpszIn; PCSTR lpAct = lpszIn;
for( ; ; lpAct++ ) for( ; ; lpAct++ )
@ -37,7 +37,7 @@ void PCSTR2LPTSTR( PCSTR lpszIn, LPTSTR lpszOut )
lpszOut[index++] = (TCHAR)(*lpAct); lpszOut[index++] = (TCHAR)(*lpAct);
if ( *lpAct == 0 ) if ( *lpAct == 0 )
break; break;
} }
#else #else
// This is trivial :) // This is trivial :)
strcpy( lpszOut, lpszIn ); strcpy( lpszOut, lpszIn );
@ -101,7 +101,7 @@ BOOL InitSymInfo( PCSTR lpszInitialSymbolPath )
CHAR lpszSymbolPath[BUFFERSIZE]; CHAR lpszSymbolPath[BUFFERSIZE];
DWORD symOptions = SymGetOptions(); DWORD symOptions = SymGetOptions();
symOptions |= SYMOPT_LOAD_LINES; symOptions |= SYMOPT_LOAD_LINES;
symOptions &= ~SYMOPT_UNDNAME; symOptions &= ~SYMOPT_UNDNAME;
SymSetOptions( symOptions ); SymSetOptions( symOptions );
InitSymbolPath( lpszSymbolPath, lpszInitialSymbolPath ); InitSymbolPath( lpszSymbolPath, lpszInitialSymbolPath );
@ -153,15 +153,15 @@ static BOOL GetFunctionInfoFromAddresses( ULONG fnAddress, ULONG stackAddress, L
#ifndef _M_X64 #ifndef _M_X64
DWORD dwDisp = 0; DWORD dwDisp = 0;
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, &dwDisp, pSym ) ) if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, &dwDisp, pSym ) )
#else #else
//makes it compile but hell im not sure if this works... //makes it compile but hell im not sure if this works...
DWORD64 dwDisp = 0; DWORD64 dwDisp = 0;
if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, (PDWORD64)&dwDisp, pSym ) ) if ( SymGetSymFromAddr( GetCurrentProcess(), (ULONG)fnAddress, (PDWORD64)&dwDisp, pSym ) )
#endif #endif
{ {
// Make the symbol readable for humans // Make the symbol readable for humans
UnDecorateSymbolName( pSym->Name, lpszNonUnicodeUnDSymbol, BUFFERSIZE, UnDecorateSymbolName( pSym->Name, lpszNonUnicodeUnDSymbol, BUFFERSIZE,
UNDNAME_COMPLETE | UNDNAME_COMPLETE |
UNDNAME_NO_THISTYPE | UNDNAME_NO_THISTYPE |
UNDNAME_NO_SPECIAL_SYMS | UNDNAME_NO_SPECIAL_SYMS |
UNDNAME_NO_MEMBER_TYPE | UNDNAME_NO_MEMBER_TYPE |
@ -219,7 +219,7 @@ static BOOL GetFunctionInfoFromAddresses( ULONG fnAddress, ULONG stackAddress, L
_tcscat( lpszSymbol, lpszParsed ); _tcscat( lpszSymbol, lpszParsed );
ret = TRUE; ret = TRUE;
} }
GlobalFree( pSym ); GlobalFree( pSym );
return ret; return ret;
@ -325,14 +325,14 @@ void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
PrintFunctionAndSourceInfo(file, callStack); PrintFunctionAndSourceInfo(file, callStack);
for( ULONG index = 0; ; index++ ) for( ULONG index = 0; ; index++ )
{ {
bResult = StackWalk( bResult = StackWalk(
IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_I386,
hProcess, hProcess,
hThread, hThread,
&callStack, &callStack,
NULL, NULL,
NULL, NULL,
SymFunctionTableAccess, SymFunctionTableAccess,
SymGetModuleBase, SymGetModuleBase,
@ -341,7 +341,7 @@ void StackTrace( HANDLE hThread, const char* lpszMessage, FILE *file )
if ( index == 0 ) if ( index == 0 )
continue; continue;
if( !bResult || callStack.AddrFrame.Offset == 0 ) if( !bResult || callStack.AddrFrame.Offset == 0 )
break; break;
PrintFunctionAndSourceInfo(file, callStack); PrintFunctionAndSourceInfo(file, callStack);
@ -382,14 +382,14 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
PrintFunctionAndSourceInfo(file, callStack); PrintFunctionAndSourceInfo(file, callStack);
for( ULONG index = 0; ; index++ ) for( ULONG index = 0; ; index++ )
{ {
bResult = StackWalk( bResult = StackWalk(
IMAGE_FILE_MACHINE_I386, IMAGE_FILE_MACHINE_I386,
hProcess, hProcess,
hThread, hThread,
&callStack, &callStack,
NULL, NULL,
NULL, NULL,
SymFunctionTableAccess, SymFunctionTableAccess,
SymGetModuleBase, SymGetModuleBase,
@ -398,7 +398,7 @@ void StackTrace(HANDLE hThread, const char* lpszMessage, FILE *file, DWORD eip,
if ( index == 0 ) if ( index == 0 )
continue; continue;
if( !bResult || callStack.AddrFrame.Offset == 0 ) if( !bResult || callStack.AddrFrame.Offset == 0 )
break; break;
PrintFunctionAndSourceInfo(file, callStack); PrintFunctionAndSourceInfo(file, callStack);

View File

@ -45,7 +45,7 @@ public:
// create the element, add it to the queue // create the element, add it to the queue
m_write_ptr->current = new T(std::forward<Arg>(t)); m_write_ptr->current = new T(std::forward<Arg>(t));
// set the next pointer to a new element ptr // set the next pointer to a new element ptr
// then advance the write pointer // then advance the write pointer
m_write_ptr = m_write_ptr->next = new ElementPtr(); m_write_ptr = m_write_ptr->next = new ElementPtr();
Common::AtomicIncrement(m_size); Common::AtomicIncrement(m_size);
} }

View File

@ -43,7 +43,7 @@ void CFileSearch::FindFiles(const std::string& _searchString, const std::string&
bool bkeepLooping = true; bool bkeepLooping = true;
while (bkeepLooping) while (bkeepLooping)
{ {
if (findData.cFileName[0] != '.') if (findData.cFileName[0] != '.')
{ {
std::string strFilename; std::string strFilename;

View File

@ -88,7 +88,7 @@ bool IsDirectory(const std::string &filename)
#endif #endif
if (result < 0) { if (result < 0) {
WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s", WARN_LOG(COMMON, "IsDirectory: stat failed on %s: %s",
filename.c_str(), GetLastErrorMsg()); filename.c_str(), GetLastErrorMsg());
return false; return false;
} }
@ -102,7 +102,7 @@ bool Delete(const std::string &filename)
{ {
INFO_LOG(COMMON, "Delete: file %s", filename.c_str()); INFO_LOG(COMMON, "Delete: file %s", filename.c_str());
// Return true because we care about the file no // Return true because we care about the file no
// being there, not the actual delete. // being there, not the actual delete.
if (!Exists(filename)) if (!Exists(filename))
{ {
@ -120,13 +120,13 @@ bool Delete(const std::string &filename)
#ifdef _WIN32 #ifdef _WIN32
if (!DeleteFile(Common::UTF8ToTStr(filename).c_str())) if (!DeleteFile(Common::UTF8ToTStr(filename).c_str()))
{ {
WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s", WARN_LOG(COMMON, "Delete: DeleteFile failed on %s: %s",
filename.c_str(), GetLastErrorMsg()); filename.c_str(), GetLastErrorMsg());
return false; return false;
} }
#else #else
if (unlink(filename.c_str()) == -1) { if (unlink(filename.c_str()) == -1) {
WARN_LOG(COMMON, "Delete: unlink failed on %s: %s", WARN_LOG(COMMON, "Delete: unlink failed on %s: %s",
filename.c_str(), GetLastErrorMsg()); filename.c_str(), GetLastErrorMsg());
return false; return false;
} }
@ -232,28 +232,28 @@ bool DeleteDir(const std::string &filename)
return false; return false;
} }
// renames file srcFilename to destFilename, returns true on success // renames file srcFilename to destFilename, returns true on success
bool Rename(const std::string &srcFilename, const std::string &destFilename) bool Rename(const std::string &srcFilename, const std::string &destFilename)
{ {
INFO_LOG(COMMON, "Rename: %s --> %s", INFO_LOG(COMMON, "Rename: %s --> %s",
srcFilename.c_str(), destFilename.c_str()); srcFilename.c_str(), destFilename.c_str());
if (rename(srcFilename.c_str(), destFilename.c_str()) == 0) if (rename(srcFilename.c_str(), destFilename.c_str()) == 0)
return true; return true;
ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s", ERROR_LOG(COMMON, "Rename: failed %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
return false; return false;
} }
// copies file srcFilename to destFilename, returns true on success // copies file srcFilename to destFilename, returns true on success
bool Copy(const std::string &srcFilename, const std::string &destFilename) bool Copy(const std::string &srcFilename, const std::string &destFilename)
{ {
INFO_LOG(COMMON, "Copy: %s --> %s", INFO_LOG(COMMON, "Copy: %s --> %s",
srcFilename.c_str(), destFilename.c_str()); srcFilename.c_str(), destFilename.c_str());
#ifdef _WIN32 #ifdef _WIN32
if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE)) if (CopyFile(Common::UTF8ToTStr(srcFilename).c_str(), Common::UTF8ToTStr(destFilename).c_str(), FALSE))
return true; return true;
ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s", ERROR_LOG(COMMON, "Copy: failed %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
return false; return false;
#else #else
@ -267,7 +267,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
FILE *input = fopen(srcFilename.c_str(), "rb"); FILE *input = fopen(srcFilename.c_str(), "rb");
if (!input) if (!input)
{ {
ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s", ERROR_LOG(COMMON, "Copy: input failed %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
return false; return false;
} }
@ -277,7 +277,7 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
if (!output) if (!output)
{ {
fclose(input); fclose(input);
ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s", ERROR_LOG(COMMON, "Copy: output failed %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
return false; return false;
} }
@ -291,8 +291,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
{ {
if (ferror(input) != 0) if (ferror(input) != 0)
{ {
ERROR_LOG(COMMON, ERROR_LOG(COMMON,
"Copy: failed reading from source, %s --> %s: %s", "Copy: failed reading from source, %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
goto bail; goto bail;
} }
@ -302,8 +302,8 @@ bool Copy(const std::string &srcFilename, const std::string &destFilename)
int wnum = fwrite(buffer, sizeof(char), rnum, output); int wnum = fwrite(buffer, sizeof(char), rnum, output);
if (wnum != rnum) if (wnum != rnum)
{ {
ERROR_LOG(COMMON, ERROR_LOG(COMMON,
"Copy: failed writing to output, %s --> %s: %s", "Copy: failed writing to output, %s --> %s: %s",
srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg()); srcFilename.c_str(), destFilename.c_str(), GetLastErrorMsg());
goto bail; goto bail;
} }
@ -335,7 +335,7 @@ u64 GetSize(const std::string &filename)
WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str()); WARN_LOG(COMMON, "GetSize: failed %s: is a directory", filename.c_str());
return 0; return 0;
} }
struct stat64 buf; struct stat64 buf;
#ifdef _WIN32 #ifdef _WIN32
if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0) if (_tstat64(Common::UTF8ToTStr(filename).c_str(), &buf) == 0)
@ -384,10 +384,10 @@ u64 GetSize(FILE *f)
return size; return size;
} }
// creates an empty file filename, returns true on success // creates an empty file filename, returns true on success
bool CreateEmptyFile(const std::string &filename) bool CreateEmptyFile(const std::string &filename)
{ {
INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str()); INFO_LOG(COMMON, "CreateEmptyFile: %s", filename.c_str());
if (!FileUtil::IOFile(filename, "wb")) if (!FileUtil::IOFile(filename, "wb"))
{ {
@ -437,7 +437,7 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
#endif #endif
// check for "." and ".." // check for "." and ".."
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
((virtualName[0] == '.') && (virtualName[1] == '.') && ((virtualName[0] == '.') && (virtualName[1] == '.') &&
(virtualName[2] == '\0'))) (virtualName[2] == '\0')))
continue; continue;
entry.virtualName = virtualName; entry.virtualName = virtualName;
@ -452,14 +452,14 @@ u32 ScanDirectoryTree(const std::string &directory, FSTEntry& parentEntry)
foundEntries += (u32)entry.size; foundEntries += (u32)entry.size;
} }
else else
{ // is a file { // is a file
entry.isDirectory = false; entry.isDirectory = false;
entry.size = GetSize(entry.physicalName.c_str()); entry.size = GetSize(entry.physicalName.c_str());
} }
++foundEntries; ++foundEntries;
// Push into the tree // Push into the tree
parentEntry.children.push_back(entry); parentEntry.children.push_back(entry);
#ifdef _WIN32 #ifdef _WIN32
} while (FindNextFile(hFind, &ffd) != 0); } while (FindNextFile(hFind, &ffd) != 0);
FindClose(hFind); FindClose(hFind);
#else #else
@ -504,7 +504,7 @@ bool DeleteDirRecursively(const std::string &directory)
// check for "." and ".." // check for "." and ".."
if (((virtualName[0] == '.') && (virtualName[1] == '\0')) || if (((virtualName[0] == '.') && (virtualName[1] == '\0')) ||
((virtualName[0] == '.') && (virtualName[1] == '.') && ((virtualName[0] == '.') && (virtualName[1] == '.') &&
(virtualName[2] == '\0'))) (virtualName[2] == '\0')))
continue; continue;
@ -540,7 +540,7 @@ bool DeleteDirRecursively(const std::string &directory)
closedir(dirp); closedir(dirp);
#endif #endif
FileUtil::DeleteDir(directory); FileUtil::DeleteDir(directory);
return true; return true;
} }
@ -585,7 +585,7 @@ void CopyDir(const std::string &source_path, const std::string &dest_path)
std::string GetCurrentDir() std::string GetCurrentDir()
{ {
char *dir; char *dir;
// Get the current working directory (getcwd uses malloc) // Get the current working directory (getcwd uses malloc)
if (!(dir = __getcwd(NULL, 0))) { if (!(dir = __getcwd(NULL, 0))) {
ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s", ERROR_LOG(COMMON, "GetCurrentDirectory failed: %s",
@ -604,7 +604,7 @@ bool SetCurrentDir(const std::string &directory)
} }
#if defined(__APPLE__) #if defined(__APPLE__)
std::string GetBundleDirectory() std::string GetBundleDirectory()
{ {
CFURLRef BundleRef; CFURLRef BundleRef;
char AppBundlePath[MAXPATHLEN]; char AppBundlePath[MAXPATHLEN];
@ -666,8 +666,8 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR)) if (FileUtil::Exists(ROOT_DIR DIR_SEP USERDATA_DIR))
paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP; paths[D_USER_IDX] = ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP;
else else
paths[D_USER_IDX] = std::string(getenv("HOME") ? paths[D_USER_IDX] = std::string(getenv("HOME") ?
getenv("HOME") : getenv("PWD") ? getenv("HOME") : getenv("PWD") ?
getenv("PWD") : "") + DIR_SEP EMU_DATA_DIR DIR_SEP; getenv("PWD") : "") + DIR_SEP EMU_DATA_DIR DIR_SEP;
#endif #endif
@ -749,7 +749,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG; paths[F_MAINLOG_IDX] = paths[D_LOGS_IDX] + MAIN_LOG;
} }
} }
return paths[DirIDX]; return paths[DirIDX];
} }
@ -762,7 +762,7 @@ const std::string& GetUserPath(const unsigned int DirIDX, const std::string &new
// if (!FileUtil::Exists(dir)) // if (!FileUtil::Exists(dir))
// dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/"; // dir = SHARED_USER_DIR THEMES_DIR "/" + theme_name + "/";
//#endif //#endif
// //
// return dir; // return dir;
//} //}

View File

@ -16,33 +16,33 @@
// User directory indices for GetUserPath // User directory indices for GetUserPath
enum { enum {
D_USER_IDX, D_USER_IDX,
D_ROOT_IDX, D_ROOT_IDX,
D_CONFIG_IDX, D_CONFIG_IDX,
D_GAMECONFIG_IDX, D_GAMECONFIG_IDX,
D_MAPS_IDX, D_MAPS_IDX,
D_CACHE_IDX, D_CACHE_IDX,
D_SHADERCACHE_IDX, D_SHADERCACHE_IDX,
D_SHADERS_IDX, D_SHADERS_IDX,
D_STATESAVES_IDX, D_STATESAVES_IDX,
D_SCREENSHOTS_IDX, D_SCREENSHOTS_IDX,
D_SDMC_IDX, D_SDMC_IDX,
D_HIRESTEXTURES_IDX, D_HIRESTEXTURES_IDX,
D_DUMP_IDX, D_DUMP_IDX,
D_DUMPFRAMES_IDX, D_DUMPFRAMES_IDX,
D_DUMPAUDIO_IDX, D_DUMPAUDIO_IDX,
D_DUMPTEXTURES_IDX, D_DUMPTEXTURES_IDX,
D_DUMPDSP_IDX, D_DUMPDSP_IDX,
D_LOGS_IDX, D_LOGS_IDX,
D_SYSCONF_IDX, D_SYSCONF_IDX,
F_EMUCONFIG_IDX, F_EMUCONFIG_IDX,
F_DEBUGGERCONFIG_IDX, F_DEBUGGERCONFIG_IDX,
F_LOGGERCONFIG_IDX, F_LOGGERCONFIG_IDX,
F_MAINLOG_IDX, F_MAINLOG_IDX,
F_RAMDUMP_IDX, F_RAMDUMP_IDX,
F_ARAMDUMP_IDX, F_ARAMDUMP_IDX,
F_SYSCONF_IDX, F_SYSCONF_IDX,
NUM_PATH_INDICES NUM_PATH_INDICES
}; };
namespace FileUtil namespace FileUtil
@ -51,11 +51,11 @@ namespace FileUtil
// FileSystem tree node/ // FileSystem tree node/
struct FSTEntry struct FSTEntry
{ {
bool isDirectory; bool isDirectory;
u64 size; // file length or number of entries from children u64 size; // file length or number of entries from children
std::string physicalName; // name on disk std::string physicalName; // name on disk
std::string virtualName; // name in FST names table std::string virtualName; // name in FST names table
std::vector<FSTEntry> children; std::vector<FSTEntry> children;
}; };
// Returns true if file filename exists // Returns true if file filename exists
@ -148,86 +148,86 @@ void SplitFilename83(const std::string& filename, std::array<char, 9>& short_nam
class IOFile : public NonCopyable class IOFile : public NonCopyable
{ {
public: public:
IOFile(); IOFile();
IOFile(std::FILE* file); IOFile(std::FILE* file);
IOFile(const std::string& filename, const char openmode[]); IOFile(const std::string& filename, const char openmode[]);
~IOFile(); ~IOFile();
IOFile(IOFile&& other); IOFile(IOFile&& other);
IOFile& operator=(IOFile&& other); IOFile& operator=(IOFile&& other);
void Swap(IOFile& other); void Swap(IOFile& other);
bool Open(const std::string& filename, const char openmode[]); bool Open(const std::string& filename, const char openmode[]);
bool Close(); bool Close();
template <typename T> template <typename T>
size_t ReadArray(T* data, size_t length) size_t ReadArray(T* data, size_t length)
{ {
if (!IsOpen()) { if (!IsOpen()) {
m_good = false; m_good = false;
return -1; return -1;
} }
size_t items_read = std::fread(data, sizeof(T), length, m_file); size_t items_read = std::fread(data, sizeof(T), length, m_file);
if (items_read != length) if (items_read != length)
m_good = false; m_good = false;
return items_read; return items_read;
} }
template <typename T> template <typename T>
size_t WriteArray(const T* data, size_t length) size_t WriteArray(const T* data, size_t length)
{ {
if (!IsOpen()) { if (!IsOpen()) {
m_good = false; m_good = false;
return -1; return -1;
} }
size_t items_written = std::fwrite(data, sizeof(T), length, m_file); size_t items_written = std::fwrite(data, sizeof(T), length, m_file);
if (items_written != length) if (items_written != length)
m_good = false; m_good = false;
return items_written; return items_written;
} }
size_t ReadBytes(void* data, size_t length) size_t ReadBytes(void* data, size_t length)
{ {
return ReadArray(reinterpret_cast<char*>(data), length); return ReadArray(reinterpret_cast<char*>(data), length);
} }
size_t WriteBytes(const void* data, size_t length) size_t WriteBytes(const void* data, size_t length)
{ {
return WriteArray(reinterpret_cast<const char*>(data), length); return WriteArray(reinterpret_cast<const char*>(data), length);
} }
bool IsOpen() { return NULL != m_file; } bool IsOpen() { return NULL != m_file; }
// m_good is set to false when a read, write or other function fails // m_good is set to false when a read, write or other function fails
bool IsGood() { return m_good; } bool IsGood() { return m_good; }
operator void*() { return m_good ? m_file : NULL; } operator void*() { return m_good ? m_file : NULL; }
std::FILE* ReleaseHandle(); std::FILE* ReleaseHandle();
std::FILE* GetHandle() { return m_file; } std::FILE* GetHandle() { return m_file; }
void SetHandle(std::FILE* file); void SetHandle(std::FILE* file);
bool Seek(s64 off, int origin); bool Seek(s64 off, int origin);
u64 Tell(); u64 Tell();
u64 GetSize(); u64 GetSize();
bool Resize(u64 size); bool Resize(u64 size);
bool Flush(); bool Flush();
// clear error state // clear error state
void Clear() { m_good = true; std::clearerr(m_file); } void Clear() { m_good = true; std::clearerr(m_file); }
std::FILE* m_file; std::FILE* m_file;
bool m_good; bool m_good;
private: private:
IOFile(IOFile&); IOFile(IOFile&);
IOFile& operator=(IOFile& other); IOFile& operator=(IOFile& other);
}; };
} // namespace } // namespace
@ -237,8 +237,8 @@ template <typename T>
void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode) void OpenFStream(T& fstream, const std::string& filename, std::ios_base::openmode openmode)
{ {
#ifdef _WIN32 #ifdef _WIN32
fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode); fstream.open(Common::UTF8ToTStr(filename).c_str(), openmode);
#else #else
fstream.open(filename.c_str(), openmode); fstream.open(filename.c_str(), openmode);
#endif #endif
} }

View File

@ -115,15 +115,15 @@ inline u64 getblock(const u64 * p, int i)
inline void bmix64(u64 & h1, u64 & h2, u64 & k1, u64 & k2, u64 & c1, u64 & c2) inline void bmix64(u64 & h1, u64 & h2, u64 & k1, u64 & k2, u64 & c1, u64 & c2)
{ {
k1 *= c1; k1 *= c1;
k1 = _rotl64(k1,23); k1 = _rotl64(k1,23);
k1 *= c2; k1 *= c2;
h1 ^= k1; h1 ^= k1;
h1 += h2; h1 += h2;
h2 = _rotl64(h2,41); h2 = _rotl64(h2,41);
k2 *= c2; k2 *= c2;
k2 = _rotl64(k2,23); k2 = _rotl64(k2,23);
k2 *= c1; k2 *= c1;
h2 ^= k2; h2 ^= k2;
@ -250,7 +250,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples)
} }
/* /*
* NOTE: This hash function is used for custom texture loading/dumping, so * NOTE: This hash function is used for custom texture loading/dumping, so
* it should not be changed, which would require all custom textures to be * it should not be changed, which would require all custom textures to be
* recalculated for their new hash values. If the hashing function is * recalculated for their new hash values. If the hashing function is
@ -273,7 +273,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
u64 k = data[0]; u64 k = data[0];
data+=Step; data+=Step;
k *= m; k *= m;
k ^= k >> r; k ^= k >> r;
k *= m; k *= m;
h ^= k; h ^= k;
h *= m; h *= m;
@ -292,13 +292,13 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
case 1: h ^= u64(data2[0]); case 1: h ^= u64(data2[0]);
h *= m; h *= m;
}; };
h ^= h >> r; h ^= h >> r;
h *= m; h *= m;
h ^= h >> r; h ^= h >> r;
return h; return h;
} }
#else #else
// CRC32 hash using the SSE4.2 instruction // CRC32 hash using the SSE4.2 instruction
u64 GetCRC32(const u8 *src, int len, u32 samples) u64 GetCRC32(const u8 *src, int len, u32 samples)
@ -351,15 +351,15 @@ inline u32 fmix32(u32 h)
inline void bmix32(u32 & h1, u32 & h2, u32 & k1, u32 & k2, u32 & c1, u32 & c2) inline void bmix32(u32 & h1, u32 & h2, u32 & k1, u32 & k2, u32 & c1, u32 & c2)
{ {
k1 *= c1; k1 *= c1;
k1 = _rotl(k1,11); k1 = _rotl(k1,11);
k1 *= c2; k1 *= c2;
h1 ^= k1; h1 ^= k1;
h1 += h2; h1 += h2;
h2 = _rotl(h2,17); h2 = _rotl(h2,17);
k2 *= c2; k2 *= c2;
k2 = _rotl(k2,11); k2 = _rotl(k2,11);
k2 *= c1; k2 *= c1;
h2 ^= k2; h2 ^= k2;
@ -405,7 +405,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
//---------- //----------
// tail // tail
const u8 * tail = (const u8*)(data + nblocks*8); const u8 * tail = (const u8*)(data + nblocks*8);
u32 k1 = 0; u32 k1 = 0;
@ -439,7 +439,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples)
out[0] = h1; out[0] = h1;
out[1] = h2; out[1] = h2;
return *((u64 *)&out); return *((u64 *)&out);
} }
@ -463,11 +463,11 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
{ {
u64 k = data[0]; u64 k = data[0];
data+=Step; data+=Step;
k *= m; k *= m;
k ^= k >> r; k ^= k >> r;
k *= m; k *= m;
h ^= k; h ^= k;
h *= m; h *= m;
} }
const u8 * data2 = (const u8*)end; const u8 * data2 = (const u8*)end;
@ -483,7 +483,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples)
case 1: h ^= u64(data2[0]); case 1: h ^= u64(data2[0]);
h *= m; h *= m;
}; };
h ^= h >> r; h ^= h >> r;
h *= m; h *= m;
h ^= h >> r; h ^= h >> r;

View File

@ -64,7 +64,7 @@ public:
m_file.seekg(0, std::ios::beg); m_file.seekg(0, std::ios::beg);
std::fstream::pos_type start_pos = m_file.tellg(); std::fstream::pos_type start_pos = m_file.tellg();
std::streamoff file_size = end_pos - start_pos; std::streamoff file_size = end_pos - start_pos;
if (m_file.is_open() && ValidateHeader()) if (m_file.is_open() && ValidateHeader())
{ {
// good header, read some key/value pairs // good header, read some key/value pairs
@ -87,7 +87,7 @@ public:
// read key/value and pass to reader // read key/value and pass to reader
if (Read(&key) && if (Read(&key) &&
Read(value, value_size) && Read(value, value_size) &&
Read(&entry_number) && Read(&entry_number) &&
entry_number == m_num_entries+1) entry_number == m_num_entries+1)
{ {
@ -115,7 +115,7 @@ public:
WriteHeader(); WriteHeader();
return 0; return 0;
} }
void Sync() void Sync()
{ {
m_file.flush(); m_file.flush();

View File

@ -11,7 +11,7 @@
enum { enum {
OS_LEVEL, // Printed by the emulated operating system OS_LEVEL, // Printed by the emulated operating system
NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports. NOTICE_LEVEL, // VERY important information that is NOT errors. Like startup and OSReports.
ERROR_LEVEL, // Critical errors ERROR_LEVEL, // Critical errors
WARNING_LEVEL, // Something is suspicious. WARNING_LEVEL, // Something is suspicious.
INFO_LEVEL, // General information. INFO_LEVEL, // General information.
DEBUG_LEVEL, // Detailed debugging - might make things slow. DEBUG_LEVEL, // Detailed debugging - might make things slow.
@ -46,7 +46,7 @@ enum LOG_TYPE {
MEMMAP, MEMMAP,
MEMCARD_MANAGER, MEMCARD_MANAGER,
OSREPORT, OSREPORT,
PAD, PAD,
PROCESSORINTERFACE, PROCESSORINTERFACE,
PIXELENGINE, PIXELENGINE,
SERIALINTERFACE, SERIALINTERFACE,
@ -89,7 +89,7 @@ enum LOG_LEVELS {
} // namespace } // namespace
void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line, void GenericLog(LOGTYPES_LEVELS level, LOGTYPES_TYPE type, const char*file, int line,
const char* function, const char* fmt, ...) const char* function, const char* fmt, ...)
#ifdef __GNUC__ #ifdef __GNUC__
__attribute__((format(printf, 6, 7))) __attribute__((format(printf, 6, 7)))

View File

@ -9,7 +9,7 @@
#include "common/timer.h" #include "common/timer.h"
#include "common/thread.h" #include "common/thread.h"
void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* function, const char* fmt, ...) const char* function, const char* fmt, ...)
{ {
va_list args; va_list args;
@ -112,7 +112,7 @@ LogManager::~LogManager()
delete m_debuggerLog; delete m_debuggerLog;
} }
void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file,
int line, const char* function, const char *fmt, va_list args) int line, const char* function, const char *fmt, va_list args)
{ {
char temp[MAX_MSGLEN]; char temp[MAX_MSGLEN];
@ -125,11 +125,11 @@ void LogManager::Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const
Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args); Common::CharArrayFromFormatV(temp, MAX_MSGLEN, fmt, args);
static const char level_to_char[7] = "ONEWID"; static const char level_to_char[7] = "ONEWID";
sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line, sprintf(msg, "%s %s:%u %c[%s] %s: %s\n", Common::Timer::GetTimeFormatted().c_str(), file, line,
level_to_char[(int)level], log->GetShortName(), function, temp); level_to_char[(int)level], log->GetShortName(), function, temp);
#ifdef ANDROID #ifdef ANDROID
Host_SysMessage(msg); Host_SysMessage(msg);
#endif #endif
log->Trigger(level, msg); log->Trigger(level, msg);
} }

View File

@ -54,7 +54,7 @@ class LogContainer
{ {
public: public:
LogContainer(const char* shortName, const char* fullName, bool enable = false); LogContainer(const char* shortName, const char* fullName, bool enable = false);
const char* GetShortName() const { return m_shortName; } const char* GetShortName() const { return m_shortName; }
const char* GetFullName() const { return m_fullName; } const char* GetFullName() const { return m_fullName; }
@ -98,7 +98,7 @@ public:
static u32 GetMaxLevel() { return LogTypes::MAX_LOGLEVEL; } static u32 GetMaxLevel() { return LogTypes::MAX_LOGLEVEL; }
void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line, void Log(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, const char* file, int line,
const char* function, const char *fmt, va_list args); const char* function, const char *fmt, va_list args);
void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level) void SetLogLevel(LogTypes::LOG_TYPE type, LogTypes::LOG_LEVELS level)

View File

@ -18,7 +18,7 @@ u32 ClassifyDouble(double dvalue)
value.d = dvalue; value.d = dvalue;
u64 sign = value.i & DOUBLE_SIGN; u64 sign = value.i & DOUBLE_SIGN;
u64 exp = value.i & DOUBLE_EXP; u64 exp = value.i & DOUBLE_EXP;
if (exp > DOUBLE_ZERO && exp < DOUBLE_EXP) if (exp > DOUBLE_ZERO && exp < DOUBLE_EXP)
{ {
// Nice normalized number. // Nice normalized number.
return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN; return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN;
@ -58,7 +58,7 @@ u32 ClassifyFloat(float fvalue)
value.f = fvalue; value.f = fvalue;
u32 sign = value.i & FLOAT_SIGN; u32 sign = value.i & FLOAT_SIGN;
u32 exp = value.i & FLOAT_EXP; u32 exp = value.i & FLOAT_EXP;
if (exp > FLOAT_ZERO && exp < FLOAT_EXP) if (exp > FLOAT_ZERO && exp < FLOAT_EXP)
{ {
// Nice normalized number. // Nice normalized number.
return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN; return sign ? PPC_FPCLASS_NN : PPC_FPCLASS_PN;
@ -77,13 +77,13 @@ u32 ClassifyFloat(float fvalue)
// Denormalized number. // Denormalized number.
return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD; return sign ? PPC_FPCLASS_ND : PPC_FPCLASS_PD;
} }
} }
else if (exp) else if (exp)
{ {
// Infinite // Infinite
return sign ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF; return sign ? PPC_FPCLASS_NINF : PPC_FPCLASS_PINF;
} }
else else
{ {
//Zero //Zero
return sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ; return sign ? PPC_FPCLASS_NZ : PPC_FPCLASS_PZ;
@ -143,7 +143,7 @@ void Matrix33::RotateY(Matrix33 &mtx, float rad)
mtx.data[0] = c; mtx.data[0] = c;
mtx.data[2] = s; mtx.data[2] = s;
mtx.data[4] = 1; mtx.data[4] = 1;
mtx.data[6] = -s; mtx.data[6] = -s;
mtx.data[8] = c; mtx.data[8] = c;
} }

View File

@ -38,7 +38,7 @@ void* globalbase = NULL;
// Hopefully this ABI will never change... // Hopefully this ABI will never change...
#define ASHMEM_DEVICE "/dev/ashmem" #define ASHMEM_DEVICE "/dev/ashmem"
/* /*
* ashmem_create_region - creates a new ashmem region and returns the file * ashmem_create_region - creates a new ashmem region and returns the file
@ -272,11 +272,11 @@ u8* MemArena::Find4GBBase()
// yeah, this could also be done in like two bitwise ops... // yeah, this could also be done in like two bitwise ops...
#define SKIP(a_flags, b_flags) #define SKIP(a_flags, b_flags)
// if (!(a_flags & MV_WII_ONLY) && (b_flags & MV_WII_ONLY)) //if (!(a_flags & MV_WII_ONLY) && (b_flags & MV_WII_ONLY))
// continue; // continue;
// if (!(a_flags & MV_FAKE_VMEM) && (b_flags & MV_FAKE_VMEM)) //if (!(a_flags & MV_FAKE_VMEM) && (b_flags & MV_FAKE_VMEM))
// continue; // continue;
static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 flags, MemArena *arena) { static bool Memory_TryBase(u8 *base, const MemoryView *views, int num_views, u32 flags, MemArena *arena) {
// OK, we know where to find free space. Now grab it! // OK, we know where to find free space. Now grab it!

View File

@ -47,7 +47,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
// printf("Mapped executable memory at %p (size %ld)\n", ptr, // printf("Mapped executable memory at %p (size %ld)\n", ptr,
// (unsigned long)size); // (unsigned long)size);
#ifdef _WIN32 #ifdef _WIN32
if (ptr == nullptr) if (ptr == nullptr)
{ {
@ -55,7 +55,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
if (ptr == MAP_FAILED) if (ptr == MAP_FAILED)
{ {
ptr = nullptr; ptr = nullptr;
#endif #endif
PanicAlert("Failed to allocate executable memory"); PanicAlert("Failed to allocate executable memory");
} }
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) #if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
@ -127,11 +127,11 @@ void FreeMemoryPages(void* ptr, size_t size)
if (ptr) if (ptr)
{ {
#ifdef _WIN32 #ifdef _WIN32
if (!VirtualFree(ptr, 0, MEM_RELEASE)) if (!VirtualFree(ptr, 0, MEM_RELEASE))
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg()); PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
ptr = NULL; // Is this our responsibility? ptr = NULL; // Is this our responsibility?
#else #else
munmap(ptr, size); munmap(ptr, size);
#endif #endif

View File

@ -15,7 +15,7 @@ enum MSG_TYPE
CRITICAL CRITICAL
}; };
typedef bool (*MsgAlertHandler)(const char* caption, const char* text, typedef bool (*MsgAlertHandler)(const char* caption, const char* text,
bool yes_no, int Style); bool yes_no, int Style);
typedef std::string (*StringTranslator)(const char* text); typedef std::string (*StringTranslator)(const char* text);
@ -31,29 +31,29 @@ void SetEnableAlert(bool enable);
#ifndef GEKKO #ifndef GEKKO
#ifdef _WIN32 #ifdef _WIN32
#define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
#define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
#define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
#define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated. // Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__) #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
#define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__) #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
#define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__) #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
#define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__) #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
#define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__) #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
#else #else
#define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) #define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
#define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) #define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
#define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) #define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
#define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) #define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
#define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) #define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
// Use these macros (that do the same thing) if the message should be translated. // Use these macros (that do the same thing) if the message should be translated.
#define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__) #define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
#define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__) #define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
#define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__) #define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
#define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__) #define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
#define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__) #define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
#endif #endif
#else #else
// GEKKO // GEKKO

View File

@ -121,11 +121,11 @@ std::string ArrayToString(const u8 *data, u32 size, int line_len, bool spaces)
{ {
std::ostringstream oss; std::ostringstream oss;
oss << std::setfill('0') << std::hex; oss << std::setfill('0') << std::hex;
for (int line = 0; size; ++data, --size) for (int line = 0; size; ++data, --size)
{ {
oss << std::setw(2) << (int)*data; oss << std::setw(2) << (int)*data;
if (line_len == ++line) if (line_len == ++line)
{ {
oss << '\n'; oss << '\n';
@ -168,7 +168,7 @@ bool TryParse(const std::string &str, u32 *const output)
errno = 0; errno = 0;
unsigned long value = strtoul(str.c_str(), &endptr, 0); unsigned long value = strtoul(str.c_str(), &endptr, 0);
if (!endptr || *endptr) if (!endptr || *endptr)
return false; return false;
@ -294,7 +294,7 @@ std::string ReplaceAll(std::string result, const std::string& src, const std::st
//#include <string> //#include <string>
//#include <assert.h> //#include <assert.h>
const char HEX2DEC[256] = const char HEX2DEC[256] =
{ {
/* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */
/* 0 */ 16,16,16,16, 16,16,16,16, 16,16,16,16, 16,16,16,16, /* 0 */ 16,16,16,16, 16,16,16,16, 16,16,16,16, 16,16,16,16,
@ -327,7 +327,7 @@ std::string UriDecode(const std::string & sSrc)
const unsigned char * pSrc = (const unsigned char *)sSrc.c_str(); const unsigned char * pSrc = (const unsigned char *)sSrc.c_str();
const size_t SRC_LEN = sSrc.length(); const size_t SRC_LEN = sSrc.length();
const unsigned char * const SRC_END = pSrc + SRC_LEN; const unsigned char * const SRC_END = pSrc + SRC_LEN;
const unsigned char * const SRC_LAST_DEC = SRC_END - 2; // last decodable '%' const unsigned char * const SRC_LAST_DEC = SRC_END - 2; // last decodable '%'
char * const pStart = new char[SRC_LEN]; char * const pStart = new char[SRC_LEN];
char * pEnd = pStart; char * pEnd = pStart;
@ -394,7 +394,7 @@ std::string UriEncode(const std::string & sSrc)
for (; pSrc < SRC_END; ++pSrc) for (; pSrc < SRC_END; ++pSrc)
{ {
if (SAFE[*pSrc]) if (SAFE[*pSrc])
*pEnd++ = *pSrc; *pEnd++ = *pSrc;
else else
{ {
@ -518,9 +518,9 @@ static std::string CodeToUTF8(const char* fromcode, const std::basic_string<T>&
out_buffer.resize(out_buffer_size - dst_bytes); out_buffer.resize(out_buffer_size - dst_bytes);
out_buffer.swap(result); out_buffer.swap(result);
iconv_close(conv_desc); iconv_close(conv_desc);
return result; return result;
} }
@ -576,7 +576,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
out_buffer.swap(result); out_buffer.swap(result);
iconv_close(conv_desc); iconv_close(conv_desc);
return result; return result;
} }

View File

@ -63,7 +63,7 @@ template <typename N>
static bool TryParse(const std::string &str, N *const output) static bool TryParse(const std::string &str, N *const output)
{ {
std::istringstream iss(str); std::istringstream iss(str);
N tmp = 0; N tmp = 0;
if (iss >> tmp) if (iss >> tmp)
{ {

View File

@ -31,7 +31,7 @@ namespace Symbols
{ {
TSymbolsMap::iterator foundSymbolItr; TSymbolsMap::iterator foundSymbolItr;
TSymbol symbol; TSymbol symbol;
foundSymbolItr = g_symbols.find(_address); foundSymbolItr = g_symbols.find(_address);
if (foundSymbolItr != g_symbols.end()) if (foundSymbolItr != g_symbols.end())
{ {
@ -44,7 +44,7 @@ namespace Symbols
{ {
return GetSymbol(_address).name; return GetSymbol(_address).name;
} }
void Remove(u32 _address) void Remove(u32 _address)
{ {
g_symbols.erase(_address); g_symbols.erase(_address);

View File

@ -25,7 +25,7 @@ int CurrentThreadId()
return 0; return 0;
#endif #endif
} }
#ifdef _WIN32 #ifdef _WIN32
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)
@ -52,7 +52,7 @@ void SwitchCurrentThread()
// Sets the debugger-visible name of the current thread. // Sets the debugger-visible name of the current thread.
// Uses undocumented (actually, it is now documented) trick. // Uses undocumented (actually, it is now documented) trick.
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp
// This is implemented much nicer in upcoming msvc++, see: // This is implemented much nicer in upcoming msvc++, see:
// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx // http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
void SetCurrentThreadName(const char* szThreadName) void SetCurrentThreadName(const char* szThreadName)
@ -81,7 +81,7 @@ void SetCurrentThreadName(const char* szThreadName)
__except(EXCEPTION_CONTINUE_EXECUTION) __except(EXCEPTION_CONTINUE_EXECUTION)
{} {}
} }
#else // !WIN32, so must be POSIX threads #else // !WIN32, so must be POSIX threads
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask)

View File

@ -30,7 +30,7 @@ int CurrentThreadId();
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask);
void SetCurrentThreadAffinity(u32 mask); void SetCurrentThreadAffinity(u32 mask);
class Event class Event
{ {
public: public:
@ -135,7 +135,7 @@ private:
const size_t m_count; const size_t m_count;
volatile size_t m_waiting; volatile size_t m_waiting;
}; };
void SleepCurrentThread(int ms); void SleepCurrentThread(int ms);
void SwitchCurrentThread(); // On Linux, this is equal to sleep 1ms void SwitchCurrentThread(); // On Linux, this is equal to sleep 1ms
@ -146,7 +146,7 @@ inline void YieldCPU()
{ {
std::this_thread::yield(); std::this_thread::yield();
} }
void SetCurrentThreadName(const char *name); void SetCurrentThreadName(const char *name);
} // namespace Common } // namespace Common

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project / PPSSPP Project // Copyright 2014 Citra Emulator Project / PPSSPP Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once
@ -12,7 +12,7 @@ template<class IdType>
struct ThreadQueueList { struct ThreadQueueList {
// Number of queues (number of priority levels starting at 0.) // Number of queues (number of priority levels starting at 0.)
static const int NUM_QUEUES = 128; static const int NUM_QUEUES = 128;
// Initial number of threads a single queue can handle. // Initial number of threads a single queue can handle.
static const int INITIAL_CAPACITY = 32; static const int INITIAL_CAPACITY = 32;

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once
@ -63,7 +63,7 @@ public:
* Get the current CPSR register * Get the current CPSR register
* @return Returns the value of the CPSR register * @return Returns the value of the CPSR register
*/ */
virtual u32 GetCPSR() const = 0; virtual u32 GetCPSR() const = 0;
/** /**
* Set the current CPSR register * Set the current CPSR register
@ -98,7 +98,7 @@ public:
} }
protected: protected:
/** /**
* Executes the given number of instructions * Executes the given number of instructions
* @param num_instructions Number of instructions to executes * @param num_instructions Number of instructions to executes

View File

@ -22,8 +22,8 @@ void LoadSymbolMap(std::string filename) {
while (std::getline(infile, line)) { while (std::getline(infile, line)) {
std::istringstream iss(line); std::istringstream iss(line);
if (!(iss >> address_str >> size >> function_name)) { if (!(iss >> address_str >> size >> function_name)) {
break; // Error parsing break; // Error parsing
} }
u32 address = std::stoul(address_str, nullptr, 16); u32 address = std::stoul(address_str, nullptr, 16);

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/arm/skyeye_common/armcpu.h" #include "core/arm/skyeye_common/armcpu.h"
#include "core/arm/skyeye_common/armemu.h" #include "core/arm/skyeye_common/armemu.h"
@ -113,7 +113,7 @@ void ARM_DynCom::ExecuteInstructions(int num_instructions) {
state->NumInstrsToExecute = num_instructions; state->NumInstrsToExecute = num_instructions;
// Dyncom only breaks on instruction dispatch. This only happens on every instruction when // Dyncom only breaks on instruction dispatch. This only happens on every instruction when
// executing one instruction at a time. Otherwise, if a block is being executed, more // executing one instruction at a time. Otherwise, if a block is being executed, more
// instructions may actually be executed than specified. // instructions may actually be executed than specified.
ticks += InterpreterMainLoop(state.get()); ticks += InterpreterMainLoop(state.get());
} }

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/arm/interpreter/arm_interpreter.h" #include "core/arm/interpreter/arm_interpreter.h"
@ -24,7 +24,7 @@ ARM_Interpreter::ARM_Interpreter() {
state->lateabtSig = LOW; state->lateabtSig = LOW;
// Reset the core to initial state // Reset the core to initial state
ARMul_CoProInit(state); ARMul_CoProInit(state);
ARMul_Reset(state); ARMul_Reset(state);
state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext state->NextInstr = RESUME; // NOTE: This will be overwritten by LoadContext
state->Emulate = 3; state->Emulate = 3;

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -41,7 +41,7 @@ struct BaseEvent
s64 time; s64 time;
u64 userdata; u64 userdata;
int type; int type;
// Event *next; // Event *next;
}; };
typedef LinkedListItem<BaseEvent> Event; typedef LinkedListItem<BaseEvent> Event;
@ -249,7 +249,7 @@ void AddEventToQueue(Event* ne)
// This must be run ONLY from within the cpu thread // This must be run ONLY from within the cpu thread
// cyclesIntoFuture may be VERY inaccurate if called from anything else // cyclesIntoFuture may be VERY inaccurate if called from anything else
// than Advance // than Advance
void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata) void ScheduleEvent(s64 cyclesIntoFuture, int event_type, u64 userdata)
{ {
Event *ne = GetNewEvent(); Event *ne = GetNewEvent();
@ -469,8 +469,8 @@ void ProcessFifoWaitEvents()
{ {
if (first->time <= globalTimer) if (first->time <= globalTimer)
{ {
// LOG(TIMER, "[Scheduler] %s (%lld, %lld) ", //LOG(TIMER, "[Scheduler] %s (%lld, %lld) ",
// first->name ? first->name : "?", (u64)globalTimer, (u64)first->time); // first->name ? first->name : "?", (u64)globalTimer, (u64)first->time);
Event* evt = first; Event* evt = first;
first = first->next; first = first->next;
event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time)); event_types[evt->type].callback(evt->userdata, (int)(globalTimer - evt->time));
@ -516,23 +516,23 @@ void Advance()
//currentMIPS->downcount = slicelength; //currentMIPS->downcount = slicelength;
//if (Common::AtomicLoadAcquire(hasTsEvents)) //if (Common::AtomicLoadAcquire(hasTsEvents))
// MoveEvents(); // MoveEvents();
//ProcessFifoWaitEvents(); //ProcessFifoWaitEvents();
//if (!first) //if (!first)
//{ //{
// // WARN_LOG(TIMER, "WARNING - no events in queue. Setting currentMIPS->downcount to 10000"); // // WARN_LOG(TIMER, "WARNING - no events in queue. Setting currentMIPS->downcount to 10000");
// currentMIPS->downcount += 10000; // currentMIPS->downcount += 10000;
//} //}
//else //else
//{ //{
// slicelength = (int)(first->time - globalTimer); // slicelength = (int)(first->time - globalTimer);
// if (slicelength > MAX_SLICE_LENGTH) // if (slicelength > MAX_SLICE_LENGTH)
// slicelength = MAX_SLICE_LENGTH; // slicelength = MAX_SLICE_LENGTH;
// currentMIPS->downcount = slicelength; // currentMIPS->downcount = slicelength;
//} //}
//if (advanceCallback) //if (advanceCallback)
// advanceCallback(cyclesExecuted); // advanceCallback(cyclesExecuted);
} }
void LogPendingEvents() void LogPendingEvents()
@ -550,20 +550,20 @@ void Idle(int maxIdle)
ERROR_LOG(TIME, "Unimplemented function!"); ERROR_LOG(TIME, "Unimplemented function!");
//int cyclesDown = currentMIPS->downcount; //int cyclesDown = currentMIPS->downcount;
//if (maxIdle != 0 && cyclesDown > maxIdle) //if (maxIdle != 0 && cyclesDown > maxIdle)
// cyclesDown = maxIdle; // cyclesDown = maxIdle;
//if (first && cyclesDown > 0) //if (first && cyclesDown > 0)
//{ //{
// int cyclesExecuted = slicelength - currentMIPS->downcount; // int cyclesExecuted = slicelength - currentMIPS->downcount;
// int cyclesNextEvent = (int) (first->time - globalTimer); // int cyclesNextEvent = (int) (first->time - globalTimer);
// if (cyclesNextEvent < cyclesExecuted + cyclesDown) // if (cyclesNextEvent < cyclesExecuted + cyclesDown)
// { // {
// cyclesDown = cyclesNextEvent - cyclesExecuted; // cyclesDown = cyclesNextEvent - cyclesExecuted;
// // Now, now... no time machines, please. // // Now, now... no time machines, please.
// if (cyclesDown < 0) // if (cyclesDown < 0)
// cyclesDown = 0; // cyclesDown = 0;
// } // }
//} //}
//INFO_LOG(TIME, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(g_clock_rate_arm11 * 0.001f)); //INFO_LOG(TIME, "Idle for %i cycles! (%f ms)", cyclesDown, cyclesDown / (float)(g_clock_rate_arm11 * 0.001f));
@ -571,7 +571,7 @@ void Idle(int maxIdle)
//idledCycles += cyclesDown; //idledCycles += cyclesDown;
//currentMIPS->downcount -= cyclesDown; //currentMIPS->downcount -= cyclesDown;
//if (currentMIPS->downcount == 0) //if (currentMIPS->downcount == 0)
// currentMIPS->downcount = -1; // currentMIPS->downcount = -1;
} }
std::string GetScheduledEventsSummary() std::string GetScheduledEventsSummary()
@ -623,4 +623,4 @@ void DoState(PointerWrap &p)
p.Do(idledCycles); p.Do(idledCycles);
} }
} // namespace } // namespace

View File

@ -222,7 +222,7 @@ public:
* @return Size of the archive in bytes * @return Size of the archive in bytes
*/ */
virtual size_t GetSize() const = 0; virtual size_t GetSize() const = 0;
/** /**
* Set the size of the archive in bytes * Set the size of the archive in bytes
*/ */

View File

@ -74,7 +74,7 @@ public:
* @return Size of the archive in bytes * @return Size of the archive in bytes
*/ */
size_t GetSize() const override; size_t GetSize() const override;
/** /**
* Set the size of the archive in bytes * Set the size of the archive in bytes
*/ */

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/common_types.h" #include "common/common_types.h"

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "core/hle/coprocessor.h" #include "core/hle/coprocessor.h"
#include "core/hle/hle.h" #include "core/hle/hle.h"

View File

@ -50,7 +50,7 @@ template<s32 func(u32*, u32, u32, u32, u32, u32)> void Wrap(){
template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() { template<s32 func(s32*, u32*, s32, bool, s64)> void Wrap() {
s32 param_1 = 0; s32 param_1 = 0;
s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2), s32 retval = func(&param_1, (Handle*)Memory::GetPointer(PARAM(1)), (s32)PARAM(2),
(PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0))); (PARAM(3) != 0), (((s64)PARAM(4) << 32) | PARAM(0)));
Core::g_app_core->SetReg(1, (u32)param_1); Core::g_app_core->SetReg(1, (u32)param_1);
FuncReturn(retval); FuncReturn(retval);
@ -103,7 +103,7 @@ template<s32 func(void*)> void Wrap() {
} }
template<s32 func(s64*, u32, void*, s32)> void Wrap(){ template<s32 func(s64*, u32, void*, s32)> void Wrap(){
FuncReturn(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))); (s32)PARAM(3)));
} }

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <vector> #include <vector>
@ -20,7 +20,7 @@ bool g_reschedule = false; ///< If true, immediately reschedules the CPU to a n
const FunctionDef* GetSVCInfo(u32 opcode) { const FunctionDef* GetSVCInfo(u32 opcode) {
u32 func_num = opcode & 0xFFFFFF; // 8 bits u32 func_num = opcode & 0xFFFFFF; // 8 bits
if (func_num > 0xFF) { if (func_num > 0xFF) {
ERROR_LOG(HLE,"unknown svc=0x%02X", func_num); ERROR_LOG(HLE,"unknown svc=0x%02X", func_num);
return nullptr; return nullptr;
} }
return &g_module_db[0].func_table[func_num]; return &g_module_db[0].func_table[func_num];
@ -58,7 +58,7 @@ void RegisterAllModules() {
void Init() { void Init() {
Service::Init(); Service::Init();
RegisterAllModules(); RegisterAllModules();
NOTICE_LOG(HLE, "initialized OK"); NOTICE_LOG(HLE, "initialized OK");

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -11,7 +11,7 @@
// Address arbiters are an underlying kernel synchronization object that can be created/used via // Address arbiters are an underlying kernel synchronization object that can be created/used via
// supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR // supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR
// applications use them as an underlying mechanism to implement thread-safe barriers, events, and // applications use them as an underlying mechanism to implement thread-safe barriers, events, and
// semphores. // semphores.
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Kernel namespace // Kernel namespace

View File

@ -52,14 +52,14 @@ public:
FileSys::Archive* backend; ///< Archive backend interface FileSys::Archive* backend; ///< Archive backend interface
/** /**
* Synchronize kernel object * Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation * @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */
Result SyncRequest(bool* wait) override { Result SyncRequest(bool* wait) override {
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
switch (cmd) { switch (cmd) {
// Read from archive... // Read from archive...
case FileCommand::Read: case FileCommand::Read:
@ -343,7 +343,7 @@ Archive* CreateArchive(Handle& handle, FileSys::Archive* backend, const std::str
archive->backend = backend; archive->backend = backend;
MountArchive(archive); MountArchive(archive);
return archive; return archive;
} }

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <map> #include <map>
#include <algorithm> #include <algorithm>
@ -95,7 +95,7 @@ Result SignalEvent(const Handle handle) {
for (size_t i = 0; i < evt->waiting_threads.size(); ++i) { for (size_t i = 0; i < evt->waiting_threads.size(); ++i) {
ResumeThreadFromWait( evt->waiting_threads[i]); ResumeThreadFromWait( evt->waiting_threads[i]);
// If any thread is signalled awake by this event, assume the event was "caught" and reset // If any thread is signalled awake by this event, assume the event was "caught" and reset
// the event. This will result in the next thread waiting on the event to block. Otherwise, // the event. This will result in the next thread waiting on the event to block. Otherwise,
// the event will not be reset, and the next thread to call WaitSynchronization on it will // the event will not be reset, and the next thread to call WaitSynchronization on it will
// not block. Not sure if this is correct behavior, but it seems to work. // not block. Not sure if this is correct behavior, but it seems to work.

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project / PPSSPP Project // Copyright 2014 Citra Emulator Project / PPSSPP Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/common.h" #include "common/common.h"
@ -68,7 +68,7 @@ void ObjectPool::List() {
for (int i = 0; i < MAX_COUNT; i++) { for (int i = 0; i < MAX_COUNT; i++) {
if (occupied[i]) { if (occupied[i]) {
if (pool[i]) { if (pool[i]) {
INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(), INFO_LOG(KERNEL, "KO %i: %s \"%s\"", i + HANDLE_OFFSET, pool[i]->GetTypeName().c_str(),
pool[i]->GetName().c_str()); pool[i]->GetName().c_str());
} }
} }
@ -110,7 +110,7 @@ void Shutdown() {
*/ */
bool LoadExec(u32 entry_point) { bool LoadExec(u32 entry_point) {
Init(); Init();
Core::g_app_core->SetPC(entry_point); Core::g_app_core->SetPC(entry_point);
// 0x30 is the typical main thread priority I've seen used so far // 0x30 is the typical main thread priority I've seen used so far

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project / PPSSPP Project // Copyright 2014 Citra Emulator Project / PPSSPP Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once
@ -34,7 +34,7 @@ enum class HandleType : u32 {
Archive = 12, Archive = 12,
Directory = 13, Directory = 13,
}; };
enum { enum {
DEFAULT_STACK_SIZE = 0x4000, DEFAULT_STACK_SIZE = 0x4000,
}; };
@ -52,7 +52,7 @@ public:
virtual Kernel::HandleType GetHandleType() const = 0; virtual Kernel::HandleType GetHandleType() const = 0;
/** /**
* Synchronize kernel object * Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation * @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */
@ -139,7 +139,7 @@ public:
} }
bool GetIDType(Handle handle, HandleType* type) const { bool GetIDType(Handle handle, HandleType* type) const {
if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) || if ((handle < HANDLE_OFFSET) || (handle >= HANDLE_OFFSET + MAX_COUNT) ||
!occupied[handle - HANDLE_OFFSET]) { !occupied[handle - HANDLE_OFFSET]) {
ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle); ERROR_LOG(KERNEL, "Kernel: Bad object handle %i (%08x)", handle, handle);
return false; return false;
@ -155,7 +155,7 @@ public:
int GetCount(); int GetCount();
private: private:
enum { enum {
MAX_COUNT = 0x1000, MAX_COUNT = 0x1000,
HANDLE_OFFSET = 0x100, HANDLE_OFFSET = 0x100,

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <map> #include <map>
#include <vector> #include <vector>
@ -28,7 +28,7 @@ public:
std::string name; ///< Name of mutex (optional) std::string name; ///< Name of mutex (optional)
/** /**
* Synchronize kernel object * Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation * @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/common.h" #include "common/common.h"
@ -67,7 +67,7 @@ Handle CreateSharedMemory(const std::string& name) {
* @param other_permissions Memory block map other permissions (specified by SVC field) * @param other_permissions Memory block map other permissions (specified by SVC field)
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */
Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
MemoryPermission other_permissions) { MemoryPermission other_permissions) {
if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) { if (address < Memory::SHARED_MEMORY_VADDR || address >= Memory::SHARED_MEMORY_VADDR_END) {

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once
@ -34,7 +34,7 @@ Handle CreateSharedMemory(const std::string& name="Unknown");
* @param other_permissions Memory block map other permissions (specified by SVC field) * @param other_permissions Memory block map other permissions (specified by SVC field)
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */
Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions, Result MapSharedMemory(u32 handle, u32 address, MemoryPermission permissions,
MemoryPermission other_permissions); MemoryPermission other_permissions);
/** /**

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project / PPSSPP Project // Copyright 2014 Citra Emulator Project / PPSSPP Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <list> #include <list>
@ -113,7 +113,7 @@ void ResetThread(Thread* t, u32 arg, s32 lowest_priority) {
t->context.pc = t->context.reg_15 = t->entry_point; t->context.pc = t->context.reg_15 = t->entry_point;
t->context.sp = t->stack_top; t->context.sp = t->stack_top;
t->context.cpsr = 0x1F; // Usermode t->context.cpsr = 0x1F; // Usermode
// TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a // TODO(bunnei): This instructs the CPU core to start the execution as if it is "resuming" a
// thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be // thread. This is somewhat Sky-Eye specific, and should be re-architected in the future to be
// agnostic of the CPU core. // agnostic of the CPU core.
@ -148,7 +148,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle)
Thread* thread = g_object_pool.GetFast<Thread>(handle); Thread* thread = g_object_pool.GetFast<Thread>(handle);
_assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!");
if (type != thread->wait_type || wait_handle != thread->wait_handle) if (type != thread->wait_type || wait_handle != thread->wait_handle)
return false; return false;
return true; return true;
@ -158,7 +158,7 @@ inline bool VerifyWait(const Handle& handle, WaitType type, Handle wait_handle)
void StopThread(Handle handle, const char* reason) { void StopThread(Handle handle, const char* reason) {
Thread* thread = g_object_pool.GetFast<Thread>(handle); Thread* thread = g_object_pool.GetFast<Thread>(handle);
_assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!"); _assert_msg_(KERNEL, (thread != nullptr), "called, but thread is nullptr!");
ChangeReadyState(thread, false); ChangeReadyState(thread, false);
thread->status = THREADSTATUS_DORMANT; thread->status = THREADSTATUS_DORMANT;
for (size_t i = 0; i < thread->waiting_threads.size(); ++i) { for (size_t i = 0; i < thread->waiting_threads.size(); ++i) {
@ -181,7 +181,7 @@ void ChangeThreadState(Thread* t, ThreadStatus new_status) {
} }
ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0); ChangeReadyState(t, (new_status & THREADSTATUS_READY) != 0);
t->status = new_status; t->status = new_status;
if (new_status == THREADSTATUS_WAIT) { if (new_status == THREADSTATUS_WAIT) {
if (t->wait_type == WAITTYPE_NONE) { if (t->wait_type == WAITTYPE_NONE) {
ERROR_LOG(KERNEL, "Waittype none not allowed"); ERROR_LOG(KERNEL, "Waittype none not allowed");
@ -216,7 +216,7 @@ Handle ArbitrateHighestPriorityThread(u32 arbiter, u32 address) {
/// Arbitrate all threads currently waiting /// Arbitrate all threads currently waiting
void ArbitrateAllThreads(u32 arbiter, u32 address) { void ArbitrateAllThreads(u32 arbiter, u32 address) {
// Iterate through threads, find highest priority thread that is waiting to be arbitrated... // Iterate through threads, find highest priority thread that is waiting to be arbitrated...
for (const auto& handle : thread_queue) { for (const auto& handle : thread_queue) {
@ -238,11 +238,11 @@ void CallThread(Thread* t) {
/// Switches CPU context to that of the specified thread /// Switches CPU context to that of the specified thread
void SwitchContext(Thread* t) { void SwitchContext(Thread* t) {
Thread* cur = GetCurrentThread(); Thread* cur = GetCurrentThread();
// Save context for current thread // Save context for current thread
if (cur) { if (cur) {
SaveContext(cur->context); SaveContext(cur->context);
if (cur->IsRunning()) { if (cur->IsRunning()) {
ChangeReadyState(cur, true); ChangeReadyState(cur, true);
} }
@ -263,7 +263,7 @@ void SwitchContext(Thread* t) {
Thread* NextThread() { Thread* NextThread() {
Handle next; Handle next;
Thread* cur = GetCurrentThread(); Thread* cur = GetCurrentThread();
if (cur && cur->IsRunning()) { if (cur && cur->IsRunning()) {
next = thread_ready_queue.pop_first_better(cur->current_priority); next = thread_ready_queue.pop_first_better(cur->current_priority);
} else { } else {
@ -319,7 +319,7 @@ void DebugThreadQueue() {
Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority, Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 priority,
s32 processor_id, u32 stack_top, int stack_size) { s32 processor_id, u32 stack_top, int stack_size) {
_assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST), _assert_msg_(KERNEL, (priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST),
"CreateThread priority=%d, outside of allowable range!", priority) "CreateThread priority=%d, outside of allowable range!", priority)
Thread* thread = new Thread; Thread* thread = new Thread;
@ -351,7 +351,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
return -1; return -1;
} }
if ((u32)stack_size < 0x200) { if ((u32)stack_size < 0x200) {
ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name, ERROR_LOG(KERNEL, "CreateThread(name=%s): invalid stack_size=0x%08X", name,
stack_size); stack_size);
return -1; return -1;
} }
@ -368,7 +368,7 @@ Handle CreateThread(const char* name, u32 entry_point, s32 priority, u32 arg, s3
return -1; return -1;
} }
Handle handle; Handle handle;
Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top, Thread* thread = CreateThread(handle, name, entry_point, priority, processor_id, stack_top,
stack_size); stack_size);
ResetThread(thread, arg, 0); ResetThread(thread, arg, 0);
@ -423,19 +423,19 @@ Result SetThreadPriority(Handle handle, s32 priority) {
/// Sets up the primary application thread /// Sets up the primary application thread
Handle SetupMainThread(s32 priority, int stack_size) { Handle SetupMainThread(s32 priority, int stack_size) {
Handle handle; Handle handle;
// Initialize new "main" thread // Initialize new "main" thread
Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority, Thread* thread = CreateThread(handle, "main", Core::g_app_core->GetPC(), priority,
THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size); THREADPROCESSORID_0, Memory::SCRATCHPAD_VADDR_END, stack_size);
ResetThread(thread, 0, 0); ResetThread(thread, 0, 0);
// If running another thread already, set it to "ready" state // If running another thread already, set it to "ready" state
Thread* cur = GetCurrentThread(); Thread* cur = GetCurrentThread();
if (cur && cur->IsRunning()) { if (cur && cur->IsRunning()) {
ChangeReadyState(cur, true); ChangeReadyState(cur, true);
} }
// Run new "main" thread // Run new "main" thread
SetCurrentThread(thread); SetCurrentThread(thread);
thread->status = THREADSTATUS_RUNNING; thread->status = THREADSTATUS_RUNNING;
@ -452,12 +452,12 @@ void Reschedule() {
HLE::g_reschedule = false; HLE::g_reschedule = false;
if (next > 0) { if (next > 0) {
INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle()); INFO_LOG(KERNEL, "context switch 0x%08X -> 0x%08X", prev->GetHandle(), next->GetHandle());
SwitchContext(next); SwitchContext(next);
// Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep // Hack - There is no mechanism yet to waken the primary thread if it has been put to sleep
// by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again. // by a simulated VBLANK thread switch. So, we'll just immediately set it to "ready" again.
// This results in the current thread yielding on a VBLANK once, and then it will be // This results in the current thread yielding on a VBLANK once, and then it will be
// immediately placed back in the queue for execution. // immediately placed back in the queue for execution.
if (prev->wait_type == WAITTYPE_VBLANK) { if (prev->wait_type == WAITTYPE_VBLANK) {
ResumeThreadFromWait(prev->GetHandle()); ResumeThreadFromWait(prev->GetHandle());

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project / PPSSPP Project // Copyright 2014 Citra Emulator Project / PPSSPP Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -9,7 +9,7 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace AC_U // Namespace AC_U
// socket service "ac:u" // socket service "ac:u"
namespace AC_U { namespace AC_U {

View File

@ -27,7 +27,7 @@ enum class SignalType : u32 {
void Initialize(Service::Interface* self) { void Initialize(Service::Interface* self) {
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Menu"); // APT menu event handle cmd_buff[3] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Menu"); // APT menu event handle
cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Pause"); // APT pause event handle cmd_buff[4] = Kernel::CreateEvent(RESETTYPE_ONESHOT, "APT_U:Pause"); // APT pause event handle
@ -168,7 +168,7 @@ void AppletUtility(Service::Interface* self) {
cmd_buff[1] = 0; // No error cmd_buff[1] = 0; // No error
WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, " WARN_LOG(KERNEL, "(STUBBED) called unk=0x%08X, buffer1_size=0x%08x, buffer2_size=0x%08x, "
"buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size, "buffer1_addr=0x%08x, buffer2_addr=0x%08x", unk, buffer1_size, buffer2_size,
buffer1_addr, buffer2_addr); buffer1_addr, buffer2_addr);
} }

View File

@ -13,8 +13,8 @@ namespace APT_U {
// Application and title launching service. These services handle signaling for home/power button as // Application and title launching service. These services handle signaling for home/power button as
// well. Only one session for either APT service can be open at a time, normally processes close the // well. Only one session for either APT service can be open at a time, normally processes close the
// service handle immediately once finished using the service. The commands for APT:U and APT:S are // service handle immediately once finished using the service. The commands for APT:U and APT:S are
// exactly the same, however certain commands are only accessible with APT:S(NS module will call // exactly the same, however certain commands are only accessible with APT:S(NS module will call
// svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services. // svcBreak when the command isn't accessible). See http://3dbrew.org/wiki/NS#APT_Services.
/// Interface to "APT:U" service /// Interface to "APT:U" service

View File

@ -21,8 +21,8 @@ namespace BOSS_U {
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable, ARRAY_SIZE(FunctionTable));
} }
Interface::~Interface() { Interface::~Interface() {
} }
} // namespace } // namespace

View File

@ -20,8 +20,8 @@ namespace ERR_F {
Interface::Interface() { Interface::Interface() {
Register(FunctionTable, ARRAY_SIZE(FunctionTable)); Register(FunctionTable, ARRAY_SIZE(FunctionTable));
} }
Interface::~Interface() { Interface::~Interface() {
} }
} // namespace } // namespace

View File

@ -23,5 +23,5 @@ namespace ERR_F {
return "err:f"; return "err:f";
} }
}; };
} // namespace } // namespace

View File

@ -269,7 +269,7 @@ static void IsSdmcDetected(Service::Interface* self) {
cmd_buff[1] = 0; cmd_buff[1] = 0;
cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0; cmd_buff[2] = Settings::values.use_virtual_sd ? 1 : 0;
DEBUG_LOG(KERNEL, "called"); DEBUG_LOG(KERNEL, "called");
} }

View File

@ -15,7 +15,7 @@
namespace HID_User { namespace HID_User {
/** /**
* Structure of a Pad controller state. * Structure of a Pad controller state.
*/ */
struct PadState { struct PadState {

View File

@ -27,7 +27,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x000D0040, nullptr, "SetClamp"}, {0x000D0040, nullptr, "SetClamp"},
{0x000E0000, nullptr, "GetClamp"}, {0x000E0000, nullptr, "GetClamp"},
{0x000F0040, nullptr, "unknown_input1"}, {0x000F0040, nullptr, "unknown_input1"},
{0x00100040, nullptr, "unknown_input2"}, {0x00100040, nullptr, "unknown_input2"},
}; };
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -75,7 +75,7 @@ Interface* Manager::FetchFromPortName(const std::string& port_name) {
/// Initialize ServiceManager /// Initialize ServiceManager
void Init() { void Init() {
g_manager = new Manager; g_manager = new Manager;
g_manager->AddService(new SRV::Interface); g_manager->AddService(new SRV::Interface);
g_manager->AddService(new AC_U::Interface); g_manager->AddService(new AC_U::Interface);
g_manager->AddService(new APT_U::Interface); g_manager->AddService(new APT_U::Interface);

View File

@ -38,7 +38,7 @@ class Manager;
class Interface : public Kernel::Object { class Interface : public Kernel::Object {
friend class Manager; friend class Manager;
public: public:
std::string GetName() const override { return GetPortName(); } std::string GetName() const override { return GetPortName(); }
std::string GetTypeName() const override { return GetPortName(); } std::string GetTypeName() const override { return GetPortName(); }
@ -76,7 +76,7 @@ public:
} }
/** /**
* Synchronize kernel object * Synchronize kernel object
* @param wait Boolean wait set if current thread should wait as a result of sync operation * @param wait Boolean wait set if current thread should wait as a result of sync operation
* @return Result of operation, 0 on success, otherwise error code * @return Result of operation, 0 on success, otherwise error code
*/ */
@ -85,23 +85,23 @@ public:
auto itr = m_functions.find(cmd_buff[0]); auto itr = m_functions.find(cmd_buff[0]);
if (itr == m_functions.end()) { if (itr == m_functions.end()) {
ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X", ERROR_LOG(OSHLE, "unknown/unimplemented function: port=%s, command=0x%08X",
GetPortName().c_str(), cmd_buff[0]); GetPortName().c_str(), cmd_buff[0]);
// TODO(bunnei): Hack - ignore error // TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[1] = 0; cmd_buff[1] = 0;
return 0; return 0;
} }
if (itr->second.func == nullptr) { if (itr->second.func == nullptr) {
ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s", ERROR_LOG(OSHLE, "unimplemented function: port=%s, name=%s",
GetPortName().c_str(), itr->second.name.c_str()); GetPortName().c_str(), itr->second.name.c_str());
// TODO(bunnei): Hack - ignore error // TODO(bunnei): Hack - ignore error
u32* cmd_buff = Service::GetCommandBuffer(); u32* cmd_buff = Service::GetCommandBuffer();
cmd_buff[1] = 0; cmd_buff[1] = 0;
return 0; return 0;
} }
itr->second.func(this); itr->second.func(this);

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <map> #include <map>
@ -30,7 +30,7 @@ enum ControlMemoryOperation {
/// Map application or GSP heap memory /// Map application or GSP heap memory
static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) { static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1, u32 size, u32 permissions) {
DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X", DEBUG_LOG(SVC,"called operation=0x%08X, addr0=0x%08X, addr1=0x%08X, size=%08X, permissions=0x%08X",
operation, addr0, addr1, size, permissions); operation, addr0, addr1, size, permissions);
switch (operation) { switch (operation) {
@ -54,7 +54,7 @@ static Result ControlMemory(u32* out_addr, u32 operation, u32 addr0, u32 addr1,
/// Maps a memory block to specified address /// Maps a memory block to specified address
static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) { static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other_permissions) {
DEBUG_LOG(SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d", DEBUG_LOG(SVC, "called memblock=0x%08X, addr=0x%08X, mypermissions=0x%08X, otherpermission=%d",
handle, addr, permissions, other_permissions); handle, addr, permissions, other_permissions);
Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions); Kernel::MemoryPermission permissions_type = static_cast<Kernel::MemoryPermission>(permissions);
@ -63,7 +63,7 @@ static Result MapMemoryBlock(Handle handle, u32 addr, u32 permissions, u32 other
case Kernel::MemoryPermission::Write: case Kernel::MemoryPermission::Write:
case Kernel::MemoryPermission::ReadWrite: case Kernel::MemoryPermission::ReadWrite:
case Kernel::MemoryPermission::DontCare: case Kernel::MemoryPermission::DontCare:
Kernel::MapSharedMemory(handle, addr, permissions_type, Kernel::MapSharedMemory(handle, addr, permissions_type,
static_cast<Kernel::MemoryPermission>(other_permissions)); static_cast<Kernel::MemoryPermission>(other_permissions));
break; break;
default: default:
@ -115,7 +115,7 @@ static Result WaitSynchronization1(Handle handle, s64 nano_seconds) {
Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle); Kernel::Object* object = Kernel::g_object_pool.GetFast<Kernel::Object>(handle);
DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(), DEBUG_LOG(SVC, "called handle=0x%08X(%s:%s), nanoseconds=%lld", handle, object->GetTypeName().c_str(),
object->GetName().c_str(), nano_seconds); object->GetName().c_str(), nano_seconds);
_assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!"); _assert_msg_(KERNEL, (object != nullptr), "called, but kernel object is nullptr!");
@ -138,7 +138,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
bool unlock_all = true; bool unlock_all = true;
bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated bool wait_infinite = (nano_seconds == -1); // Used to wait until a thread has terminated
DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld", DEBUG_LOG(SVC, "called handle_count=%d, wait_all=%s, nanoseconds=%lld",
handle_count, (wait_all ? "true" : "false"), nano_seconds); handle_count, (wait_all ? "true" : "false"), nano_seconds);
// Iterate through each handle, synchronize kernel object // Iterate through each handle, synchronize kernel object
@ -149,7 +149,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
_assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object " _assert_msg_(KERNEL, (object != nullptr), "called handle=0x%08X, but kernel object "
"is nullptr!", handles[i]); "is nullptr!", handles[i]);
DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(), DEBUG_LOG(SVC, "\thandle[%d] = 0x%08X(%s:%s)", i, handles[i], object->GetTypeName().c_str(),
object->GetName().c_str()); object->GetName().c_str());
Result res = object->WaitSynchronization(&wait); Result res = object->WaitSynchronization(&wait);
@ -183,7 +183,7 @@ static Result CreateAddressArbiter(u32* arbiter) {
/// Arbitrate address /// Arbitrate address
static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) { static Result ArbitrateAddress(Handle arbiter, u32 address, u32 type, u32 value, s64 nanoseconds) {
return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), address, return Kernel::ArbitrateAddress(arbiter, static_cast<Kernel::ArbitrationType>(type), address,
value); value);
} }
@ -195,7 +195,7 @@ static void OutputDebugString(const char* string) {
/// Get resource limit /// Get resource limit
static Result GetResourceLimit(Handle* resource_limit, Handle process) { static Result GetResourceLimit(Handle* resource_limit, Handle process) {
// With regards to proceess values: // With regards to proceess values:
// 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for // 0xFFFF8001 is a handle alias for the current KProcess, and 0xFFFF8000 is a handle alias for
// the current KThread. // the current KThread.
*resource_limit = 0xDEADBEEF; *resource_limit = 0xDEADBEEF;
ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process); ERROR_LOG(SVC, "(UNIMPLEMENTED) called process=0x%08X", process);
@ -227,9 +227,9 @@ static Result CreateThread(u32 priority, u32 entry_point, u32 arg, u32 stack_top
Core::g_app_core->SetReg(1, thread); Core::g_app_core->SetReg(1, thread);
DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, " DEBUG_LOG(SVC, "called entrypoint=0x%08X (%s), arg=0x%08X, stacktop=0x%08X, "
"threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point, "threadpriority=0x%08X, processorid=0x%08X : created handle=0x%08X", entry_point,
name.c_str(), arg, stack_top, priority, processor_id, thread); name.c_str(), arg, stack_top, priority, processor_id, thread);
return 0; return 0;
} }
@ -258,7 +258,7 @@ static Result SetThreadPriority(Handle handle, s32 priority) {
/// Create a mutex /// Create a mutex
static Result CreateMutex(Handle* mutex, u32 initial_locked) { static Result CreateMutex(Handle* mutex, u32 initial_locked) {
*mutex = Kernel::CreateMutex((initial_locked != 0)); *mutex = Kernel::CreateMutex((initial_locked != 0));
DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X", DEBUG_LOG(SVC, "called initial_locked=%s : created handle=0x%08X",
initial_locked ? "true" : "false", *mutex); initial_locked ? "true" : "false", *mutex);
return 0; return 0;
} }
@ -286,7 +286,7 @@ static Result QueryMemory(void* info, void* out, u32 addr) {
/// Create an event /// Create an event
static Result CreateEvent(Handle* evt, u32 reset_type) { static Result CreateEvent(Handle* evt, u32 reset_type) {
*evt = Kernel::CreateEvent((ResetType)reset_type); *evt = Kernel::CreateEvent((ResetType)reset_type);
DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X", DEBUG_LOG(SVC, "called reset_type=0x%08X : created handle=0x%08X",
reset_type, *evt); reset_type, *evt);
return 0; return 0;
} }
@ -301,7 +301,7 @@ static Result DuplicateHandle(Handle* out, Handle handle) {
} }
_assert_msg_(KERNEL, (handle != Kernel::CurrentProcess), _assert_msg_(KERNEL, (handle != Kernel::CurrentProcess),
"(UNIMPLEMENTED) process handle duplication!"); "(UNIMPLEMENTED) process handle duplication!");
// TODO(bunnei): FixMe - This is a hack to return the handle that we were asked to duplicate. // TODO(bunnei): FixMe - This is a hack to return the handle that we were asked to duplicate.
*out = handle; *out = handle;

View File

@ -1,6 +1,6 @@
// Copyright 2014 Citra Emulator Project // Copyright 2014 Citra Emulator Project
// Licensed under GPLv2 // Licensed under GPLv2
// Refer to the license.txt file included. // Refer to the license.txt file included.
#pragma once #pragma once

View File

@ -39,7 +39,7 @@ enum {
template <typename T> template <typename T>
inline void Read(T &var, const u32 addr) { inline void Read(T &var, const u32 addr) {
switch (addr & 0xFFFFF000) { switch (addr & 0xFFFFF000) {
// TODO(bunnei): What is the virtual address of NDMA? // TODO(bunnei): What is the virtual address of NDMA?
// case VADDR_NDMA: // case VADDR_NDMA:
// NDMA::Read(var, addr); // NDMA::Read(var, addr);
@ -57,9 +57,9 @@ inline void Read(T &var, const u32 addr) {
template <typename T> template <typename T>
inline void Write(u32 addr, const T data) { inline void Write(u32 addr, const T data) {
switch (addr & 0xFFFFF000) { switch (addr & 0xFFFFF000) {
// TODO(bunnei): What is the virtual address of NDMA? // TODO(bunnei): What is the virtual address of NDMA?
// case VADDR_NDMA // case VADDR_NDMA
// NDMA::Write(addr, data); // NDMA::Write(addr, data);
// break; // break;

View File

@ -273,13 +273,13 @@ bool ElfReader::LoadInto(u32 vaddr) {
for (int i = 0; i < header->e_phnum; i++) { for (int i = 0; i < header->e_phnum; i++) {
Elf32_Phdr *p = segments + i; Elf32_Phdr *p = segments + i;
INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr, INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr,
p->p_filesz, p->p_memsz); p->p_filesz, p->p_memsz);
if (p->p_type == PT_LOAD) { if (p->p_type == PT_LOAD) {
segment_addr[i] = base_addr + p->p_vaddr; segment_addr[i] = base_addr + p->p_vaddr;
memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz); memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz);
INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i], INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i],
p->p_memsz); p->p_memsz);
} }
} }

View File

@ -118,7 +118,7 @@ AppLoader_NCCH::~AppLoader_NCCH() {
* @return ResultStatus result of function * @return ResultStatus result of function
*/ */
ResultStatus AppLoader_NCCH::LoadExec() const { ResultStatus AppLoader_NCCH::LoadExec() const {
if (!is_loaded) if (!is_loaded)
return ResultStatus::ErrorNotLoaded; return ResultStatus::ErrorNotLoaded;
std::vector<u8> code; std::vector<u8> code;
@ -185,7 +185,7 @@ ResultStatus AppLoader_NCCH::LoadSectionExeFS(const char* name, std::vector<u8>&
return ResultStatus::Error; return ResultStatus::Error;
} }
return ResultStatus::ErrorNotUsed; return ResultStatus::ErrorNotUsed;
} }
/** /**
* Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI) * Loads an NCCH file (e.g. from a CCI, or the first NCCH in a CXI)
@ -210,7 +210,7 @@ ResultStatus AppLoader_NCCH::Load() {
file.Seek(ncch_offset, 0); file.Seek(ncch_offset, 0);
file.ReadBytes(&ncch_header, sizeof(NCCH_Header)); file.ReadBytes(&ncch_header, sizeof(NCCH_Header));
} }
// Verify we are loading the correct file type... // Verify we are loading the correct file type...
if (0 != memcmp(&ncch_header.magic, "NCCH", 4)) if (0 != memcmp(&ncch_header.magic, "NCCH", 4))
return ResultStatus::ErrorInvalidFormat; return ResultStatus::ErrorInvalidFormat;

View File

@ -215,7 +215,7 @@ private:
u32 entry_point; u32 entry_point;
u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header u32 ncch_offset; // Offset to NCCH header, can be 0 or after NCSD header
u32 exefs_offset; u32 exefs_offset;
NCCH_Header ncch_header; NCCH_Header ncch_header;
ExeFs_Header exefs_header; ExeFs_Header exefs_header;
ExHeader_Header exheader_header; ExHeader_Header exheader_header;

View File

@ -12,14 +12,14 @@ namespace System {
// State of the full emulator // State of the full emulator
enum State { enum State {
STATE_NULL = 0, ///< System is in null state, nothing initialized STATE_NULL = 0, ///< System is in null state, nothing initialized
STATE_IDLE, ///< System is in an initialized state, but not running STATE_IDLE, ///< System is in an initialized state, but not running
STATE_RUNNING, ///< System is running STATE_RUNNING, ///< System is running
STATE_LOADING, ///< System is loading a ROM STATE_LOADING, ///< System is loading a ROM
STATE_HALTED, ///< System is halted (error) STATE_HALTED, ///< System is halted (error)
STATE_STALLED, ///< System is stalled (unused) STATE_STALLED, ///< System is stalled (unused)
STATE_DEBUG, ///< System is in a special debug mode (unused) STATE_DEBUG, ///< System is in a special debug mode (unused)
STATE_DIE ///< System is shutting down STATE_DIE ///< System is shutting down
}; };
extern volatile State g_state; extern volatile State g_state;

View File

@ -318,9 +318,9 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
return; return;
#ifndef HAVE_PNG #ifndef HAVE_PNG
return; return;
#else #else
if (!data) if (!data)
return; return;
// Write data to file // Write data to file

View File

@ -41,7 +41,7 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
// Utility class to log Pica commands. // Utility class to log Pica commands.
struct PicaTrace { struct PicaTrace {
struct Write : public std::pair<u32,u32> { struct Write : public std::pair<u32,u32> {
Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {} Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {}
u32& Id() { return first; } u32& Id() { return first; }
const u32& Id() const { return first; } const u32& Id() const { return first; }

View File

@ -25,7 +25,7 @@ public:
/// Swap buffers (render frame) /// Swap buffers (render frame)
virtual void SwapBuffers() = 0; virtual void SwapBuffers() = 0;
/** /**
* Set the emulator window to use for renderer * Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering * @param window EmuWindow handle to emulator window to use for rendering
*/ */

View File

@ -239,7 +239,7 @@ MathUtil::Rectangle<unsigned> RendererOpenGL::GetViewportExtent() {
MathUtil::Rectangle<unsigned> viewport_extent; MathUtil::Rectangle<unsigned> viewport_extent;
if (window_aspect_ratio > emulation_aspect_ratio) { if (window_aspect_ratio > emulation_aspect_ratio) {
// Window is narrower than the emulation content => apply borders to the top and bottom // Window is narrower than the emulation content => apply borders to the top and bottom
unsigned viewport_height = emulation_aspect_ratio * framebuffer_width; unsigned viewport_height = emulation_aspect_ratio * framebuffer_width;
viewport_extent.left = 0; viewport_extent.left = 0;
viewport_extent.top = (framebuffer_height - viewport_height) / 2; viewport_extent.top = (framebuffer_height - viewport_height) / 2;

View File

@ -20,7 +20,7 @@ namespace VideoCore {
void DumpTGA(std::string filename, short width, short height, u8* raw_data) { void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
TGAHeader hdr = {0, 0, 2, 0, 0, 0, 0, width, height, 24, 0}; TGAHeader hdr = {0, 0, 2, 0, 0, 0, 0, width, height, 24, 0};
FILE* fout = fopen(filename.c_str(), "wb"); FILE* fout = fopen(filename.c_str(), "wb");
fwrite(&hdr, sizeof(TGAHeader), 1, fout); fwrite(&hdr, sizeof(TGAHeader), 1, fout);
for (int y = 0; y < height; y++) { for (int y = 0; y < height; y++) {
@ -30,7 +30,7 @@ void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
putc(raw_data[(3 * (y * width)) + (3 * x) + 2], fout); // r putc(raw_data[(3 * (y * width)) + (3 * x) + 2], fout); // r
} }
} }
fclose(fout); fclose(fout);
} }
} // namespace } // namespace

View File

@ -12,24 +12,24 @@ namespace FormatPrecision {
/// Adjust RGBA8 color with RGBA6 precision /// Adjust RGBA8 color with RGBA6 precision
static inline u32 rgba8_with_rgba6(u32 src) { static inline u32 rgba8_with_rgba6(u32 src) {
u32 color = src; u32 color = src;
color &= 0xFCFCFCFC; color &= 0xFCFCFCFC;
color |= (color >> 6) & 0x03030303; color |= (color >> 6) & 0x03030303;
return color; return color;
} }
/// Adjust RGBA8 color with RGB565 precision /// Adjust RGBA8 color with RGB565 precision
static inline u32 rgba8_with_rgb565(u32 src) { static inline u32 rgba8_with_rgb565(u32 src) {
u32 color = (src & 0xF8FCF8); u32 color = (src & 0xF8FCF8);
color |= (color >> 5) & 0x070007; color |= (color >> 5) & 0x070007;
color |= (color >> 6) & 0x000300; color |= (color >> 6) & 0x000300;
color |= 0xFF000000; color |= 0xFF000000;
return color; return color;
} }
/// Adjust Z24 depth value with Z16 precision /// Adjust Z24 depth value with Z16 precision
static inline u32 z24_with_z16(u32 src) { static inline u32 z24_with_z16(u32 src) {
return (src & 0xFFFF00) | (src >> 16); return (src & 0xFFFF00) | (src >> 16);
} }
} // namespace } // namespace