From 3abcaee63ff285514e8b51a60949c97a7dfa5304 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 24 Feb 2016 07:46:57 +0100 Subject: Cleanups and version bump --- src/emu/luaengine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/emu/luaengine.cpp') diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 990f417eac4..b8f1d0772ec 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -51,7 +51,7 @@ extern "C" { int luaopen_zlib(lua_State *L); int luaopen_luv(lua_State *L); int luaopen_lfs(lua_State *L); - uv_loop_t* luv_loop(lua_State* L); + uv_loop_t* luv_loop(lua_State* L); } static void lstop(lua_State *L, lua_Debug *ar) @@ -744,7 +744,7 @@ int lua_engine::lua_options_entry::l_entry_value(lua_State *L) luaL_error(L, "%s", error.c_str()); } } - + switch (e->type()) { case OPTION_BOOLEAN: @@ -1194,7 +1194,7 @@ lua_engine::lua_engine() lua_gc(m_lua_state, LUA_GCSTOP, 0); /* stop collector during initialization */ luaL_openlibs(m_lua_state); /* open libraries */ - // Get package.preload so we can store builtins in it. + // Get package.preload so we can store builtins in it. lua_getglobal(m_lua_state, "package"); lua_getfield(m_lua_state, -1, "preload"); lua_remove(m_lua_state, -2); // Remove package @@ -1205,13 +1205,13 @@ lua_engine::lua_engine() lua_pushcfunction(m_lua_state, luaopen_zlib); lua_setfield(m_lua_state, -2, "zlib"); - + lua_pushcfunction(m_lua_state, luaopen_lsqlite3); lua_setfield(m_lua_state, -2, "lsqlite3"); lua_pushcfunction(m_lua_state, luaopen_lfs); lua_setfield(m_lua_state, -2, "lfs"); - + luaopen_ioport(m_lua_state); lua_gc(m_lua_state, LUA_GCRESTART, 0); @@ -1668,7 +1668,7 @@ void lua_engine::periodic_check() auto loop = luv_loop(m_lua_state); if (loop!=nullptr) uv_run(loop, UV_RUN_NOWAIT); - + } //------------------------------------------------- -- cgit v1.2.3-70-g09d2 From 0f85f112c91334cbea3f87040edc3919384066be Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Thu, 25 Feb 2016 13:34:56 +0100 Subject: renamed names that clash system defines in various environments (nw) --- src/emu/luaengine.cpp | 18 +++++++----------- src/lib/netlist/nl_base.h | 22 +++++++++++----------- src/lib/netlist/nl_factory.h | 8 ++++---- 3 files changed, 22 insertions(+), 26 deletions(-) (limited to 'src/emu/luaengine.cpp') diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index b8f1d0772ec..32eccb8a85b 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -136,23 +136,19 @@ lua_engine::hook::hook() cb = -1; } -#if (defined(__sun__) && defined(__svr4__)) || defined(__ANDROID__) || defined(__OpenBSD__) -#undef _L -#endif - -void lua_engine::hook::set(lua_State *_L, int idx) +void lua_engine::hook::set(lua_State *lua, int idx) { if (L) luaL_unref(L, LUA_REGISTRYINDEX, cb); - if (lua_isnil(_L, idx)) { + if (lua_isnil(lua, idx)) { L = nullptr; cb = -1; } else { - L = _L; - lua_pushvalue(_L, idx); - cb = luaL_ref(_L, LUA_REGISTRYINDEX); + L = lua; + lua_pushvalue(lua, idx); + cb = luaL_ref(lua, LUA_REGISTRYINDEX); } } @@ -197,9 +193,9 @@ void lua_engine::resume(lua_State *L, int nparam, lua_State *root) } } -void lua_engine::resume(void *_L, INT32 param) +void lua_engine::resume(void *lua, INT32 param) { - resume(static_cast(_L)); + resume(static_cast(lua)); } int lua_engine::l_ioport_write(lua_State *L) diff --git a/src/lib/netlist/nl_base.h b/src/lib/netlist/nl_base.h index a47ca7c6fc5..5289a3171e0 100644 --- a/src/lib/netlist/nl_base.h +++ b/src/lib/netlist/nl_base.h @@ -1185,38 +1185,38 @@ namespace netlist ATTR_COLD net_t *find_net(const pstring &name); - template - ATTR_COLD plist_t<_C *> get_device_list() + template + ATTR_COLD plist_t<_device_class *> get_device_list() { - plist_t<_C *> tmp; + plist_t<_device_class *> tmp; for (std::size_t i = 0; i < m_devices.size(); i++) { - _C *dev = dynamic_cast<_C *>(m_devices[i]); + _device_class *dev = dynamic_cast<_device_class *>(m_devices[i]); if (dev != NULL) tmp.add(dev); } return tmp; } - template - ATTR_COLD _C *get_first_device() + template + ATTR_COLD _device_class *get_first_device() { for (std::size_t i = 0; i < m_devices.size(); i++) { - _C *dev = dynamic_cast<_C *>(m_devices[i]); + _device_class *dev = dynamic_cast<_device_class *>(m_devices[i]); if (dev != NULL) return dev; } return NULL; } - template - ATTR_COLD _C *get_single_device(const char *classname) + template + ATTR_COLD _device_class *get_single_device(const char *classname) { - _C *ret = NULL; + _device_class *ret = NULL; for (std::size_t i = 0; i < m_devices.size(); i++) { - _C *dev = dynamic_cast<_C *>(m_devices[i]); + _device_class *dev = dynamic_cast<_device_class *>(m_devices[i]); if (dev != NULL) { if (ret != NULL) diff --git a/src/lib/netlist/nl_factory.h b/src/lib/netlist/nl_factory.h index cc007960c6e..971912a0d2d 100644 --- a/src/lib/netlist/nl_factory.h +++ b/src/lib/netlist/nl_factory.h @@ -45,7 +45,7 @@ namespace netlist pstring m_def_param; /* default parameter */ }; - template + template class factory_t : public base_factory_t { P_PREVENT_COPYING(factory_t) @@ -56,7 +56,7 @@ namespace netlist ATTR_COLD device_t *Create() override { - device_t *r = palloc(C); + device_t *r = palloc(_device_class); //r->init(setup, name); return r; } @@ -68,11 +68,11 @@ namespace netlist factory_list_t(setup_t &m_setup); ~factory_list_t(); - template + template ATTR_COLD void register_device(const pstring &name, const pstring &classname, const pstring &def_param) { - if (!add(name, palloc(factory_t< _C >(name, classname, def_param)))) + if (!add(name, palloc(factory_t< _device_class >(name, classname, def_param)))) error("factory already contains " + name); } -- cgit v1.2.3-70-g09d2 From 3a811376d974de519c4ef74dff3e5b8719468f4a Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Fri, 26 Feb 2016 14:50:09 +0100 Subject: Made pnacl to compile (nw) --- 3rdparty/lua/src/liolib.c | 2 +- makefile | 9 +++++++-- scripts/genie.lua | 21 ++++++++++++++++++--- scripts/src/3rdparty.lua | 7 ++++--- scripts/src/main.lua | 18 +++++++++++++++--- src/emu/luaengine.cpp | 11 +++++++++-- 6 files changed, 54 insertions(+), 14 deletions(-) (limited to 'src/emu/luaengine.cpp') diff --git a/3rdparty/lua/src/liolib.c b/3rdparty/lua/src/liolib.c index a91ba391817..bb4bcf03d90 100644 --- a/3rdparty/lua/src/liolib.c +++ b/3rdparty/lua/src/liolib.c @@ -81,7 +81,7 @@ #if !defined(l_getc) /* { */ -#if defined(LUA_USE_POSIX) +#if defined(LUA_USE_POSIX) && !defined(__native_client__) #define l_getc(f) getc_unlocked(f) #define l_lockfile(f) flockfile(f) #define l_unlockfile(f) funlockfile(f) diff --git a/makefile b/makefile index 7671600b4df..0422f8a03a7 100644 --- a/makefile +++ b/makefile @@ -94,7 +94,8 @@ # FORCE_VERSION_COMPILE = 1 -# MS BUILD = 1 +# MSBUILD = 1 +# USE_LIBUV = 1 ifdef PREFIX_MAKEFILE include $(PREFIX_MAKEFILE) @@ -676,6 +677,10 @@ ifdef PLATFORM TARGET_PARAMS += --PLATFORM='$(PLATFORM)' endif +ifdef USE_LIBUV +PARAMS += --USE_LIBUV='$(USE_LIBUV)' +endif + #------------------------------------------------- # All scripts #------------------------------------------------- @@ -1024,7 +1029,7 @@ $(PROJECTDIR_MINI)/gmake-pnacl/Makefile: makefile $(SCRIPTS) $(GENIE) ifndef NACL_SDK_ROOT $(error NACL_SDK_ROOT is not set) endif - $(SILENT) $(GENIE) $(PARAMS) --gcc=pnacl --gcc_version=3.7.0 --osd=osdmini --targetos=pnacl --NOASM=1 gmake + $(SILENT) $(GENIE) $(PARAMS) --gcc=pnacl --gcc_version=3.7.0 --osd=osdmini --targetos=pnacl --NOASM=1 --USE_LIBUV=0 gmake .PHONY: pnacl pnacl: generate $(PROJECTDIR_MINI)/gmake-pnacl/Makefile diff --git a/scripts/genie.lua b/scripts/genie.lua index 2cf8916713f..329efb08a0a 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -387,6 +387,15 @@ newoption { description = "Target machine platform (x86,arm,...)", } +newoption { + trigger = "USE_LIBUV", + description = "Use libuv.", + allowed = { + { "0", "Disabled" }, + { "1", "Enabled" }, + } +} + if _OPTIONS["SHLIB"]=="1" then LIBTYPE = "SharedLib" else @@ -411,6 +420,10 @@ if not _OPTIONS["NOASM"] then end end +if not _OPTIONS["USE_LIBUV"] then + _OPTIONS["USE_LIBUV"] = "1" +end + if _OPTIONS["NOASM"]=="1" and not _OPTIONS["FORCE_DRC_C_BACKEND"] then _OPTIONS["FORCE_DRC_C_BACKEND"] = "1" end @@ -511,6 +524,11 @@ configuration { "gmake" } dofile ("toolchain.lua") +if _OPTIONS["USE_LIBUV"]=="0" then + defines { + "NO_LIBUV", + } +end if _OPTIONS["targetos"]=="windows" then configuration { "x64" } @@ -1023,9 +1041,6 @@ configuration { "android*" } "-Wno-tautological-constant-out-of-range-compare", "-Wno-tautological-pointer-compare", } - defines { - "_POSIX_BARRIERS=1", - } archivesplit_size "20" configuration { "pnacl" } diff --git a/scripts/src/3rdparty.lua b/scripts/src/3rdparty.lua index cfaa171bf64..72e0d0c24f4 100644 --- a/scripts/src/3rdparty.lua +++ b/scripts/src/3rdparty.lua @@ -513,7 +513,7 @@ project "lualibs" -------------------------------------------------- -- luv lua library objects -------------------------------------------------- - +if _OPTIONS["USE_LIBUV"]=="1" then project "luv" uuid "d98ec5ca-da2a-4a50-88a2-52061ca53871" kind "StaticLib" @@ -567,7 +567,7 @@ project "luv" MAME_DIR .. "3rdparty/luv/src/luv.c", MAME_DIR .. "3rdparty/luv/src/luv.h", } - +end -------------------------------------------------- -- SQLite3 library objects -------------------------------------------------- @@ -1007,6 +1007,7 @@ end -------------------------------------------------- -- libuv library objects -------------------------------------------------- +if _OPTIONS["USE_LIBUV"]=="1" then project "uv" uuid "cd2afe7f-139d-49c3-9000-fc9119f3cea0" kind "StaticLib" @@ -1196,7 +1197,7 @@ project "uv" "-Wshadow" } end - +end -------------------------------------------------- -- HTTP parser library objects -------------------------------------------------- diff --git a/scripts/src/main.lua b/scripts/src/main.lua index ad71d0a5cb7..2a4acab17a5 100644 --- a/scripts/src/main.lua +++ b/scripts/src/main.lua @@ -35,6 +35,14 @@ end "EGL", "GLESv2", } + configuration { "pnacl" } + kind "ConsoleApp" + targetextension ".pexe" + links { + "ppapi", + "ppapi_gles2", + "pthread", + } configuration { } addprojectflags() @@ -153,11 +161,15 @@ end "7z", "lua", "lualibs", - "luv", - "uv", - "http-parser", } + if _OPTIONS["USE_LIBUV"]=="1" then + links { + "luv", + "uv", + "http-parser", + } + end if _OPTIONS["with-bundled-zlib"] then links { "zlib", diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 32eccb8a85b..061305b3d9f 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -19,7 +19,9 @@ #include "ui/ui.h" #include "luaengine.h" #include +#if !defined(NO_LIBUV) #include "libuv/include/uv.h" +#endif //************************************************************************** // LUA ENGINE @@ -49,9 +51,11 @@ lua_engine* lua_engine::luaThis = nullptr; extern "C" { int luaopen_lsqlite3(lua_State *L); int luaopen_zlib(lua_State *L); - int luaopen_luv(lua_State *L); int luaopen_lfs(lua_State *L); +#if !defined(NO_LIBUV) + int luaopen_luv(lua_State *L); uv_loop_t* luv_loop(lua_State* L); +#endif } static void lstop(lua_State *L, lua_Debug *ar) @@ -1195,9 +1199,11 @@ lua_engine::lua_engine() lua_getfield(m_lua_state, -1, "preload"); lua_remove(m_lua_state, -2); // Remove package +#if !defined(NO_LIBUV) // Store uv module definition at preload.uv lua_pushcfunction(m_lua_state, luaopen_luv); lua_setfield(m_lua_state, -2, "luv"); +#endif lua_pushcfunction(m_lua_state, luaopen_zlib); lua_setfield(m_lua_state, -2, "zlib"); @@ -1661,10 +1667,11 @@ void lua_engine::periodic_check() msg.ready = 0; msg.done = 1; } +#if !defined(NO_LIBUV) auto loop = luv_loop(m_lua_state); if (loop!=nullptr) uv_run(loop, UV_RUN_NOWAIT); - +#endif } //------------------------------------------------- -- cgit v1.2.3-70-g09d2 From 0ba1d210934a92614e7c61247e9e6ef6a89870d8 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 27 Feb 2016 19:34:48 +0100 Subject: fix autoboot_command (nw) --- src/emu/luaengine.cpp | 13 ++++++++----- src/emu/luaengine.h | 1 + src/emu/machine.cpp | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/emu/luaengine.cpp') diff --git a/src/emu/luaengine.cpp b/src/emu/luaengine.cpp index 061305b3d9f..ecf1b418de5 100644 --- a/src/emu/luaengine.cpp +++ b/src/emu/luaengine.cpp @@ -1342,15 +1342,18 @@ void lua_engine::update_machine() } port = port->next(); } - machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_start), this)); - machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(lua_engine::on_machine_stop), this)); - machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(lua_engine::on_machine_pause), this)); - machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(lua_engine::on_machine_resume), this)); - machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(lua_engine::on_machine_frame), this)); } lua_setglobal(m_lua_state, "ioport"); } +void lua_engine::attach_notifiers() +{ + machine().add_notifier(MACHINE_NOTIFY_RESET, machine_notify_delegate(FUNC(lua_engine::on_machine_start), this)); + machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(lua_engine::on_machine_stop), this)); + machine().add_notifier(MACHINE_NOTIFY_PAUSE, machine_notify_delegate(FUNC(lua_engine::on_machine_pause), this)); + machine().add_notifier(MACHINE_NOTIFY_RESUME, machine_notify_delegate(FUNC(lua_engine::on_machine_resume), this)); + machine().add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(FUNC(lua_engine::on_machine_frame), this)); +} //------------------------------------------------- // initialize - initialize lua hookup to emu engine diff --git a/src/emu/luaengine.h b/src/emu/luaengine.h index fca3a564618..908a82a8f0b 100644 --- a/src/emu/luaengine.h +++ b/src/emu/luaengine.h @@ -51,6 +51,7 @@ public: void resume(lua_State *L, int nparam = 0, lua_State *root = nullptr); void set_machine(running_machine *machine) { m_machine = machine; update_machine(); } + void attach_notifiers(); private: struct hook { lua_State *L; diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp index 0c8d85a4540..643d8bb6801 100644 --- a/src/emu/machine.cpp +++ b/src/emu/machine.cpp @@ -321,6 +321,7 @@ void running_machine::start() m_favorite = std::make_unique(*this); manager().update_machine(); + manager().lua()->attach_notifiers(); } -- cgit v1.2.3-70-g09d2