Merge pull request #643 from inckie/local_fixes

* statics initialization order fix
This commit is contained in:
Justin Moore 2017-02-23 17:34:13 -06:00 committed by GitHub
commit ed56f7e96b
1 changed files with 6 additions and 1 deletions

View File

@ -140,9 +140,13 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
}); });
} }
std::vector<xe::cpu::Export*> xboxkrnl_exports(4096); static auto& get_xboxkrnl_exports() {
static std::vector<xe::cpu::Export*> xboxkrnl_exports(4096);
return xboxkrnl_exports;
}
xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export_entry) { xe::cpu::Export* RegisterExport_xboxkrnl(xe::cpu::Export* export_entry) {
auto& xboxkrnl_exports = get_xboxkrnl_exports();
assert_true(export_entry->ordinal < xboxkrnl_exports.size()); assert_true(export_entry->ordinal < xboxkrnl_exports.size());
xboxkrnl_exports[export_entry->ordinal] = export_entry; xboxkrnl_exports[export_entry->ordinal] = export_entry;
return export_entry; return export_entry;
@ -158,6 +162,7 @@ void XboxkrnlModule::RegisterExportTable(
#include "xenia/kernel/xboxkrnl/xboxkrnl_table.inc" #include "xenia/kernel/xboxkrnl/xboxkrnl_table.inc"
}; };
#include "xenia/kernel/util/export_table_post.inc" #include "xenia/kernel/util/export_table_post.inc"
auto& xboxkrnl_exports = get_xboxkrnl_exports();
for (size_t i = 0; i < xe::countof(xboxkrnl_export_table); ++i) { for (size_t i = 0; i < xe::countof(xboxkrnl_export_table); ++i) {
auto& export_entry = xboxkrnl_export_table[i]; auto& export_entry = xboxkrnl_export_table[i];
assert_true(export_entry.ordinal < xboxkrnl_exports.size()); assert_true(export_entry.ordinal < xboxkrnl_exports.size());