forked from ShuriZma/suyu
Merge pull request #633 from FearlessTobi/port-defines
Port #3579 from Citra: Clean up architecture-specific defines
This commit is contained in:
commit
04524e76c2
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM)
|
#if !defined(ARCHITECTURE_x86_64) && !defined(ARCHITECTURE_ARM)
|
||||||
#include <cstdlib> // for exit
|
#include <cstdlib> // for exit
|
||||||
#endif
|
#endif
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
#ifdef ARCHITECTURE_x86_64
|
#ifdef ARCHITECTURE_x86_64
|
||||||
#define Crash() __asm__ __volatile__("int $3")
|
#define Crash() __asm__ __volatile__("int $3")
|
||||||
#elif defined(_M_ARM)
|
#elif defined(ARCHITECTURE_ARM)
|
||||||
#define Crash() __asm__ __volatile__("trap")
|
#define Crash() __asm__ __volatile__("trap")
|
||||||
#else
|
#else
|
||||||
#define Crash() exit(1)
|
#define Crash() exit(1)
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT)
|
#if !defined(_WIN32) && defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define PAGE_MASK (getpagesize() - 1)
|
#define PAGE_MASK (getpagesize() - 1)
|
||||||
#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
|
#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
|
||||||
|
@ -30,7 +30,7 @@ void* AllocateExecutableMemory(size_t size, bool low) {
|
||||||
void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
void* ptr = VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
#else
|
#else
|
||||||
static char* map_hint = nullptr;
|
static char* map_hint = nullptr;
|
||||||
#if defined(ARCHITECTURE_X64) && !defined(MAP_32BIT)
|
#if defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT)
|
||||||
// This OS has no flag to enforce allocation below the 4 GB boundary,
|
// This OS has no flag to enforce allocation below the 4 GB boundary,
|
||||||
// but if we hint that we want a low address it is very likely we will
|
// but if we hint that we want a low address it is very likely we will
|
||||||
// get one.
|
// get one.
|
||||||
|
@ -42,7 +42,7 @@ void* AllocateExecutableMemory(size_t size, bool low) {
|
||||||
#endif
|
#endif
|
||||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_ANON | MAP_PRIVATE
|
MAP_ANON | MAP_PRIVATE
|
||||||
#if defined(ARCHITECTURE_X64) && defined(MAP_32BIT)
|
#if defined(ARCHITECTURE_x86_64) && defined(MAP_32BIT)
|
||||||
| (low ? MAP_32BIT : 0)
|
| (low ? MAP_32BIT : 0)
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
|
@ -57,7 +57,7 @@ void* AllocateExecutableMemory(size_t size, bool low) {
|
||||||
#endif
|
#endif
|
||||||
LOG_ERROR(Common_Memory, "Failed to allocate executable memory");
|
LOG_ERROR(Common_Memory, "Failed to allocate executable memory");
|
||||||
}
|
}
|
||||||
#if !defined(_WIN32) && defined(ARCHITECTURE_X64) && !defined(MAP_32BIT)
|
#if !defined(_WIN32) && defined(ARCHITECTURE_x86_64) && !defined(MAP_32BIT)
|
||||||
else {
|
else {
|
||||||
if (low) {
|
if (low) {
|
||||||
map_hint += size;
|
map_hint += size;
|
||||||
|
|
|
@ -69,7 +69,7 @@ inline u32 swap32(u32 _data) {
|
||||||
inline u64 swap64(u64 _data) {
|
inline u64 swap64(u64 _data) {
|
||||||
return _byteswap_uint64(_data);
|
return _byteswap_uint64(_data);
|
||||||
}
|
}
|
||||||
#elif _M_ARM
|
#elif ARCHITECTURE_ARM
|
||||||
inline u16 swap16(u16 _data) {
|
inline u16 swap16(u16 _data) {
|
||||||
u32 data = _data;
|
u32 data = _data;
|
||||||
__asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data));
|
__asm__("rev16 %0, %1\n" : "=l"(data) : "l"(data));
|
||||||
|
|
Loading…
Reference in New Issue