static void retro_wrap_emulator() { mmain(1,RPATH); pauseg=-1; environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, 0); // Were done here co_switch(mainThread); // Dead emulator, but libco says not to return while(true) { LOGI("Running a dead emulator."); co_switch(mainThread); } }
static int test_exec(void) { module_t mod = module_FREE; const char * name[] = { "testmodule", "testmodule_Debug" }; for (unsigned i = 0; i < lengthof(name); ++i) { // prepare TEST(0 == init_module(&mod, name[i])); // TEST module_main: execute typedef int (*module_main_f) (testmodule_functable_t * functable, threadcontext_t * tcontext); module_main_f mmain = (module_main_f) (uintptr_t) codeaddr_module(&mod); testmodule_functable_t table = { 0, 0, 0 }; TEST(0 == mmain(&table, tcontext_maincontext())); TEST(codeaddr_module(&mod) < (uint8_t*)(uintptr_t)table.add && (uint8_t*)(uintptr_t)table.add < codeaddr_module(&mod) + codesize_module(&mod)); TEST(codeaddr_module(&mod) < (uint8_t*)(uintptr_t)table.sub && (uint8_t*)(uintptr_t)table.sub < codeaddr_module(&mod) + codesize_module(&mod)); TEST(codeaddr_module(&mod) < (uint8_t*)(uintptr_t)table.mult && (uint8_t*)(uintptr_t)table.mult < codeaddr_module(&mod) + codesize_module(&mod)); // TEST testmodule_functable_t: execute functions TEST(5 == table.add(3,2)); TEST(6 == table.add(3,3)); TEST(0 == table.add(3,-3)); TEST(9 == table.sub(11,2)); TEST(-1== table.sub(11,12)); TEST(1 == table.sub(11,10)); TEST(8 == table.mult(2,4)); TEST(6 == table.mult(2,3)); TEST(9 == table.mult(3,3)); // unprepare TEST(0 == free_module(&mod)); } return 0; ONERR: free_module(&mod); return EINVAL; }