From 85bdbd24d1b5923cfb104f45194a96e7ac57026e Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 29 Mar 2013 05:07:32 -0700 Subject: [PATCH] In-progress work: refactoring PAL not to be instanced. This removes a lot of useless passing around of the PAL object. --- src/xenia/core/file.cc | 27 +--- src/xenia/core/file.h | 10 +- src/xenia/core/memory.cc | 2 +- src/xenia/core/memory.h | 3 +- src/xenia/core/mmap.h | 4 +- src/xenia/core/mmap_posix.cc | 3 +- src/xenia/core/mmap_win.cc | 3 +- src/xenia/core/pal.h | 16 +- src/xenia/core/pal_mac.cc | 84 ++++++++++ src/xenia/core/pal_posix.cc | 62 ++++++++ src/xenia/core/pal_win.cc | 145 ++++++++++++++++++ src/xenia/core/path.cc | 35 +++++ src/xenia/core/{pal.cc => path.h} | 36 ++--- src/xenia/core/path_posix.cc | 15 ++ src/xenia/core/path_win.cc | 15 ++ src/xenia/core/sources.gypi | 16 +- src/xenia/core/thread.cc | 3 +- src/xenia/core/thread.h | 2 +- src/xenia/cpu/processor.h | 4 +- src/xenia/dbg/debugger.cc | 13 +- src/xenia/dbg/debugger.h | 5 +- src/xenia/dbg/listener.cc | 4 +- src/xenia/dbg/listener.h | 3 +- src/xenia/dbg/ws_client.cc | 5 +- src/xenia/dbg/ws_listener.cc | 4 +- src/xenia/dbg/ws_listener.h | 2 +- src/xenia/kernel/fs/device.cc | 8 +- src/xenia/kernel/fs/device.h | 4 +- .../kernel/fs/devices/disc_image_device.cc | 7 +- .../kernel/fs/devices/disc_image_device.h | 2 +- .../fs/devices/local_directory_device.cc | 9 +- .../fs/devices/local_directory_device.h | 3 +- src/xenia/kernel/fs/filesystem.cc | 9 +- src/xenia/kernel/fs/filesystem.h | 3 +- src/xenia/kernel/kernel_module.h | 3 - src/xenia/kernel/modules/xam/xam_module.cc | 2 +- src/xenia/kernel/modules/xam/xam_state.cc | 4 +- src/xenia/kernel/modules/xam/xam_state.h | 4 +- .../kernel/modules/xboxkrnl/kernel_state.cc | 6 - .../kernel/modules/xboxkrnl/kernel_state.h | 2 - .../modules/xboxkrnl/objects/xmodule.cc | 3 +- src/xenia/kernel/runtime.cc | 10 +- src/xenia/kernel/runtime.h | 5 +- tools/xenia-run/xenia-run.cc | 13 +- tools/xenia-test/xenia-test.cc | 15 +- 45 files changed, 444 insertions(+), 189 deletions(-) create mode 100644 src/xenia/core/pal_mac.cc create mode 100644 src/xenia/core/pal_posix.cc create mode 100644 src/xenia/core/pal_win.cc create mode 100644 src/xenia/core/path.cc rename src/xenia/core/{pal.cc => path.h} (53%) create mode 100644 src/xenia/core/path_posix.cc create mode 100644 src/xenia/core/path_win.cc diff --git a/src/xenia/core/file.cc b/src/xenia/core/file.cc index 0728b8af0..126ad40d9 100644 --- a/src/xenia/core/file.cc +++ b/src/xenia/core/file.cc @@ -23,8 +23,7 @@ typedef struct xe_file { #endif // WIN32 -xe_file_ref xe_file_open(xe_pal_ref pal, const xe_file_mode mode, - const xechar_t *path) { +xe_file_ref xe_file_open(const xe_file_mode mode, const xechar_t *path) { xe_file_ref file = (xe_file_ref)xe_calloc(sizeof(xe_file_t)); xe_ref_init((xe_ref)file); @@ -83,27 +82,3 @@ size_t xe_file_read(xe_file_ref file, const size_t offset, return fread(buffer, 1, buffer_size, handle); } - -void xe_path_join(const xechar_t* left, const xechar_t* right, - xechar_t* out_path, size_t out_path_size) { -#if XE_WCHAR - xesnprintf(out_path, out_path_size, XT("%ls%c%ls"), - left, XE_PATH_SEPARATOR, right); -#else - xesnprintf(out_path, out_path_size, XT("%s%c%s"), - left, XE_PATH_SEPARATOR, right); -#endif // XE_WCHAR -} - -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_WCHAR - _wfullpath(out_abs_path, path, abs_path_size); -#else - _fullpath(out_abs_path, path, abs_path_size); -#endif // XE_WCHAR -#else - realpath(path, out_abs_path); -#endif // WIN32 -} diff --git a/src/xenia/core/file.h b/src/xenia/core/file.h index 23da2e30f..038b00c0e 100644 --- a/src/xenia/core/file.h +++ b/src/xenia/core/file.h @@ -11,7 +11,7 @@ #define XENIA_CORE_FILE_H_ #include -#include +#include #include @@ -25,18 +25,12 @@ typedef enum { } xe_file_mode; -xe_file_ref xe_file_open(xe_pal_ref pal, const xe_file_mode mode, - const xechar_t *path); +xe_file_ref xe_file_open(const xe_file_mode mode, const xechar_t *path); xe_file_ref xe_file_retain(xe_file_ref file); void xe_file_release(xe_file_ref file); size_t xe_file_get_length(xe_file_ref file); size_t xe_file_read(xe_file_ref file, const size_t offset, uint8_t *buffer, const size_t buffer_size); -void xe_path_join(const xechar_t* left, const xechar_t* right, - xechar_t* out_path, size_t out_path_size); -void xe_path_get_absolute(const xechar_t* path, xechar_t* out_abs_path, - size_t abs_path_size); - #endif // XENIA_CORE_FILE_H_ diff --git a/src/xenia/core/memory.cc b/src/xenia/core/memory.cc index dc9e871f4..015c34144 100644 --- a/src/xenia/core/memory.cc +++ b/src/xenia/core/memory.cc @@ -53,7 +53,7 @@ struct xe_memory { }; -xe_memory_ref xe_memory_create(xe_pal_ref pal, xe_memory_options_t options) { +xe_memory_ref xe_memory_create(xe_memory_options_t options) { uint32_t offset; uint32_t mspace_size; diff --git a/src/xenia/core/memory.h b/src/xenia/core/memory.h index 4e319e5f2..6c22c650e 100644 --- a/src/xenia/core/memory.h +++ b/src/xenia/core/memory.h @@ -11,7 +11,6 @@ #define XENIA_CORE_MEMORY_H_ #include -#include #include @@ -24,7 +23,7 @@ struct xe_memory; typedef struct xe_memory* xe_memory_ref; -xe_memory_ref xe_memory_create(xe_pal_ref pal, xe_memory_options_t options); +xe_memory_ref xe_memory_create(xe_memory_options_t options); xe_memory_ref xe_memory_retain(xe_memory_ref memory); void xe_memory_release(xe_memory_ref memory); diff --git a/src/xenia/core/mmap.h b/src/xenia/core/mmap.h index df73b345d..cf1dc91e5 100644 --- a/src/xenia/core/mmap.h +++ b/src/xenia/core/mmap.h @@ -12,7 +12,6 @@ #include #include -#include #include @@ -20,8 +19,7 @@ struct xe_mmap; typedef struct xe_mmap* xe_mmap_ref; -xe_mmap_ref xe_mmap_open(xe_pal_ref pal, const xe_file_mode mode, - const xechar_t *path, +xe_mmap_ref xe_mmap_open(const xe_file_mode mode, const xechar_t *path, const size_t offset, const size_t length); xe_mmap_ref xe_mmap_retain(xe_mmap_ref mmap); void xe_mmap_release(xe_mmap_ref mmap); diff --git a/src/xenia/core/mmap_posix.cc b/src/xenia/core/mmap_posix.cc index 7e8ce3c71..3dc904c63 100644 --- a/src/xenia/core/mmap_posix.cc +++ b/src/xenia/core/mmap_posix.cc @@ -23,8 +23,7 @@ typedef struct xe_mmap { } xe_mmap_t; -xe_mmap_ref xe_mmap_open(xe_pal_ref pal, const xe_file_mode mode, - const xechar_t *path, +xe_mmap_ref xe_mmap_open(const xe_file_mode mode, const xechar_t *path, const size_t offset, const size_t length) { xe_mmap_ref mmap = (xe_mmap_ref)xe_calloc(sizeof(xe_mmap_t)); xe_ref_init((xe_ref)mmap); diff --git a/src/xenia/core/mmap_win.cc b/src/xenia/core/mmap_win.cc index fc52080db..38b9ca025 100644 --- a/src/xenia/core/mmap_win.cc +++ b/src/xenia/core/mmap_win.cc @@ -21,8 +21,7 @@ typedef struct xe_mmap { } xe_mmap_t; -xe_mmap_ref xe_mmap_open(xe_pal_ref pal, const xe_file_mode mode, - const xechar_t *path, +xe_mmap_ref xe_mmap_open(const xe_file_mode mode, const xechar_t *path, const size_t offset, const size_t length) { xe_mmap_ref mmap = (xe_mmap_ref)xe_calloc(sizeof(xe_mmap_t)); xe_ref_init((xe_ref)mmap); diff --git a/src/xenia/core/pal.h b/src/xenia/core/pal.h index 59eefe044..7ba8d232f 100644 --- a/src/xenia/core/pal.h +++ b/src/xenia/core/pal.h @@ -19,13 +19,19 @@ typedef struct { } xe_pal_options_t; -struct xe_pal; -typedef struct xe_pal* xe_pal_ref; +int xe_pal_init(xe_pal_options_t options); -xe_pal_ref xe_pal_create(xe_pal_options_t options); -xe_pal_ref xe_pal_retain(xe_pal_ref pal); -void xe_pal_release(xe_pal_ref pal); +typedef struct { + struct { + uint32_t physical_count; + uint32_t logical_count; + } processors; +} xe_system_info; + +int xe_pal_get_system_info(xe_system_info* out_info); + +double xe_pal_now(); #endif // XENIA_CORE_PAL_H_ diff --git a/src/xenia/core/pal_mac.cc b/src/xenia/core/pal_mac.cc new file mode 100644 index 000000000..8bc3487f9 --- /dev/null +++ b/src/xenia/core/pal_mac.cc @@ -0,0 +1,84 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + +#include +#include +#include +#include +#include +#include + + +namespace { +typedef struct xe_pal_mac { + double time_to_sec; +} xe_pal_mac_t; + +xe_pal_mac_t* pal; +} + + +void xe_pal_dealloc(); +int xe_pal_init(xe_pal_options_t options) { + pal = (xe_pal_mac_t)xe_calloc(sizeof(pal)); + + mach_timebase_info_data_t info; + mach_timebase_info(&info); + pal->time_to_sec = (double)((info.numer / info.denom) / 1000000000.0); + + atexit(xe_pal_dealloc); + return 0; +} + +void xe_pal_dealloc() { + // + + xe_free(pal); +} + +int xe_pal_get_system_info(xe_system_info* out_info) { + xe_zero_struct(out_info, sizeof(xe_system_info)); + out_info->processors.physical_count = 1; + out_info->processors.logical_count = 1; + + // http://geekinfo.googlecode.com/svn-history/r74/trunk/src/macosxsystem.cpp + int count; + size_t size = sizeof(int); + if (!sysctlbyname("hw.physicalcpu", &count, &size, NULL, 0)) { + out_info->processors.physical_count = count; + } else if (!sysctlbyname("hw.packages", &count, &size, NULL, 0)) { + out_info->processors.physical_count = count; + } else { + out_info->processors.physical_count = 1; + } + if (!sysctlbyname("hw.logicalcpu", &count, &size, NULL, 0)) { + out_info->processors.logical_count = count; + } else if (!sysctlbyname("hw.ncpu", &count, &size, NULL, 0)) { + out_info->processors.logical_count = count; + } else { + out_info->processors.logical_count = 1; + } + + return 0; +} + +double xe_pal_now() { + // According to a bunch of random posts, CACurrentMediaTime is a better call: + // https://devforums.apple.com/message/118806#118806 + // CACurrentMediaTime is based on mach_absolute_time(), which doesn't have a + // dependency on QuartzCore: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1398.html + + // return (double)CFAbsoluteTimeGetCurrent(); + // return (double)CACurrentMediaTime(); + + return (double)(mach_absolute_time() * pal->time_to_sec); +} diff --git a/src/xenia/core/pal_posix.cc b/src/xenia/core/pal_posix.cc new file mode 100644 index 000000000..93b2986f8 --- /dev/null +++ b/src/xenia/core/pal_posix.cc @@ -0,0 +1,62 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +namespace { +typedef struct xe_pal_posix { + +} xe_pal_posix_t; + +xe_pal_posix_t* pal; +} + + +void xe_pal_dealloc(); +int xe_pal_init(xe_pal_options_t options) { + pal = (xe_pal_posix_t)xe_calloc(sizeof(pal)); + + // + + atexit(xe_pal_dealloc); + return 0; +} + +void xe_pal_dealloc() { + // + + xe_free(pal); +} + +int xe_pal_get_system_info(xe_system_info* out_info) { + xe_zero_struct(out_info, sizeof(xe_system_info)); + out_info->processors.physical_count = 1; + out_info->processors.logical_count = 1; + +#if defined(_SC_NPROCESSORS_ONLN) + int nproc = sysconf(_SC_NPROCESSORS_ONLN); + if (nproc >= 1) { + // Only able to get logical count. + sysInfo->processors.logicalCount = nproc; + } +#else +#warning no calls to get processor counts +#endif // _SC_NPROCESSORS_ONLN + + return 0; +} + +double xe_pal_now() { + // http://www.kernel.org/doc/man-pages/online/pages/man2/clock_gettime.2.html + // http://juliusdavies.ca/posix_clocks/clock_realtime_linux_faq.html + struct timespec ts; + CPIGNORE(clock_gettime(CLOCK_MONOTONIC, &ts)); + return (double)(ts.tv_sec + (ts.tv_nsec * 1000000000.0)); +} diff --git a/src/xenia/core/pal_win.cc b/src/xenia/core/pal_win.cc new file mode 100644 index 000000000..4bc43cdc7 --- /dev/null +++ b/src/xenia/core/pal_win.cc @@ -0,0 +1,145 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +namespace { +typedef struct xe_pal_win { + bool use_high_perf_timer; + double inv_ticks_per_sec; +} xe_pal_win_t; + +xe_pal_win_t* pal; +} + + +void xe_pal_dealloc(); +int xe_pal_init(xe_pal_options_t options) { + pal = (xe_pal_win_t)xe_calloc(sizeof(pal)); + + // Get QPC timing frequency... hopefully stable over the life of the app, + // but likely not. + // TODO(benvanik): requery periodically/etc. + LARGE_INTEGER ticks_per_sec; + if (QueryPerformanceFrequency(&ticks_per_sec)) { + pal->use_high_perf_timer = true; + pal->inv_ticks_per_sec = 1.0 / (double)ticks_per_sec.QuadPart; + } else { + pal->use_high_perf_timer = false; + XELOGW("Falling back from high performance timer"); + } + + // Setup COM on the main thread. + // NOTE: this may fail if COM has already been initialized - that's OK. + XEIGNORE(CoInitializeEx(NULL, COINIT_MULTITHREADED)); + + atexit(xe_pal_dealloc); + return 0; +} + +void xe_pal_dealloc() { + // + + xe_free(pal); +} + +// http://msdn.microsoft.com/en-us/library/ms683194.aspx +namespace { +DWORD CountSetBits(ULONG_PTR bitMask) { + DWORD LSHIFT = sizeof(ULONG_PTR)*8 - 1; + DWORD bitSetCount = 0; + ULONG_PTR bitTest = (ULONG_PTR)1 << LSHIFT; + for (DWORD i = 0; i <= LSHIFT; ++i, bitTest /= 2) { + bitSetCount += ((bitMask & bitTest)?1:0); + } + return bitSetCount; +} +} +int xe_pal_get_system_info(xe_system_info* out_info) { + int result_code = 1; + xe_zero_struct(out_info, sizeof(xe_system_info)); + out_info->processors.physical_count = 1; + out_info->processors.logical_count = 1; + + typedef BOOL (WINAPI *LPFN_GLPI)( + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); + + HMODULE kernel32 = NULL; + LPFN_GLPI glpi = NULL; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer = NULL; + + kernel32 = GetModuleHandle(TEXT("kernel32")); + XEEXPECTNOTNULL(kernel32); + glpi = (LPFN_GLPI)GetProcAddress(kernel32, "GetLogicalProcessorInfomration"); + XEEXPECTNOTNULL(glpi); + + // Call GLPI once to get the buffer size, allocate it, then call again. + DWORD buffer_length = 0; + XEEXPECTFALSE(glpi(NULL, &buffer_length)); + XEEXPECT(GetLastError() == ERROR_INSUFFICIENT_BUFFER); + buffer = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)xe_malloc(buffer_length); + XEEXPECTNOTNULL(buffer); + XEEXPECTTRUE(glpi(buffer, &buffer_length)); + XEEXPECTNOTZERO(buffer_length); + + out_info->processors.physical_count = 0; + out_info->processors.logical_count = 0; + + size_t info_count = buffer_length / + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); + for (size_t n = 0; n < info_count; n++) { + switch (buffer[n].Relationship) { + case RelationProcessorPackage: + out_info->processors.physical_count++; + break; + case RelationProcessorCore: + if (buffer[n].ProcessorCore.Flags == 1) { + // Hyper-threaded. + // The number of processors is set as bits in ProcessorMask. + out_info.processors.logical_count += + CountSetBits(buffer[n].ProcessorMask); + } else { + // A real core - just count as one. + out_info->processors.logical_count++; + } + break; + } + } + + out_info->processors.physical_count = + MAX(1, out_info->processors.physical_count); + out_info->processors.logical_count = + MAX(1, out_info->processors.logical_count); + + result_code = 0; +XECLEANUP: + xe_free(buffer); + if (kernel32) { + FreeLibrary(kernel32); + } + return result_code; +} + +double xe_pal_now() { + if (pal->use_high_perf_timer) { + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + return counter.QuadPart * pal->inv_ticks_per_sec; + } else { + // Using GetSystemTimeAsFileTime instead of GetSystemTime() as it has a + // 100ns resolution. + FILETIME ft; + GetSystemTimeAsFileTime(&ft); + ULARGE_INTEGER uli; + uli.LowPart = ft.dwLowDateTime; + uli.HighPart = ft.dwHighDateTime; + return uli.QuadPart / 10000000.0; + } +} diff --git a/src/xenia/core/path.cc b/src/xenia/core/path.cc new file mode 100644 index 000000000..fbf0bd491 --- /dev/null +++ b/src/xenia/core/path.cc @@ -0,0 +1,35 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +void xe_path_join(const xechar_t* left, const xechar_t* right, + xechar_t* out_path, size_t out_path_size) { +#if XE_WCHAR + xesnprintf(out_path, out_path_size, XT("%ls%c%ls"), + left, XE_PATH_SEPARATOR, right); +#else + xesnprintf(out_path, out_path_size, XT("%s%c%s"), + left, XE_PATH_SEPARATOR, right); +#endif // XE_WCHAR +} + +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_WCHAR + _wfullpath(out_abs_path, path, abs_path_size); +#else + _fullpath(out_abs_path, path, abs_path_size); +#endif // XE_WCHAR +#else + realpath(path, out_abs_path); +#endif // WIN32 +} diff --git a/src/xenia/core/pal.cc b/src/xenia/core/path.h similarity index 53% rename from src/xenia/core/pal.cc rename to src/xenia/core/path.h index 11fea7ca8..7ccfde28b 100644 --- a/src/xenia/core/pal.cc +++ b/src/xenia/core/path.h @@ -7,33 +7,19 @@ ****************************************************************************** */ +#ifndef XENIA_CORE_PATH_H_ +#define XENIA_CORE_PATH_H_ + +#include #include +#include -typedef struct xe_pal { - xe_ref_t ref; +void xe_path_join(const xechar_t* left, const xechar_t* right, + xechar_t* out_path, size_t out_path_size); +void xe_path_get_absolute(const xechar_t* path, xechar_t* out_abs_path, + size_t abs_path_size); -} xe_pal_t; +const xechar_t* xe_path_get_tmp(const xechar_t* prefix); - -xe_pal_ref xe_pal_create(xe_pal_options_t options) { - xe_pal_ref pal = (xe_pal_ref)xe_calloc(sizeof(xe_pal_t)); - xe_ref_init((xe_ref)pal); - - // - - return pal; -} - -void xe_pal_dealloc(xe_pal_ref pal) { - // -} - -xe_pal_ref xe_pal_retain(xe_pal_ref pal) { - xe_ref_retain((xe_ref)pal); - return pal; -} - -void xe_pal_release(xe_pal_ref pal) { - xe_ref_release((xe_ref)pal, (xe_ref_dealloc_t)xe_pal_dealloc); -} +#endif // XENIA_CORE_PATH_H_ diff --git a/src/xenia/core/path_posix.cc b/src/xenia/core/path_posix.cc new file mode 100644 index 000000000..c5a764dd9 --- /dev/null +++ b/src/xenia/core/path_posix.cc @@ -0,0 +1,15 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +const xechar_t* xe_path_get_tmp(const xechar_t* prefix) { + // +} diff --git a/src/xenia/core/path_win.cc b/src/xenia/core/path_win.cc new file mode 100644 index 000000000..c5a764dd9 --- /dev/null +++ b/src/xenia/core/path_win.cc @@ -0,0 +1,15 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2013 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include + + +const xechar_t* xe_path_get_tmp(const xechar_t* prefix) { + // +} diff --git a/src/xenia/core/sources.gypi b/src/xenia/core/sources.gypi index c489e5329..65c0051e4 100644 --- a/src/xenia/core/sources.gypi +++ b/src/xenia/core/sources.gypi @@ -7,8 +7,9 @@ 'memory.h', 'mmap.h', 'mutex.h', - 'pal.cc', 'pal.h', + 'path.cc', + 'path.h', 'ref.cc', 'ref.h', 'socket.h', @@ -21,13 +22,26 @@ 'sources': [ 'mmap_posix.cc', 'mutex_posix.cc', + 'path_posix.cc', 'socket_posix.cc', ], }], + ['OS == "linux"', { + 'sources': [ + 'pal_posix.cc', + ], + }], + ['OS == "mac"', { + 'sources': [ + 'pal_mac.cc', + ], + }], ['OS == "win"', { 'sources': [ 'mmap_win.cc', 'mutex_win.cc', + 'pal_win.cc', + 'path_win.cc', 'socket_win.cc', ], }], diff --git a/src/xenia/core/thread.cc b/src/xenia/core/thread.cc index 59d585fd6..fa2ac36b6 100644 --- a/src/xenia/core/thread.cc +++ b/src/xenia/core/thread.cc @@ -24,8 +24,7 @@ typedef struct xe_thread { xe_thread_ref xe_thread_create( - xe_pal_ref pal, const char* name, xe_thread_callback callback, - void* param) { + const char* name, xe_thread_callback callback, void* param) { xe_thread_ref thread = (xe_thread_ref)xe_calloc(sizeof(xe_thread_t)); xe_ref_init((xe_ref)thread); diff --git a/src/xenia/core/thread.h b/src/xenia/core/thread.h index 4c707d9c8..fee1880cd 100644 --- a/src/xenia/core/thread.h +++ b/src/xenia/core/thread.h @@ -23,7 +23,7 @@ typedef void (*xe_thread_callback)(void* param); xe_thread_ref xe_thread_create( - xe_pal_ref pal, const char* name, xe_thread_callback callback, void* param); + const char* name, xe_thread_callback callback, void* param); xe_thread_ref xe_thread_retain(xe_thread_ref thread); void xe_thread_release(xe_thread_ref thread); diff --git a/src/xenia/cpu/processor.h b/src/xenia/cpu/processor.h index 13e30c6ba..fee4b9032 100644 --- a/src/xenia/cpu/processor.h +++ b/src/xenia/cpu/processor.h @@ -32,10 +32,9 @@ namespace cpu { class Processor { public: - Processor(xe_pal_ref pal, xe_memory_ref memory); + Processor(xe_memory_ref memory); ~Processor(); - xe_pal_ref pal(); xe_memory_ref memory(); int Setup(); @@ -56,7 +55,6 @@ public: private: llvm::Function* GetFunction(uint32_t address); - xe_pal_ref pal_; xe_memory_ref memory_; shared_ptr engine_; diff --git a/src/xenia/dbg/debugger.cc b/src/xenia/dbg/debugger.cc index dce8d4d2f..27cf39026 100644 --- a/src/xenia/dbg/debugger.cc +++ b/src/xenia/dbg/debugger.cc @@ -25,11 +25,8 @@ DEFINE_int32(remote_debug_port, 6200, "Websocket port to listen for debugger connections on."); -Debugger::Debugger(xe_pal_ref pal) { - pal_ = xe_pal_retain(pal); - - listener_ = auto_ptr(new WsListener( - this, pal_, FLAGS_remote_debug_port)); +Debugger::Debugger() { + listener_ = auto_ptr(new WsListener(this, FLAGS_remote_debug_port)); } Debugger::~Debugger() { @@ -45,12 +42,6 @@ Debugger::~Debugger() { delete it->second; } content_sources_.clear(); - - xe_pal_release(pal_); -} - -xe_pal_ref Debugger::pal() { - return xe_pal_retain(pal_); } void Debugger::RegisterContentSource(ContentSource* content_source) { diff --git a/src/xenia/dbg/debugger.h b/src/xenia/dbg/debugger.h index 158b98e6d..3d331b128 100644 --- a/src/xenia/dbg/debugger.h +++ b/src/xenia/dbg/debugger.h @@ -28,11 +28,9 @@ class Listener; class Debugger { public: - Debugger(xe_pal_ref pal); + Debugger(); virtual ~Debugger(); - xe_pal_ref pal(); - void RegisterContentSource(ContentSource* content_source); int Startup(); @@ -47,7 +45,6 @@ private: friend class Client; private: - xe_pal_ref pal_; auto_ptr listener_; std::vector clients_; std::map content_sources_; diff --git a/src/xenia/dbg/listener.cc b/src/xenia/dbg/listener.cc index 2a72d99a9..4701709d3 100644 --- a/src/xenia/dbg/listener.cc +++ b/src/xenia/dbg/listener.cc @@ -14,11 +14,9 @@ using namespace xe; using namespace xe::dbg; -Listener::Listener(Debugger* debugger, xe_pal_ref pal) : +Listener::Listener(Debugger* debugger) : debugger_(debugger) { - pal_ = xe_pal_retain(pal); } Listener::~Listener() { - xe_pal_release(pal_); } diff --git a/src/xenia/dbg/listener.h b/src/xenia/dbg/listener.h index 43a160e6c..5326ffb54 100644 --- a/src/xenia/dbg/listener.h +++ b/src/xenia/dbg/listener.h @@ -23,7 +23,7 @@ class Debugger; class Listener { public: - Listener(Debugger* debugger, xe_pal_ref pal); + Listener(Debugger* debugger); virtual ~Listener(); virtual int Setup() = 0; @@ -31,7 +31,6 @@ public: protected: Debugger* debugger_; - xe_pal_ref pal_; }; diff --git a/src/xenia/dbg/ws_client.cc b/src/xenia/dbg/ws_client.cc index 01d02e86b..bfccd8786 100644 --- a/src/xenia/dbg/ws_client.cc +++ b/src/xenia/dbg/ws_client.cc @@ -60,10 +60,7 @@ int WsClient::Setup() { xe_socket_set_keepalive(socket_id_, true); xe_socket_set_nodelay(socket_id_, true); - xe_pal_ref pal = debugger_->pal(); - thread_ = xe_thread_create(pal, "Debugger Client", - StartCallback, this); - xe_pal_release(pal); + thread_ = xe_thread_create("Debugger Client", StartCallback, this); return xe_thread_start(thread_); } diff --git a/src/xenia/dbg/ws_listener.cc b/src/xenia/dbg/ws_listener.cc index 2b9eeb1e2..c07bb8bf0 100644 --- a/src/xenia/dbg/ws_listener.cc +++ b/src/xenia/dbg/ws_listener.cc @@ -16,8 +16,8 @@ using namespace xe; using namespace xe::dbg; -WsListener::WsListener(Debugger* debugger, xe_pal_ref pal, uint32_t port) : - Listener(debugger, pal), +WsListener::WsListener(Debugger* debugger, uint32_t port) : + Listener(debugger), port_(port) { } diff --git a/src/xenia/dbg/ws_listener.h b/src/xenia/dbg/ws_listener.h index f495d5ee3..c4c7df6d6 100644 --- a/src/xenia/dbg/ws_listener.h +++ b/src/xenia/dbg/ws_listener.h @@ -25,7 +25,7 @@ class Debugger; class WsListener : public Listener { public: - WsListener(Debugger* debugger, xe_pal_ref pal, uint32_t port); + WsListener(Debugger* debugger, uint32_t port); virtual ~WsListener(); virtual int Setup(); diff --git a/src/xenia/kernel/fs/device.cc b/src/xenia/kernel/fs/device.cc index 094ecc986..d49c56362 100644 --- a/src/xenia/kernel/fs/device.cc +++ b/src/xenia/kernel/fs/device.cc @@ -15,18 +15,12 @@ using namespace xe::kernel; using namespace xe::kernel::fs; -Device::Device(xe_pal_ref pal, const char* path) { - pal_ = xe_pal_retain(pal); +Device::Device(const char* path) { path_ = xestrdupa(path); } Device::~Device() { xe_free(path_); - xe_pal_release(pal_); -} - -xe_pal_ref Device::pal() { - return xe_pal_retain(pal_); } const char* Device::path() { diff --git a/src/xenia/kernel/fs/device.h b/src/xenia/kernel/fs/device.h index adeac566f..8ad650202 100644 --- a/src/xenia/kernel/fs/device.h +++ b/src/xenia/kernel/fs/device.h @@ -23,16 +23,14 @@ namespace fs { class Device { public: - Device(xe_pal_ref pal, const char* path); + Device(const char* path); virtual ~Device(); - xe_pal_ref pal(); const char* path(); virtual Entry* ResolvePath(const char* path) = 0; protected: - xe_pal_ref pal_; char* path_; }; diff --git a/src/xenia/kernel/fs/devices/disc_image_device.cc b/src/xenia/kernel/fs/devices/disc_image_device.cc index 973924686..7a0abc6ab 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.cc +++ b/src/xenia/kernel/fs/devices/disc_image_device.cc @@ -74,9 +74,8 @@ private: } -DiscImageDevice::DiscImageDevice(xe_pal_ref pal, const char* path, - const xechar_t* local_path) : - Device(pal, path) { +DiscImageDevice::DiscImageDevice(const char* path, const xechar_t* local_path) : + Device(path) { local_path_ = xestrdup(local_path); mmap_ = NULL; gdfx_ = NULL; @@ -89,7 +88,7 @@ DiscImageDevice::~DiscImageDevice() { } int DiscImageDevice::Init() { - mmap_ = xe_mmap_open(pal_, kXEFileModeRead, local_path_, 0, 0); + mmap_ = xe_mmap_open(kXEFileModeRead, local_path_, 0, 0); if (!mmap_) { XELOGE("Disc image could not be mapped"); return 1; diff --git a/src/xenia/kernel/fs/devices/disc_image_device.h b/src/xenia/kernel/fs/devices/disc_image_device.h index a01898dc2..361affda0 100644 --- a/src/xenia/kernel/fs/devices/disc_image_device.h +++ b/src/xenia/kernel/fs/devices/disc_image_device.h @@ -26,7 +26,7 @@ class GDFX; class DiscImageDevice : public Device { public: - DiscImageDevice(xe_pal_ref pal, const char* path, const xechar_t* local_path); + DiscImageDevice(const char* path, const xechar_t* local_path); virtual ~DiscImageDevice(); int Init(); diff --git a/src/xenia/kernel/fs/devices/local_directory_device.cc b/src/xenia/kernel/fs/devices/local_directory_device.cc index b8dfecf09..694d804d4 100644 --- a/src/xenia/kernel/fs/devices/local_directory_device.cc +++ b/src/xenia/kernel/fs/devices/local_directory_device.cc @@ -46,10 +46,7 @@ public: virtual MemoryMapping* CreateMemoryMapping( xe_file_mode file_mode, const size_t offset, const size_t length) { - xe_pal_ref pal = device()->pal(); - xe_mmap_ref mmap = xe_mmap_open(pal, file_mode, local_path_, - offset, length); - xe_pal_release(pal); + xe_mmap_ref mmap = xe_mmap_open(file_mode, local_path_, offset, length); if (!mmap) { return NULL; } @@ -70,9 +67,9 @@ private: } -LocalDirectoryDevice::LocalDirectoryDevice(xe_pal_ref pal, const char* path, +LocalDirectoryDevice::LocalDirectoryDevice(const char* path, const xechar_t* local_path) : - Device(pal, path) { + Device(path) { local_path_ = xestrdup(local_path); } diff --git a/src/xenia/kernel/fs/devices/local_directory_device.h b/src/xenia/kernel/fs/devices/local_directory_device.h index 372fc464b..4a0fbd1ee 100644 --- a/src/xenia/kernel/fs/devices/local_directory_device.h +++ b/src/xenia/kernel/fs/devices/local_directory_device.h @@ -23,8 +23,7 @@ namespace fs { class LocalDirectoryDevice : public Device { public: - LocalDirectoryDevice(xe_pal_ref pal, const char* path, - const xechar_t* local_path); + LocalDirectoryDevice(const char* path, const xechar_t* local_path); virtual ~LocalDirectoryDevice(); virtual Entry* ResolvePath(const char* path); diff --git a/src/xenia/kernel/fs/filesystem.cc b/src/xenia/kernel/fs/filesystem.cc index 68e79377a..4c1f867e7 100644 --- a/src/xenia/kernel/fs/filesystem.cc +++ b/src/xenia/kernel/fs/filesystem.cc @@ -18,8 +18,7 @@ using namespace xe::kernel; using namespace xe::kernel::fs; -FileSystem::FileSystem(xe_pal_ref pal) { - pal_ = xe_pal_retain(pal); +FileSystem::FileSystem() { } FileSystem::~FileSystem() { @@ -31,8 +30,6 @@ FileSystem::~FileSystem() { } devices_.clear(); symlinks_.clear(); - - xe_pal_release(pal_); } int FileSystem::RegisterDevice(const char* path, Device* device) { @@ -42,13 +39,13 @@ int FileSystem::RegisterDevice(const char* path, Device* device) { int FileSystem::RegisterLocalDirectoryDevice( const char* path, const xechar_t* local_path) { - Device* device = new LocalDirectoryDevice(pal_, path, local_path); + Device* device = new LocalDirectoryDevice(path, local_path); return RegisterDevice(path, device); } int FileSystem::RegisterDiscImageDevice( const char* path, const xechar_t* local_path) { - DiscImageDevice* device = new DiscImageDevice(pal_, path, local_path); + DiscImageDevice* device = new DiscImageDevice(path, local_path); if (device->Init()) { return 1; } diff --git a/src/xenia/kernel/fs/filesystem.h b/src/xenia/kernel/fs/filesystem.h index e9f6ea619..cc99a8bd3 100644 --- a/src/xenia/kernel/fs/filesystem.h +++ b/src/xenia/kernel/fs/filesystem.h @@ -28,7 +28,7 @@ class Device; class FileSystem { public: - FileSystem(xe_pal_ref pal); + FileSystem(); ~FileSystem(); int RegisterDevice(const char* path, Device* device); @@ -42,7 +42,6 @@ public: Entry* ResolvePath(const char* path); private: - xe_pal_ref pal_; std::vector devices_; std::tr1::unordered_map symlinks_; }; diff --git a/src/xenia/kernel/kernel_module.h b/src/xenia/kernel/kernel_module.h index 5602ea6ed..9c5133135 100644 --- a/src/xenia/kernel/kernel_module.h +++ b/src/xenia/kernel/kernel_module.h @@ -28,7 +28,6 @@ class KernelModule { public: KernelModule(Runtime* runtime) { runtime_ = runtime; - pal_ = runtime->pal(); memory_ = runtime->memory(); export_resolver_ = runtime->export_resolver(); } @@ -36,12 +35,10 @@ public: virtual ~KernelModule() { export_resolver_.reset(); xe_memory_release(memory_); - xe_pal_release(pal_); } protected: Runtime* runtime_; - xe_pal_ref pal_; xe_memory_ref memory_; shared_ptr export_resolver_; }; diff --git a/src/xenia/kernel/modules/xam/xam_module.cc b/src/xenia/kernel/modules/xam/xam_module.cc index 147f5b126..e8bbc8f5b 100644 --- a/src/xenia/kernel/modules/xam/xam_module.cc +++ b/src/xenia/kernel/modules/xam/xam_module.cc @@ -24,7 +24,7 @@ XamModule::XamModule(Runtime* runtime) : "xam.xex", xam_export_table, XECOUNT(xam_export_table)); // Setup the xam state instance. - xam_state = auto_ptr(new XamState(pal_, memory_, export_resolver_)); + xam_state = auto_ptr(new XamState(memory_, export_resolver_)); // Register all exported functions. RegisterInfoExports(export_resolver_.get(), xam_state.get()); diff --git a/src/xenia/kernel/modules/xam/xam_state.cc b/src/xenia/kernel/modules/xam/xam_state.cc index d55e2be3a..98a0fb6e0 100644 --- a/src/xenia/kernel/modules/xam/xam_state.cc +++ b/src/xenia/kernel/modules/xam/xam_state.cc @@ -20,14 +20,12 @@ namespace { } -XamState::XamState(xe_pal_ref pal, xe_memory_ref memory, +XamState::XamState(xe_memory_ref memory, shared_ptr export_resolver) { - this->pal = xe_pal_retain(pal); this->memory = xe_memory_retain(memory); export_resolver_ = export_resolver; } XamState::~XamState() { xe_memory_release(memory); - xe_pal_release(pal); } diff --git a/src/xenia/kernel/modules/xam/xam_state.h b/src/xenia/kernel/modules/xam/xam_state.h index 23112f4cb..83e95e219 100644 --- a/src/xenia/kernel/modules/xam/xam_state.h +++ b/src/xenia/kernel/modules/xam/xam_state.h @@ -24,11 +24,9 @@ namespace xam { class XamState { public: - XamState(xe_pal_ref pal, xe_memory_ref memory, - shared_ptr export_resolver); + XamState(xe_memory_ref memory, shared_ptr export_resolver); ~XamState(); - xe_pal_ref pal; xe_memory_ref memory; private: diff --git a/src/xenia/kernel/modules/xboxkrnl/kernel_state.cc b/src/xenia/kernel/modules/xboxkrnl/kernel_state.cc index 273d573f8..f5e03cb6f 100644 --- a/src/xenia/kernel/modules/xboxkrnl/kernel_state.cc +++ b/src/xenia/kernel/modules/xboxkrnl/kernel_state.cc @@ -28,7 +28,6 @@ KernelState::KernelState(Runtime* runtime) : runtime_(runtime), executable_module_(NULL), next_handle_(0) { - pal_ = runtime->pal(); memory_ = runtime->memory(); processor_ = runtime->processor(); filesystem_ = runtime->filesystem(); @@ -69,17 +68,12 @@ KernelState::~KernelState() { filesystem_.reset(); processor_.reset(); xe_memory_release(memory_); - xe_pal_release(pal_); } Runtime* KernelState::runtime() { return runtime_; } -xe_pal_ref KernelState::pal() { - return pal_; -} - xe_memory_ref KernelState::memory() { return memory_; } diff --git a/src/xenia/kernel/modules/xboxkrnl/kernel_state.h b/src/xenia/kernel/modules/xboxkrnl/kernel_state.h index 38e580fa3..0ba2a9152 100644 --- a/src/xenia/kernel/modules/xboxkrnl/kernel_state.h +++ b/src/xenia/kernel/modules/xboxkrnl/kernel_state.h @@ -35,7 +35,6 @@ public: ~KernelState(); Runtime* runtime(); - xe_pal_ref pal(); xe_memory_ref memory(); cpu::Processor* processor(); fs::FileSystem* filesystem(); @@ -51,7 +50,6 @@ private: void RemoveObject(XObject* obj); Runtime* runtime_; - xe_pal_ref pal_; xe_memory_ref memory_; shared_ptr processor_; shared_ptr filesystem_; diff --git a/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc b/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc index 4107f5b8e..1e5ea2bf7 100644 --- a/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc +++ b/src/xenia/kernel/modules/xboxkrnl/objects/xmodule.cc @@ -92,8 +92,7 @@ X_STATUS XModule::LoadFromMemory(const void* addr, const size_t length) { XEEXPECTNOTNULL(xex_); // Prepare the module for execution. - XEEXPECTZERO(kernel_state()->processor()->PrepareModule( - name_, path_, xex_, runtime()->export_resolver())); + XEEXPECTZERO(kernel_state()->processor()->LoadXexModule(name_, path_, xex_)); return X_STATUS_SUCCESS; diff --git a/src/xenia/kernel/runtime.cc b/src/xenia/kernel/runtime.cc index 2b37415dd..201458ad2 100644 --- a/src/xenia/kernel/runtime.cc +++ b/src/xenia/kernel/runtime.cc @@ -18,15 +18,14 @@ using namespace xe::kernel; using namespace xe::kernel::fs; -Runtime::Runtime(xe_pal_ref pal, shared_ptr processor, +Runtime::Runtime(shared_ptr processor, const xechar_t* command_line) { - pal_ = xe_pal_retain(pal); memory_ = processor->memory(); processor_ = processor; XEIGNORE(xestrcpy(command_line_, XECOUNT(command_line_), command_line)); export_resolver_ = shared_ptr(new ExportResolver()); - filesystem_ = shared_ptr(new FileSystem(pal_)); + filesystem_ = shared_ptr(new FileSystem()); xboxkrnl_ = auto_ptr( new xboxkrnl::XboxkrnlModule(this)); @@ -36,17 +35,12 @@ Runtime::Runtime(xe_pal_ref pal, shared_ptr processor, Runtime::~Runtime() { xe_memory_release(memory_); - xe_pal_release(pal_); } const xechar_t* Runtime::command_line() { return command_line_; } -xe_pal_ref Runtime::pal() { - return xe_pal_retain(pal_); -} - xe_memory_ref Runtime::memory() { return xe_memory_retain(memory_); } diff --git a/src/xenia/kernel/runtime.h b/src/xenia/kernel/runtime.h index 5de930149..d530493d6 100644 --- a/src/xenia/kernel/runtime.h +++ b/src/xenia/kernel/runtime.h @@ -42,13 +42,11 @@ class KernelModule; class Runtime { public: - Runtime(xe_pal_ref pal, shared_ptr processor, - const xechar_t* command_line); + Runtime(shared_ptr processor, const xechar_t* command_line); ~Runtime(); const xechar_t* command_line(); - xe_pal_ref pal(); xe_memory_ref memory(); shared_ptr processor(); shared_ptr export_resolver(); @@ -60,7 +58,6 @@ public: private: xechar_t command_line_[XE_MAX_PATH]; - xe_pal_ref pal_; xe_memory_ref memory_; shared_ptr processor_; shared_ptr export_resolver_; diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index a9c7391e5..a40408764 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -27,7 +27,6 @@ public: int Launch(const xechar_t* path); private: - xe_pal_ref pal_; xe_memory_ref memory_; shared_ptr processor_; shared_ptr runtime_; @@ -39,26 +38,24 @@ Run::Run() { Run::~Run() { xe_memory_release(memory_); - xe_pal_release(pal_); } int Run::Setup() { xe_pal_options_t pal_options; xe_zero_struct(&pal_options, sizeof(pal_options)); - pal_ = xe_pal_create(pal_options); - XEEXPECTNOTNULL(pal_); + XEEXPECTZERO(xe_pal_init(pal_options)); - debugger_ = shared_ptr(new Debugger(pal_)); + debugger_ = shared_ptr(new Debugger()); xe_memory_options_t memory_options; xe_zero_struct(&memory_options, sizeof(memory_options)); - memory_ = xe_memory_create(pal_, memory_options); + memory_ = xe_memory_create(memory_options); XEEXPECTNOTNULL(memory_); - processor_ = shared_ptr(new Processor(pal_, memory_)); + processor_ = shared_ptr(new Processor(memory_)); XEEXPECTZERO(processor_->Setup()); - runtime_ = shared_ptr(new Runtime(pal_, processor_, XT(""))); + runtime_ = shared_ptr(new Runtime(processor_, XT(""))); return 0; XECLEANUP: diff --git a/tools/xenia-test/xenia-test.cc b/tools/xenia-test/xenia-test.cc index 990313aa7..b30e4cd10 100644 --- a/tools/xenia-test/xenia-test.cc +++ b/tools/xenia-test/xenia-test.cc @@ -26,8 +26,7 @@ DEFINE_string(test_path, "test/codegen/", typedef vector > annotations_list_t; -int read_annotations(xe_pal_ref pal, string& src_file_path, - annotations_list_t& annotations) { +int read_annotations(string& src_file_path, annotations_list_t& annotations) { // TODO(benvanik): use PAL instead of this FILE* f = fopen(src_file_path.c_str(), "r"); char line_buffer[BUFSIZ]; @@ -98,7 +97,7 @@ int check_test_results(xe_memory_ref memory, Processor* processor, return any_failed; } -int run_test(xe_pal_ref pal, string& src_file_path) { +int run_test(string& src_file_path) { int result_code = 1; // test.s -> test.bin @@ -126,11 +125,10 @@ int run_test(xe_pal_ref pal, string& src_file_path) { runtime = shared_ptr(new Runtime(pal, processor, XT(""))); // Load the binary module. - XEEXPECTZERO(processor->LoadBinary(bin_file_path.c_str(), 0x82010000, - runtime->export_resolver())); + XEEXPECTZERO(processor->LoadRawBinary(bin_file_path.c_str(), 0x82010000)); // Simulate a thread. - thread_state = processor->AllocThread(256 * 1024 * 1024, 0); + thread_state = processor->AllocThread(256 * 1024, 0); // Setup test state from annotations. XEEXPECTZERO(setup_test_state(memory, processor.get(), thread_state, @@ -186,13 +184,11 @@ int run_tests(const xechar_t* test_name) { int failed_count = 0; int passed_count = 0; - xe_pal_ref pal = NULL; vector test_files; xe_pal_options_t pal_options; xe_zero_struct(&pal_options, sizeof(pal_options)); - pal = xe_pal_create(pal_options); - XEEXPECTNOTNULL(pal); + XEEXPECTZERO(xe_pal_init(pal_options)); XEEXPECTZERO(discover_tests(FLAGS_test_path, test_files)); if (!test_files.size()) { @@ -225,7 +221,6 @@ int run_tests(const xechar_t* test_name) { result_code = failed_count ? 1 : 0; XECLEANUP: - xe_pal_release(pal); return result_code; }