From 6129e1eb7a0e26ca31090554c31312cf21a5713b Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 12 Jan 2014 14:06:00 -0800 Subject: [PATCH] Simplifying macros to fix VS' broken preprocessor. --- src/alloy/backend/ivm/ivm_intcode.cc | 4 ++-- src/xenia/assert.h | 8 +++---- src/xenia/atomic.h | 6 ++--- src/xenia/byte_order.h | 8 +++---- src/xenia/config.h | 2 -- src/xenia/core.h | 2 +- src/xenia/core/crc32.cc | 2 +- src/xenia/core/file.cc | 4 ++-- src/xenia/core/hash.cc | 4 ++-- src/xenia/core/path.cc | 2 +- src/xenia/core/thread.cc | 4 ++-- src/xenia/cpu/xenon_memory.cc | 2 +- src/xenia/debug/protocols/ws/simple_sha1.cc | 2 +- src/xenia/debug/protocols/ws/ws_client.cc | 2 +- src/xenia/gpu/gpu.cc | 6 ++--- src/xenia/gpu/gpu.h | 2 +- src/xenia/hid/hid.cc | 6 ++--- src/xenia/kernel/objects/xthread.cc | 6 ++--- src/xenia/kernel/xboxkrnl_threading.cc | 8 +++---- src/xenia/logging.h | 24 +++++++++---------- src/xenia/platform.cc | 2 +- src/xenia/platform.h | 9 ++----- src/xenia/platform_includes.h | 10 ++++---- src/xenia/string.cc | 2 +- src/xenia/string.h | 6 ++--- src/xenia/types.h | 26 ++++++++++----------- 26 files changed, 76 insertions(+), 83 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index 40fae05a3..cc88228a2 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -2587,7 +2587,7 @@ uint32_t IntCode_MUL_HI_I32_I32(IntCodeState& ics, const IntCode* i) { return IA_NEXT; } uint32_t IntCode_MUL_HI_I64_I64(IntCodeState& ics, const IntCode* i) { -#if !XE_COMPILER(MSVC) +#if !XE_COMPILER_MSVC // GCC can, in theory, do this: __int128 v = (__int128)ics.rf[i->src1_reg].i64 * (__int128)ics.rf[i->src2_reg].i64; @@ -2622,7 +2622,7 @@ uint32_t IntCode_MUL_HI_I32_I32_U(IntCodeState& ics, const IntCode* i) { return IA_NEXT; } uint32_t IntCode_MUL_HI_I64_I64_U(IntCodeState& ics, const IntCode* i) { -#if !XE_COMPILER(MSVC) +#if !XE_COMPILER_MSVC // GCC can, in theory, do this: __int128 v = (__int128)ics.rf[i->src1_reg].i64 * (__int128)ics.rf[i->src2_reg].i64; diff --git a/src/xenia/assert.h b/src/xenia/assert.h index fc4abaf9d..8215bd549 100644 --- a/src/xenia/assert.h +++ b/src/xenia/assert.h @@ -20,7 +20,7 @@ #include -#if 0 && XE_COMPILER(MSVC) && defined(UNICODE) && UNICODE +#if 0 && XE_COMPILER_MSVC && defined(UNICODE) && UNICODE // http://msdn.microsoft.com/en-us/library/b0084kay.aspx #if !defined(__WFILE__) #define WIDEN2(x) L##x @@ -38,7 +38,7 @@ #define __XE_ASSERT(expr) assert(expr) -#if XE_OPTION(ENABLE_ASSERTS) +#if XE_OPTION_ENABLE_ASSERTS #define XEASSERTCORE(expr) __XE_ASSERT(expr) #else #define XEASSERTCORE(expr) XE_EMPTY_MACRO @@ -54,12 +54,12 @@ #define XEASSERTNOTNULL(expr) XEASSERTCORE( (expr) != NULL ) -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC // http://msdn.microsoft.com/en-us/library/bb918086.aspx // TODO(benvanik): if 2010+, use static_assert? // http://msdn.microsoft.com/en-us/library/dd293588.aspx #define XESTATICASSERT(expr, message) _STATIC_ASSERT(expr) -//#elif XE_COMPILER(GNUC) +//#elif XE_COMPILER_GNUC // http://stackoverflow.com/questions/3385515/static-assert-in-c //#define XESTATICASSERT(expr, message) ({ extern int __attribute__((error("assertion failure: '" #expr "' not true - " #message))) compile_time_check(); ((expr)?0:compile_time_check()),0; }) #else diff --git a/src/xenia/atomic.h b/src/xenia/atomic.h index d6fd5fb92..ae483495c 100644 --- a/src/xenia/atomic.h +++ b/src/xenia/atomic.h @@ -17,7 +17,7 @@ // These functions are modeled off of the Apple OSAtomic routines // http://developer.apple.com/library/mac/#documentation/DriversKernelHardware/Reference/libkern_ref/OSAtomic_h/ -#if XE_LIKE(OSX) +#if XE_LIKE_OSX #include #define xe_atomic_inc_32(value) \ @@ -41,7 +41,7 @@ typedef OSQueueHead xe_atomic_stack_t; #define xe_atomic_stack_dequeue(stack, offset) \ OSAtomicDequeue((OSQueueHead*)stack, offset) -#elif XE_LIKE(WIN32) +#elif XE_LIKE_WIN32 #define xe_atomic_inc_32(value) \ InterlockedIncrement((volatile LONG*)value) @@ -73,7 +73,7 @@ XEFORCEINLINE void* xe_atomic_stack_dequeue(xe_atomic_stack_t* stack, } } -#elif XE_LIKE(POSIX) +#elif XE_LIKE_POSIX #define xe_atomic_inc_32(value) \ __sync_add_and_fetch(value, 1) diff --git a/src/xenia/byte_order.h b/src/xenia/byte_order.h index b84044762..10905276f 100644 --- a/src/xenia/byte_order.h +++ b/src/xenia/byte_order.h @@ -14,11 +14,11 @@ #include -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC #define XESWAP16 _byteswap_ushort #define XESWAP32 _byteswap_ulong #define XESWAP64 _byteswap_uint64 -#elif XE_LIKE(OSX) +#elif XE_LIKE_OSX #include #define XESWAP16 OSSwapInt16 #define XESWAP32 OSSwapInt32 @@ -30,7 +30,7 @@ #endif -#if XE_CPU(BIGENDIAN) +#if XE_CPU_BIGENDIAN #define XESWAP16BE(p) (p) #define XESWAP32BE(p) (p) #define XESWAP64BE(p) (p) @@ -47,7 +47,7 @@ #endif -#if XE_CPU(BIGENDIAN) +#if XE_CPU_BIGENDIAN #define XESWAPF32BE(p) (p) #define XESWAPF64BE(p) (p) XEFORCEINLINE float XESWAPF32LE(float value) { diff --git a/src/xenia/config.h b/src/xenia/config.h index 2d11d03f9..b83aa8715 100644 --- a/src/xenia/config.h +++ b/src/xenia/config.h @@ -11,8 +11,6 @@ #define XENIA_CONFIG_H_ -#define XE_OPTION(NAME) (defined XE_OPTION_##NAME && XE_OPTION_##NAME) - // Enable compile-time and runtime-time assertions. #define XE_OPTION_ENABLE_ASSERTS 1 diff --git a/src/xenia/core.h b/src/xenia/core.h index c54c6ebcf..49ce110d5 100644 --- a/src/xenia/core.h +++ b/src/xenia/core.h @@ -29,7 +29,7 @@ namespace xe { #include #include -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #include #endif // WIN32 diff --git a/src/xenia/core/crc32.cc b/src/xenia/core/crc32.cc index 7afb11d0e..ada1ac88d 100644 --- a/src/xenia/core/crc32.cc +++ b/src/xenia/core/crc32.cc @@ -299,7 +299,7 @@ uint32_t xe_crc32(const void* data, size_t length, uint32_t previous_crc) { // Process eight bytes at once (Slicing-by-8). const uint32_t* current = (const uint32_t*)data; while (length >= 8) { -#if XE_CPU(BIGENDIAN) +#if XE_CPU_BIGENDIAN uint32_t one = *current++ ^ XESWAP32(crc); uint32_t two = *current++; crc = xe_crc32_lookup_[0][ two & 0xFF] ^ diff --git a/src/xenia/core/file.cc b/src/xenia/core/file.cc index 126ad40d9..bf240d7f6 100644 --- a/src/xenia/core/file.cc +++ b/src/xenia/core/file.cc @@ -17,7 +17,7 @@ typedef struct xe_file { } xe_file_t; -#if XE_LIKE(WIN32) +#if XE_LIKE_WIN32 #define fseeko _fseeki64 #define ftello _ftelli64 #endif // WIN32 @@ -37,7 +37,7 @@ xe_file_ref xe_file_open(const xe_file_mode mode, const xechar_t *path) { } XEIGNORE(xestrcat(mode_string, XECOUNT(mode_string), XT("b"))); -#if XE_LIKE(WIN32) && XE_WCHAR +#if XE_LIKE_WIN32 && XE_WCHAR XEEXPECTZERO(_wfopen_s((FILE**)&file->handle, path, mode_string)); #else file->handle = fopen(path, mode_string); diff --git a/src/xenia/core/hash.cc b/src/xenia/core/hash.cc index 266d10275..5a9e85256 100644 --- a/src/xenia/core/hash.cc +++ b/src/xenia/core/hash.cc @@ -85,13 +85,13 @@ XEFORCEINLINE uint32_t UNALIGNED_LOAD32(const char *p) { } #endif -#if XE_CPU(BIGENDIAN) +#if XE_CPU_BIGENDIAN #define uint32_t_in_expected_order(x) (XESWAP32(x)) #define uint64_in_expected_order(x) (XESWAP64(x)) #else #define uint32_t_in_expected_order(x) (x) #define uint64_in_expected_order(x) (x) -#endif // XE_CPU(BIGENDIAN) +#endif // XE_CPU_BIGENDIAN #if !defined(LIKELY) #if HAVE_BUILTIN_EXPECT diff --git a/src/xenia/core/path.cc b/src/xenia/core/path.cc index fbf0bd491..6356178f6 100644 --- a/src/xenia/core/path.cc +++ b/src/xenia/core/path.cc @@ -23,7 +23,7 @@ void xe_path_join(const xechar_t* left, const xechar_t* right, void xe_path_get_absolute(const xechar_t* path, xechar_t* out_abs_path, size_t abs_path_size) { -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #if XE_WCHAR _wfullpath(out_abs_path, path, abs_path_size); #else diff --git a/src/xenia/core/thread.cc b/src/xenia/core/thread.cc index 861038890..8a48d8267 100644 --- a/src/xenia/core/thread.cc +++ b/src/xenia/core/thread.cc @@ -49,7 +49,7 @@ void xe_thread_release(xe_thread_ref thread) { xe_ref_release((xe_ref)thread, (xe_ref_dealloc_t)xe_thread_dealloc); } -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 // http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx #pragma pack(push,8) @@ -113,7 +113,7 @@ void xe_thread_join(xe_thread_ref thread) { static void* xe_thread_callback_pthreads(void* param) { xe_thread_t* thread = reinterpret_cast(param); -#if XE_LIKE(OSX) +#if XE_LIKE_OSX XEIGNORE(pthread_setname_np(thread->name)); #else pthread_setname_np(pthread_self(), thread->name); diff --git a/src/xenia/cpu/xenon_memory.cc b/src/xenia/cpu/xenon_memory.cc index 31d0bf7d6..81f817a7a 100644 --- a/src/xenia/cpu/xenon_memory.cc +++ b/src/xenia/cpu/xenon_memory.cc @@ -20,7 +20,7 @@ using namespace xe::cpu; // TODO(benvanik): move xbox.h out #include -#if !XE_PLATFORM(WIN32) +#if !XE_PLATFORM_WIN32 #include #endif // WIN32 diff --git a/src/xenia/debug/protocols/ws/simple_sha1.cc b/src/xenia/debug/protocols/ws/simple_sha1.cc index 797ec7191..868f23a2c 100644 --- a/src/xenia/debug/protocols/ws/simple_sha1.cc +++ b/src/xenia/debug/protocols/ws/simple_sha1.cc @@ -9,7 +9,7 @@ #include -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #include #else #include diff --git a/src/xenia/debug/protocols/ws/ws_client.cc b/src/xenia/debug/protocols/ws/ws_client.cc index 52df46335..64f7fe7d3 100644 --- a/src/xenia/debug/protocols/ws/ws_client.cc +++ b/src/xenia/debug/protocols/ws/ws_client.cc @@ -21,7 +21,7 @@ #include #include -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 // Required for wslay. typedef SSIZE_T ssize_t; #endif // WIN32 diff --git a/src/xenia/gpu/gpu.cc b/src/xenia/gpu/gpu.cc index f6133c1e5..102f2a488 100644 --- a/src/xenia/gpu/gpu.cc +++ b/src/xenia/gpu/gpu.cc @@ -32,7 +32,7 @@ GraphicsSystem* xe::gpu::CreateNop(Emulator* emulator) { } -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #include GraphicsSystem* xe::gpu::CreateD3D11(Emulator* emulator) { return xe::gpu::d3d11::Create(emulator); @@ -43,7 +43,7 @@ GraphicsSystem* xe::gpu::CreateD3D11(Emulator* emulator) { GraphicsSystem* xe::gpu::Create(Emulator* emulator) { if (FLAGS_gpu.compare("nop") == 0) { return CreateNop(emulator); -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 } else if (FLAGS_gpu.compare("d3d11") == 0) { return CreateD3D11(emulator); #endif // WIN32 @@ -51,7 +51,7 @@ GraphicsSystem* xe::gpu::Create(Emulator* emulator) { // Create best available. GraphicsSystem* best = NULL; -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 best = CreateD3D11(emulator); if (best) { return best; diff --git a/src/xenia/gpu/gpu.h b/src/xenia/gpu/gpu.h index 70fc72376..2861d7446 100644 --- a/src/xenia/gpu/gpu.h +++ b/src/xenia/gpu/gpu.h @@ -24,7 +24,7 @@ GraphicsSystem* Create(Emulator* emulator); GraphicsSystem* CreateNop(Emulator* emulator); -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 GraphicsSystem* CreateD3D11(Emulator* emulator); #endif // WIN32 diff --git a/src/xenia/hid/hid.cc b/src/xenia/hid/hid.cc index f55fc3735..9aa58c618 100644 --- a/src/xenia/hid/hid.cc +++ b/src/xenia/hid/hid.cc @@ -21,7 +21,7 @@ DEFINE_string(hid, "any", #include -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #include #endif // WIN32 @@ -32,7 +32,7 @@ InputSystem* xe::hid::Create(Emulator* emulator) { if (FLAGS_hid.compare("nop") == 0) { input_system->AddDriver(xe::hid::nop::Create(input_system)); -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 } else if (FLAGS_hid.compare("xinput") == 0) { input_system->AddDriver(xe::hid::xinput::Create(input_system)); #endif // WIN32 @@ -42,7 +42,7 @@ InputSystem* xe::hid::Create(Emulator* emulator) { // NOTE: in any mode we create as many as we can, falling back to nop. -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 InputDriver* xinput_driver = xe::hid::xinput::Create(input_system); if (xinput_driver) { input_system->AddDriver(xinput_driver); diff --git a/src/xenia/kernel/objects/xthread.cc b/src/xenia/kernel/objects/xthread.cc index 4fc4ec20a..33f5aa378 100644 --- a/src/xenia/kernel/objects/xthread.cc +++ b/src/xenia/kernel/objects/xthread.cc @@ -147,7 +147,7 @@ void XThread::set_name(const char* name) { } name_ = xestrdupa(name); -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 // Do the nasty set for us. #pragma pack(push, 8) typedef struct tagTHREADNAME_INFO { @@ -249,7 +249,7 @@ X_STATUS XThread::Exit(int exit_code) { return X_STATUS_SUCCESS; } -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 static uint32_t __stdcall XThreadStartCallbackWin32(void* param) { XThread* thread = reinterpret_cast(param); @@ -308,7 +308,7 @@ X_STATUS XThread::PlatformCreate() { int result_code; if (creation_params_.creation_flags & X_CREATE_SUSPENDED) { -#if XE_PLATFORM(OSX) +#if XE_PLATFORM_OSX result_code = pthread_create_suspended_np( reinterpret_cast(&thread_handle_), &attr, diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index c72f447fa..07d679664 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -465,7 +465,7 @@ uint32_t xeKeTlsAlloc() { uint32_t tls_index; -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 tls_index = TlsAlloc(); #else pthread_key_t key; @@ -501,7 +501,7 @@ int KeTlsFree(uint32_t tls_index) { int result_code = 0; -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 result_code = TlsFree(tls_index); #else result_code = pthread_key_delete(tls_index) == 0; @@ -531,7 +531,7 @@ uint64_t xeKeTlsGetValue(uint32_t tls_index) { uint64_t value = 0; -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 value = (uint64_t)TlsGetValue(tls_index); #else value = (uint64_t)pthread_getspecific(tls_index); @@ -567,7 +567,7 @@ int xeKeTlsSetValue(uint32_t tls_index, uint64_t tls_value) { int result_code = 0; -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 result_code = TlsSetValue(tls_index, (LPVOID)tls_value); #else result_code = pthread_setspecific(tls_index, (void*)tls_value) == 0; diff --git a/src/xenia/logging.h b/src/xenia/logging.h index 7c1fe00ec..b2430761e 100644 --- a/src/xenia/logging.h +++ b/src/xenia/logging.h @@ -16,7 +16,7 @@ #include -#if XE_COMPILER(GNUC) +#if XE_COMPILER_GNUC #define XE_LOG_LINE_ATTRIBUTE __attribute__ ((format (printf, 5, 6))) #else #define XE_LOG_LINE_ATTRIBUTE @@ -26,7 +26,7 @@ void xe_log_line(const char* file_path, const uint32_t line_number, const char* fmt, ...) XE_LOG_LINE_ATTRIBUTE; #undef XE_LOG_LINE_ATTRIBUTE -#if XE_OPTION(ENABLE_LOGGING) +#if XE_OPTION_ENABLE_LOGGING #define XELOGCORE(level, fmt, ...) xe_log_line( \ XE_CURRENT_FILE, XE_CURRENT_LINE, XE_CURRENT_FUNCTION, level, \ fmt, ##__VA_ARGS__) @@ -34,52 +34,52 @@ void xe_log_line(const char* file_path, const uint32_t line_number, #define XELOGCORE(level, fmt, ...) XE_EMPTY_MACRO #endif // ENABLE_LOGGING -#if XE_OPTION(LOG_ERROR) +#if XE_OPTION_LOG_ERROR #define XELOGE(fmt, ...) XELOGCORE('!', fmt, ##__VA_ARGS__) #else #define XELOGE(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_WARNING) +#if XE_OPTION_LOG_WARNING #define XELOGW(fmt, ...) XELOGCORE('w', fmt, ##__VA_ARGS__) #else #define XELOGW(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_INFO) +#if XE_OPTION_LOG_INFO #define XELOGI(fmt, ...) XELOGCORE('i', fmt, ##__VA_ARGS__) #else #define XELOGI(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_DEBUG) +#if XE_OPTION_LOG_DEBUG #define XELOGD(fmt, ...) XELOGCORE('d', fmt, ##__VA_ARGS__) #else #define XELOGD(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_CPU) +#if XE_OPTION_LOG_CPU #define XELOGCPU(fmt, ...) XELOGCORE('C', fmt, ##__VA_ARGS__) #else #define XELOGCPU(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_SDB) +#if XE_OPTION_LOG_SDB #define XELOGSDB(fmt, ...) XELOGCORE('S', fmt, ##__VA_ARGS__) #else #define XELOGSDB(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_APU) +#if XE_OPTION_LOG_APU #define XELOGAPU(fmt, ...) XELOGCORE('A', fmt, ##__VA_ARGS__) #else #define XELOGAPU(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_GPU) +#if XE_OPTION_LOG_GPU #define XELOGGPU(fmt, ...) XELOGCORE('G', fmt, ##__VA_ARGS__) #else #define XELOGGPU(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_KERNEL) +#if XE_OPTION_LOG_KERNEL #define XELOGKERNEL(fmt, ...) XELOGCORE('K', fmt, ##__VA_ARGS__) #else #define XELOGKERNEL(fmt, ...) XE_EMPTY_MACRO #endif -#if XE_OPTION(LOG_FS) +#if XE_OPTION_LOG_FS #define XELOGFS(fmt, ...) XELOGCORE('F', fmt, ##__VA_ARGS__) #else #define XELOGFS(fmt, ...) XE_EMPTY_MACRO diff --git a/src/xenia/platform.cc b/src/xenia/platform.cc index 1a96f7828..0ecba79df 100644 --- a/src/xenia/platform.cc +++ b/src/xenia/platform.cc @@ -21,7 +21,7 @@ typedef int (*user_main_t)(int argc, xechar_t** argv); } -#if XE_LIKE(WIN32) && defined(UNICODE) && UNICODE +#if XE_LIKE_WIN32 && defined(UNICODE) && UNICODE int xe_main_thunk( int argc, wchar_t* argv[], diff --git a/src/xenia/platform.h b/src/xenia/platform.h index 300a634e8..6edec7692 100644 --- a/src/xenia/platform.h +++ b/src/xenia/platform.h @@ -23,11 +23,6 @@ XE_COMPILER: GNUC | MSVC | INTEL | UNKNOWN XE_CPU: 32BIT | 64BIT | BIGENDIAN | LITTLEENDIAN */ -#define XE_PLATFORM(NAME) (defined XE_PLATFORM_##NAME && XE_PLATFORM_##NAME ) -#define XE_LIKE(NAME) (defined XE_LIKE_##NAME && XE_LIKE_##NAME ) -#define XE_PROFILE(NAME) (defined XE_PROFILE_##NAME && XE_PROFILE_##NAME ) -#define XE_COMPILER(NAME) (defined XE_COMPILER_##NAME && XE_COMPILER_##NAME ) -#define XE_CPU(NAME) (defined XE_CPU_##NAME && XE_CPU_##NAME ) #if defined(__APPLE__) #include @@ -133,13 +128,13 @@ XE_CPU: 32BIT | 64BIT | BIGENDIAN | LITTLEENDIAN #define XE_DEBUG 1 #endif // DEBUG -#if XE_CPU(32BIT) +#if XE_CPU_32BIT #define XE_ALIGNMENT 8 #else #define XE_ALIGNMENT 16 #endif // 32BIT -#if XE_LIKE(WIN32) && defined(UNICODE) && UNICODE +#if XE_LIKE_WIN32 && defined(UNICODE) && UNICODE int xe_main_thunk( int argc, wchar_t* argv[], void* user_main, const char* usage); diff --git a/src/xenia/platform_includes.h b/src/xenia/platform_includes.h index 9dbf186ec..e9d513316 100644 --- a/src/xenia/platform_includes.h +++ b/src/xenia/platform_includes.h @@ -13,7 +13,7 @@ #include -#if XE_PLATFORM(WINCE) || XE_PLATFORM(WIN32) +#if XE_PLATFORM_WINCE || XE_PLATFORM_WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif @@ -24,17 +24,17 @@ #undef max #endif // WINCE || WIN32 -#if XE_PLATFORM(XBOX360) +#if XE_PLATFORM_XBOX360 #include #include #endif // XBOX360 -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC // Disable warning C4068: unknown pragma #pragma warning(disable : 4068) #endif // MSVC -#if XE_LIKE(POSIX) +#if XE_LIKE_POSIX #include #include #endif // POSIX @@ -56,7 +56,7 @@ #include #include -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC #include #include #else diff --git a/src/xenia/string.cc b/src/xenia/string.cc index 369f0eee6..9d90f2952 100644 --- a/src/xenia/string.cc +++ b/src/xenia/string.cc @@ -12,7 +12,7 @@ #include -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 char* xestrcasestra(const char* str, const char* substr) { const size_t len = xestrlena(substr); diff --git a/src/xenia/string.h b/src/xenia/string.h index e0a8512f3..e833118ef 100644 --- a/src/xenia/string.h +++ b/src/xenia/string.h @@ -19,7 +19,7 @@ #define XEInvalidSize ((size_t)(-1)) -#if !XE_LIKE(WIN32) +#if !XE_LIKE_WIN32 int strncpy_s(char* dest, size_t destLength, const char* source, size_t count); #define strcpy_s(dest, destLength, source) !(strcpy(dest, source) == dest + (destLength*0)) #define strcat_s(dest, destLength, source) !(strcat(dest, source) == dest + (destLength*0)) @@ -62,7 +62,7 @@ char* xestrcasestra(const char* str, const char* substr); #define xesnprintfa(buffer, bufferCount, format, ...) _snprintf_s(buffer, bufferCount, bufferCount, format, ##__VA_ARGS__) #define xevsnprintfa(buffer, bufferCount, format, args) vsnprintf(buffer, bufferCount, format, args) -#if XE_PLATFORM(WIN32) && defined(UNICODE) && UNICODE +#if XE_PLATFORM_WIN32 && defined(UNICODE) && UNICODE typedef wchar_t xechar_t; #define XE_WCHAR 1 @@ -115,7 +115,7 @@ typedef char xechar_t; #define XT XETEXT #define XTS XESTRFORMAT -#if XE_LIKE(WIN32) +#if XE_LIKE_WIN32 #define XE_PATH_SEPARATOR ((xechar_t)'\\') #define XE_MAX_PATH _MAX_PATH #else diff --git a/src/xenia/types.h b/src/xenia/types.h index d375857ef..21c54dba2 100644 --- a/src/xenia/types.h +++ b/src/xenia/types.h @@ -39,13 +39,13 @@ using std::tr1::shared_ptr; class name; \ } } } } -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC #define XEASSUME(expr) __analysis_assume(expr) #else #define XEASSUME(expr) #endif // MSVC -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC #define XECDECL __cdecl #else #define XECDECL @@ -61,11 +61,11 @@ using std::tr1::shared_ptr; #define XEEXTERNC_END #endif // __cplusplus -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC // http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx #define XEFORCEINLINE static __forceinline #define XENOINLINE __declspec(noinline) -#elif XE_COMPILER(GNUC) +#elif XE_COMPILER_GNUC // http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html #if (__GNUC__ >= 4) #define XEFORCEINLINE static __inline__ __attribute__((always_inline)) @@ -78,7 +78,7 @@ using std::tr1::shared_ptr; #define XENOINLINE #endif // MSVC -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC #define XEPACKEDSTRUCT(name, value) \ __pragma(pack(push, 1)) struct name##_s value __pragma(pack(pop)); \ typedef struct name##_s name; @@ -87,7 +87,7 @@ using std::tr1::shared_ptr; #define XEPACKEDUNION(name, value) \ __pragma(pack(push, 1)) union name##_s value __pragma(pack(pop)); \ typedef union name##_s name; -#elif XE_COMPILER(GNUC) +#elif XE_COMPILER_GNUC #define XEPACKEDSTRUCT(name, value) \ struct __attribute__((packed)) name #define XEPACKEDSTRUCTANONYMOUS(value) \ @@ -96,11 +96,11 @@ using std::tr1::shared_ptr; union __attribute__((packed)) name #endif // MSVC -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC // http://msdn.microsoft.com/en-us/library/83ythb65.aspx #define XECACHEALIGN __declspec(align(XE_ALIGNMENT)) #define XECACHEALIGN64 __declspec(align(64)) -#elif XE_COMPILER(GNUC) +#elif XE_COMPILER_GNUC // http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html #define XECACHEALIGN __attribute__ ((aligned(XE_ALIGNMENT))) #define XECACHEALIGN64 __attribute__ ((aligned(64))) @@ -110,20 +110,20 @@ using std::tr1::shared_ptr; #endif // MSVC typedef XECACHEALIGN volatile void xe_aligned_void_t; -#if XE_COMPILER(MSVC) +#if XE_COMPILER_MSVC // http://msdn.microsoft.com/en-us/library/ms175773.aspx #define XECOUNT(array) _countof(array) -#elif XE_COMPILER(GNUC) +#elif XE_COMPILER_GNUC #define XECOUNT(array) (sizeof(array) / sizeof(__typeof__(array[0]))) #else #define XECOUNT(array) (sizeof(array) / sizeof(array[0])) #endif // MSVC #if !defined(MIN) -#if XE_COMPILER(GNUC) +#if XE_COMPILER_GNUC #define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); (__a < __b) ? __a : __b; }) #define MAX(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); (__a < __b) ? __b : __a; }) -//#elif XE_COMPILER(MSVC) +//#elif XE_COMPILER_MSVC // TODO(benvanik): experiment with decltype: // http://msdn.microsoft.com/en-us/library/dd537655.aspx #else @@ -134,7 +134,7 @@ typedef XECACHEALIGN volatile void xe_aligned_void_t; #endif // GNUC #endif // !MIN -#if XE_PLATFORM(WIN32) +#if XE_PLATFORM_WIN32 #define XESAFERELEASE(p) if (p) { p->Release(); } #endif // WIN32