misc cleanup
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3942 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
43adc4f194
commit
95344be674
|
@ -93,7 +93,8 @@ void CPUInfo::Detect()
|
|||
#ifdef _WIN32
|
||||
#ifdef _M_IX86
|
||||
BOOL f64 = false;
|
||||
OS64bit = IsWow64Process(GetCurrentProcess(), &f64);
|
||||
IsWow64Process(GetCurrentProcess(), &f64);
|
||||
OS64bit = (f64 == TRUE) ? true : false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
#ifndef _SECURE_SCL
|
||||
#error Please define _SECURE_SCL=0 in the project settings
|
||||
#else
|
||||
CompileTimeAssert<_SECURE_SCL==0> x;
|
||||
CompileTimeAssert<_SECURE_SCL==0> EnsureNoSecureSCL;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -115,10 +115,10 @@
|
|||
// Shorts - dirs
|
||||
// User dirs
|
||||
#define FULL_USERDATA_DIR ROOT_DIR DIR_SEP USERDATA_DIR DIR_SEP
|
||||
#define T_FULLUSERDATA_DIR _T(ROOT_DIR) _T(DIR_SEP) _T(USERDATA_DIR) _T(DIR_SEP)
|
||||
#define T_FULLUSERDATA_DIR _T(ROOT_DIR) _T(DIR_SEP) _T(USERDATA_DIR) _T(DIR_SEP)
|
||||
|
||||
#define FULL_GC_USER_DIR FULL_USERDATA_DIR GC_USER_DIR DIR_SEP
|
||||
#define T_FULL_GC_USER_DIR T_FULLUSERDATA_DIR _T(GC_USER_DIR) _T(DIR_SEP)
|
||||
#define T_FULL_GC_USER_DIR T_FULLUSERDATA_DIR _T(GC_USER_DIR) _T(DIR_SEP)
|
||||
|
||||
#define FULL_WII_USER_DIR FULL_USERDATA_DIR WII_USER_DIR DIR_SEP
|
||||
#define FULL_WII_ROOT_DIR FULL_USERDATA_DIR WII_USER_DIR // This is the "root" for Wii fs, so that it may be used with created devices
|
||||
|
|
|
@ -487,10 +487,10 @@ bool DeleteDirRecursively(const char *directory)
|
|||
return true;
|
||||
}
|
||||
|
||||
// Returns the current directory, caller should free
|
||||
const char *GetCurrentDir()
|
||||
// Returns the current directory
|
||||
std::string GetCurrentDir()
|
||||
{
|
||||
const char *dir;
|
||||
char *dir;
|
||||
// Get the current working directory (getcwd uses malloc)
|
||||
if (!(dir = __getcwd(NULL, 0))) {
|
||||
|
||||
|
@ -498,7 +498,9 @@ const char *GetCurrentDir()
|
|||
GetLastErrorMsg());
|
||||
return NULL;
|
||||
}
|
||||
return dir;
|
||||
std::string strDir = dir;
|
||||
free(dir);
|
||||
return strDir;
|
||||
}
|
||||
|
||||
// Sets the current directory to the given directory
|
||||
|
@ -577,14 +579,15 @@ std::string GetSysDirectory()
|
|||
sysDir = GetBundleDirectory();
|
||||
sysDir += DIR_SEP;
|
||||
sysDir += SYSDATA_DIR;
|
||||
sysDir += DIR_SEP;
|
||||
#elif defined __linux__
|
||||
sysDir = SYSDATA_DIR;
|
||||
sysDir += DIR_SEP;
|
||||
// FIXME global install
|
||||
#else
|
||||
sysDir = SYSDATA_DIR;
|
||||
sysDir = FULL_SYSDATA_DIR;
|
||||
#endif
|
||||
|
||||
sysDir += DIR_SEP;
|
||||
INFO_LOG(COMMON, "GetSysDirectory: Setting to %s:", sysDir.c_str());
|
||||
return sysDir;
|
||||
}
|
||||
|
|
|
@ -75,8 +75,8 @@ u32 ScanDirectoryTree(const char *directory, FSTEntry& parentEntry);
|
|||
// deletes the given directory and anything under it. Returns true on success.
|
||||
bool DeleteDirRecursively(const char *directory);
|
||||
|
||||
// Returns the current directory, caller should free
|
||||
const char *GetCurrentDir();
|
||||
// Returns the current directory
|
||||
std::string GetCurrentDir();
|
||||
|
||||
// Set the current directory to given directory
|
||||
bool SetCurrentDir(const char *directory);
|
||||
|
|
|
@ -40,7 +40,7 @@ static const char* ram_temp_file = "/tmp/gc_mem.tmp";
|
|||
void MemArena::GrabLowMemSpace(size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
hMemoryMapping = CreateFileMapping(NULL, NULL, PAGE_READWRITE, 0, (DWORD)(size), _T("All GC Memory"));
|
||||
hMemoryMapping = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, (DWORD)(size), _T("All GC Memory"));
|
||||
#else
|
||||
mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
fd = open(ram_temp_file, O_RDWR | O_CREAT, mode);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define MAP_VARIABLE 0
|
||||
#endif
|
||||
|
||||
// This is purposedely not a full wrapper for virtualalloc/mmap, but it
|
||||
// This is purposely not a full wrapper for virtualalloc/mmap, but it
|
||||
// provides exactly the primitive operations that Dolphin needs.
|
||||
|
||||
void* AllocateExecutableMemory(size_t size, bool low)
|
||||
|
@ -49,7 +49,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
|||
// If this happens, we have to implement a free ram search scheme. ector knows how.
|
||||
}
|
||||
|
||||
return(ptr);
|
||||
return ptr;
|
||||
|
||||
#else
|
||||
void* retval = mmap(0, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
|
@ -65,12 +65,11 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
|||
PanicAlert("Failed to allocate executable memory, errno=%i", errno);
|
||||
}
|
||||
|
||||
return(retval);
|
||||
return retval;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void* AllocateMemoryPages(size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -81,7 +80,7 @@ void* AllocateMemoryPages(size_t size)
|
|||
PanicAlert("Failed to allocate raw memory");
|
||||
}
|
||||
|
||||
return(ptr);
|
||||
return ptr;
|
||||
|
||||
#else
|
||||
void* retval = mmap(0, size, PROT_READ | PROT_WRITE,
|
||||
|
@ -93,43 +92,43 @@ void* AllocateMemoryPages(size_t size)
|
|||
PanicAlert("Failed to allocate raw memory, errno=%i", errno);
|
||||
}
|
||||
|
||||
return(retval);
|
||||
return retval;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FreeMemoryPages(void* ptr, size_t size)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (ptr)
|
||||
{
|
||||
VirtualFree(ptr, 0, MEM_RELEASE);
|
||||
ptr = NULL;
|
||||
if (!VirtualFree(ptr, 0, MEM_RELEASE))
|
||||
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
|
||||
ptr = NULL; // Is this our responsibility?
|
||||
}
|
||||
#else
|
||||
munmap(ptr, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void WriteProtectMemory(void* ptr, size_t size, bool allowExecute)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, 0);
|
||||
DWORD oldValue;
|
||||
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READ : PAGE_READONLY, &oldValue))
|
||||
PanicAlert("WriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
||||
#else
|
||||
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_EXEC) : PROT_READ);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READONLY, 0);
|
||||
DWORD oldValue;
|
||||
if (!VirtualProtect(ptr, size, allowExecute ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE, &oldValue))
|
||||
PanicAlert("UnWriteProtectMemory failed!\n%s", GetLastErrorMsg());
|
||||
#else
|
||||
mprotect(ptr, size, allowExecute ? (PROT_READ | PROT_WRITE | PROT_EXEC) : PROT_WRITE | PROT_READ);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -206,7 +206,10 @@ bool SDCardCreate(u32 disk_size /*in MB*/, char* filename)
|
|||
|
||||
f = fopen(filename, "wb");
|
||||
if (!f)
|
||||
{
|
||||
ERROR_LOG(COMMON, "could not create file '%s', aborting...\n", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
/* here's the layout:
|
||||
*
|
||||
|
@ -246,7 +249,8 @@ bool SDCardCreate(u32 disk_size /*in MB*/, char* filename)
|
|||
|
||||
FailWrite:
|
||||
ERROR_LOG(COMMON, "could not write to '%s', aborting...\n", filename);
|
||||
unlink(filename);
|
||||
if (unlink(filename) < 0)
|
||||
ERROR_LOG(COMMON, "unlink(%s) failed\n%s", filename, GetLastErrorMsg());
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#include "Setup.h"
|
||||
#include "Thread.h"
|
||||
#include "Log.h"
|
||||
#include "Common.h"
|
||||
|
||||
#ifdef USE_BEGINTHREADEX
|
||||
#include <process.h>
|
||||
|
@ -37,7 +37,8 @@ CriticalSection::CriticalSection(int spincount)
|
|||
{
|
||||
if (spincount)
|
||||
{
|
||||
InitializeCriticalSectionAndSpinCount(§ion, spincount);
|
||||
if (!InitializeCriticalSectionAndSpinCount(§ion, spincount))
|
||||
ERROR_LOG(COMMON, "CriticalSection could not be initialized!\n%s", GetLastErrorMsg());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -195,6 +196,8 @@ typedef struct tagTHREADNAME_INFO
|
|||
// Uses undocumented (actually, it is now documented) trick.
|
||||
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtsksettingthreadname.asp
|
||||
|
||||
// This is implemented much nicer in upcoming msvc++, see:
|
||||
// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
|
||||
void SetCurrentThreadName(const TCHAR* szThreadName)
|
||||
{
|
||||
THREADNAME_INFO info;
|
||||
|
|
|
@ -19,10 +19,6 @@
|
|||
#include <string>
|
||||
#include "svnrev.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue