diff options
| -rw-r--r-- | src/common/common_funcs.h | 4 | ||||
| -rw-r--r-- | src/common/memory_util.cpp | 8 | ||||
| -rw-r--r-- | src/common/swap.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/savedata_factory.cpp | 9 |
4 files changed, 16 insertions, 7 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 7cf7b7997..995938d0b 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM) | 7 | #if !defined(ARCHITECTURE_x86_64) && !defined(ARCHITECTURE_ARM) |
| 8 | #include <cstdlib> // for exit | 8 | #include <cstdlib> // for exit |
| 9 | #endif | 9 | #endif |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| @@ -30,7 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | #ifdef ARCHITECTURE_x86_64 | 31 | #ifdef ARCHITECTURE_x86_64 |
| 32 | #define Crash() __asm__ __volatile__("int $3") | 32 | #define Crash() __asm__ __volatile__("int $3") |
| 33 | #elif defined(_M_ARM) | 33 | #elif defined(ARCHITECTURE_ARM) |
| 34 | #define Crash() __asm__ __volatile__("trap") | 34 | #define Crash() __asm__ __volatile__("trap") |
| 35 | #else | 35 | #else |
| 36 | #define Crash() exit(1) | 36 | #define Crash() exit(1) |
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp index 5d89209ed..09462ccee 100644 --- a/src/common/memory_util.cpp +++ b/src/common/memory_util.cpp | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include <sys/mman.h> | 16 | #include <sys/mman.h> |
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) | 19 | #if !defined(_WIN32) && defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT) |
| 20 | #include <unistd.h> | 20 | #include <unistd.h> |
| 21 | #define PAGE_MASK (getpagesize() - 1) | 21 | #define PAGE_MASK (getpagesize() - 1) |
| 22 | #define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) | 22 | #define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK)) |
| @@ -30,7 +30,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { | |||
| 30 | void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); | 30 | void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); |
| 31 | #else | 31 | #else |
| 32 | static char* map_hint = nullptr; | 32 | static char* map_hint = nullptr; |
| 33 | #if defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) | 33 | #if defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT) |
| 34 | // This OS has no flag to enforce allocation below the 4 GB boundary, | 34 | // This OS has no flag to enforce allocation below the 4 GB boundary, |
| 35 | // but if we hint that we want a low address it is very likely we will | 35 | // but if we hint that we want a low address it is very likely we will |
| 36 | // get one. | 36 | // get one. |
| @@ -42,7 +42,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { | |||
| 42 | #endif | 42 | #endif |
| 43 | void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, | 43 | void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC, |
| 44 | MAP_ANON | MAP_PRIVATE | 44 | MAP_ANON | MAP_PRIVATE |
| 45 | #if defined(ARCHITECTURE_X64) && defined(MAP_32BIT) | 45 | #if defined(ARCHITECTURE_x86_64) && defined(MAP_32BIT) |
| 46 | | (low ? MAP_32BIT : 0) | 46 | | (low ? MAP_32BIT : 0) |
| 47 | #endif | 47 | #endif |
| 48 | , | 48 | , |
| @@ -57,7 +57,7 @@ void* AllocateExecutableMemory(size_t size, bool low) { | |||
| 57 | #endif | 57 | #endif |
| 58 | LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); | 58 | LOG_ERROR(Common_Memory, "Failed to allocate executable memory"); |
| 59 | } | 59 | } |
| 60 | #if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT) | 60 | #if !defined(_WIN32) && defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT) |
| 61 | else { | 61 | else { |
| 62 | if (low) { | 62 | if (low) { |
| 63 | map_hint += size; | 63 | map_hint += size; |
diff --git a/src/common/swap.h b/src/common/swap.h index 4a4012d1a..f025f7450 100644 --- a/src/common/swap.h +++ b/src/common/swap.h | |||
| @@ -69,7 +69,7 @@ inline u32 swap32(u32 _data) { | |||
| 69 | inline u64 swap64(u64 _data) { | 69 | inline u64 swap64(u64 _data) { |
| 70 | return _byteswap_uint64(_data); | 70 | return _byteswap_uint64(_data); |
| 71 | } | 71 | } |
| 72 | #elif _M_ARM | 72 | #elif ARCHITECTURE_ARM |
| 73 | inline u16 swap16(u16 _data) { | 73 | inline u16 swap16(u16 _data) { |
| 74 | u32 data = _data; | 74 | u32 data = _data; |
| 75 | __asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data)); | 75 | __asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data)); |
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index d78baf9c3..f3aa213af 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -17,6 +17,15 @@ SaveData_Factory::SaveData_Factory(std::string nand_directory) | |||
| 17 | 17 | ||
| 18 | ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path& path) { | 18 | ResultVal<std::unique_ptr<FileSystemBackend>> SaveData_Factory::Open(const Path& path) { |
| 19 | std::string save_directory = GetFullPath(); | 19 | std::string save_directory = GetFullPath(); |
| 20 | |||
| 21 | if (!FileUtil::Exists(save_directory)) { | ||
| 22 | // TODO(bunnei): This is a work-around to always create a save data directory if it does not | ||
| 23 | // already exist. This is a hack, as we do not understand yet how this works on hardware. | ||
| 24 | // Without a save data directory, many games will assert on boot. This should not have any | ||
| 25 | // bad side-effects. | ||
| 26 | FileUtil::CreateFullPath(save_directory); | ||
| 27 | } | ||
| 28 | |||
| 20 | // Return an error if the save data doesn't actually exist. | 29 | // Return an error if the save data doesn't actually exist. |
| 21 | if (!FileUtil::IsDirectory(save_directory)) { | 30 | if (!FileUtil::IsDirectory(save_directory)) { |
| 22 | // TODO(Subv): Find out correct error code. | 31 | // TODO(Subv): Find out correct error code. |