diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/devdelegate.h | 37 | ||||
-rw-r--r-- | src/frontend/mame/infoxml.cpp | 169 | ||||
-rw-r--r-- | src/lib/util/delegate.h | 9 | ||||
-rw-r--r-- | src/mame/brother/lw350.cpp | 13 | ||||
-rw-r--r-- | src/mame/psikyo/psikyo.cpp | 2 | ||||
-rw-r--r-- | src/mame/sanyo/mbc200.cpp | 11 | ||||
-rw-r--r-- | src/mame/sega/segas16a.cpp | 6 | ||||
-rw-r--r-- | src/mame/skeleton/freedom220.cpp | 7 | ||||
-rw-r--r-- | src/osd/modules/debugger/win/consolewininfo.cpp | 12 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib.h | 28 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_macosx.cpp | 10 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_unix.cpp | 10 | ||||
-rw-r--r-- | src/osd/modules/lib/osdlib_win32.cpp | 10 | ||||
-rw-r--r-- | src/osd/osdcore.h | 2 | ||||
-rw-r--r-- | src/osd/osdsync.cpp | 71 |
15 files changed, 247 insertions, 150 deletions
diff --git a/src/emu/devdelegate.h b/src/emu/devdelegate.h index a2465985c13..6b405ee0303 100644 --- a/src/emu/devdelegate.h +++ b/src/emu/devdelegate.h @@ -115,6 +115,16 @@ public: void reset() noexcept { basetype::reset(); m_name = nullptr; } }; +template <class FunctionClass, typename ReturnType, typename... Params> +named_delegate(ReturnType (FunctionClass::*)(Params...), char const *, FunctionClass *) -> named_delegate<ReturnType (Params...)>; + +template <class FunctionClass, typename ReturnType, typename... Params> +named_delegate(ReturnType (FunctionClass::*)(Params...) const, char const *, FunctionClass *) -> named_delegate<ReturnType (Params...)>; + +template <class FunctionClass, typename ReturnType, typename... Params> +named_delegate(ReturnType (*)(FunctionClass &, Params...), char const *, FunctionClass *) -> named_delegate<ReturnType (Params...)>; + + // ======================> device_delegate // device_delegate is a delegate that wraps with a device tag and can be easily @@ -290,6 +300,33 @@ public: } }; +template <class D, typename ReturnType, typename... Params> +device_delegate(device_t &, char const *, ReturnType (D::*)(Params...), char const *) -> device_delegate<ReturnType (Params...)>; + +template <class D, typename ReturnType, typename... Params> +device_delegate(device_t &, char const *, ReturnType (D::*)(Params...) const, char const *) -> device_delegate<ReturnType (Params...)>; + +template <class D, typename ReturnType, typename... Params> +device_delegate(device_t &, char const *, ReturnType (*)(D &, Params...), char const *) -> device_delegate<ReturnType (Params...)>; + +template <class D, bool R, class E, typename ReturnType, typename... Params> +device_delegate(device_finder<D, R> const &, ReturnType (E::*)(Params...), char const *) -> device_delegate<ReturnType (Params...)>; + +template <class D, bool R, class E, typename ReturnType, typename... Params> +device_delegate(device_finder<D, R> const &, ReturnType (E::*)(Params...) const, char const *) -> device_delegate<ReturnType (Params...)>; + +template <class D, bool R, class E, typename ReturnType, typename... Params> +device_delegate(device_finder<D, R> const &, ReturnType (*)(E &, Params...), char const *) -> device_delegate<ReturnType (Params...)>; + +template <class T, class D, typename ReturnType, typename... Params> +device_delegate(T &, ReturnType (D::*)(Params...), char const *) -> device_delegate<ReturnType (Params...)>; + +template <class T, class D, typename ReturnType, typename... Params> +device_delegate(T &, ReturnType (D::*)(Params...) const, char const *) -> device_delegate<ReturnType (Params...)>; + +template <class T, class D, typename ReturnType, typename... Params> +device_delegate(T &, ReturnType (*)(D &, Params...), char const *) -> device_delegate<ReturnType (Params...)>; + } // namespace emu diff --git a/src/frontend/mame/infoxml.cpp b/src/frontend/mame/infoxml.cpp index fa0d998aa1b..31651bef2b6 100644 --- a/src/frontend/mame/infoxml.cpp +++ b/src/frontend/mame/infoxml.cpp @@ -102,7 +102,8 @@ private: }; -typedef std::set<std::add_pointer_t<device_type>, device_type_compare> device_type_set; +using device_type_set = std::set<std::add_pointer_t<device_type>, device_type_compare>; +using device_type_vector = std::vector<std::add_pointer_t<device_type> >; // internal helper void output_header(std::ostream &out, bool dtd); @@ -449,11 +450,6 @@ void info_xml_creator::output(std::ostream &out, const std::function<bool(const device_type_set m_dev_set; }; - // TODO: maybe not the best place for this as it affects the stream passed in - // if the device part is threaded, the local streams used by the tasks can be - // imbued and the stream passed in can be left alone - out.imbue(std::locale::classic()); - // prepare a driver enumerator and the queue driver_enumerator drivlist(m_lookup_options); device_filter devfilter(filter); @@ -461,14 +457,14 @@ void info_xml_creator::output(std::ostream &out, const std::function<bool(const bool header_outputted = false; // essentially a local method to emit the header if necessary - auto output_header_if_necessary = [this, &header_outputted](std::ostream &out) - { - if (!header_outputted) - { - output_header(out, m_dtd); - header_outputted = true; - } - }; + auto const output_header_if_necessary = [this, &header_outputted] (std::ostream &out) + { + if (!header_outputted) + { + output_header(out, m_dtd); + header_outputted = true; + } + }; // only keep a device set when we're asked to track it std::optional<device_type_set> devset; @@ -477,14 +473,14 @@ void info_xml_creator::output(std::ostream &out, const std::function<bool(const // prepare a queue of tasks - this is a FIFO queue because of the // need to be deterministic - std::queue<std::future<prepared_info>> tasks; + std::queue<std::future<prepared_info> > tasks; // while we want to be deterministic, asynchronous task scheduling is not; so we want to // track the amount of active tasks so that we can keep on spawning tasks even if we're // waiting on the task in the front of the queue std::atomic<unsigned int> active_task_count = 0; - unsigned int maximum_active_task_count = std::thread::hardware_concurrency() + 10; - unsigned int maximum_outstanding_task_count = maximum_active_task_count + 20; + unsigned int const maximum_active_task_count = std::thread::hardware_concurrency() + 10; + unsigned int const maximum_outstanding_task_count = maximum_active_task_count + 20; // loop until we're done enumerating drivers, and until there are no outstanding tasks while (!filtered_drivlist.done() || !tasks.empty()) @@ -492,32 +488,32 @@ void info_xml_creator::output(std::ostream &out, const std::function<bool(const // loop until there are as many outstanding tasks as possible (we want to separately cap outstanding // tasks and active tasks) while (!filtered_drivlist.done() - && active_task_count < maximum_active_task_count - && tasks.size() < maximum_outstanding_task_count) + && (active_task_count < maximum_active_task_count) + && (tasks.size() < maximum_outstanding_task_count)) { // we want to launch a task; grab a packet of drivers to process - std::vector<std::reference_wrapper<const game_driver>> drivers = filtered_drivlist.next(20); + std::vector<std::reference_wrapper<const game_driver> > drivers = filtered_drivlist.next(20); if (drivers.empty()) break; - // do the dirty work asychronously - auto task_proc = [&drivlist, drivers{ std::move(drivers) }, include_devices, &active_task_count] - { - prepared_info result; - std::ostringstream stream; - stream.imbue(std::locale::classic()); + // do the dirty work asynchronously + auto task_proc = [&drivlist, drivers = std::move(drivers), include_devices, &active_task_count] + { + prepared_info result; + std::ostringstream stream; + stream.imbue(std::locale::classic()); - // output each of the drivers - for (const game_driver &driver : drivers) - output_one(stream, drivlist, driver, include_devices ? &result.m_dev_set : nullptr); + // output each of the drivers + for (const game_driver &driver : drivers) + output_one(stream, drivlist, driver, include_devices ? &result.m_dev_set : nullptr); - // capture the XML snippet - result.m_xml_snippet = stream.str(); + // capture the XML snippet + result.m_xml_snippet = std::move(stream).str(); - // we're done with the task; decrement the counter and return - active_task_count--; - return result; - }; + // we're done with the task; decrement the counter and return + active_task_count--; + return result; + }; // add this task to the queue active_task_count++; @@ -527,8 +523,7 @@ void info_xml_creator::output(std::ostream &out, const std::function<bool(const // we've put as many outstanding tasks out as we can; are there any tasks outstanding? if (!tasks.empty()) { - // wait for the task at the front of the queue to complete and get the info, in the - // spirit of determinism + // wait for the oldest task to complete and get the info, in the spirit of determinism prepared_info pi = tasks.front().get(); tasks.pop(); @@ -593,9 +588,10 @@ bool device_filter::filter(const char *shortname) // of game_drivers, while applying filters //------------------------------------------------- -std::vector<std::reference_wrapper<const game_driver>> filtered_driver_enumerator::next(int count) +std::vector<std::reference_wrapper<const game_driver> > filtered_driver_enumerator::next(int count) { - std::vector<std::reference_wrapper<const game_driver>> results; + std::vector<std::reference_wrapper<const game_driver> > results; + results.reserve(count); while (!done() && results.size() < count) { if (!m_drivlist.next()) @@ -607,7 +603,7 @@ std::vector<std::reference_wrapper<const game_driver>> filtered_driver_enumerato else if (m_devfilter.filter(m_drivlist.driver().name)) { const game_driver &driver(m_drivlist.driver()); - results.push_back(driver); + results.emplace_back(driver); } } return results; @@ -864,38 +860,85 @@ void output_one_device(std::ostream &out, machine_config &config, device_t &devi void output_devices(std::ostream &out, emu_options &lookup_options, device_type_set const *filter) { - // get config for empty machine - machine_config config(GAME_NAME(___empty), lookup_options); - - auto const action = [&config, &out] (device_type type) + auto const action = [&lookup_options, &out] (auto &types, auto deref) { - // add it at the root of the machine config - device_t *dev; + // machinery for making output order deterministic and capping outstanding tasks + std::queue<std::future<std::string> > tasks; + std::atomic<unsigned int> active_task_count = 0; + unsigned int const maximum_active_task_count = std::thread::hardware_concurrency() + 10; + unsigned int const maximum_outstanding_task_count = maximum_active_task_count + 20; + + // loop until we're done enumerating devices and there are no outstanding tasks + auto it = std::begin(types); + while ((std::end(types) != it) || !tasks.empty()) { - machine_config::token const tok(config.begin_configuration(config.root_device())); - dev = config.device_add("_tmp", type, 0); - } + // look until there are as many outstanding tasks as possible + while ((std::end(types) != it) + && (active_task_count < maximum_active_task_count) + && (tasks.size() < maximum_outstanding_task_count)) + { + device_type_vector batch; + batch.reserve(10); + while ((std::end(types) != it) && (batch.size() < 10)) + batch.emplace_back(deref(*it++)); + if (batch.empty()) + break; - // notify this device and all its subdevices that they are now configured - for (device_t &device : device_enumerator(*dev)) - if (!device.configured()) - device.config_complete(); + // do the dirty work asynchronously + auto task_proc = [&active_task_count, &lookup_options, batch = std::move(batch)] + { + // use a single machine configuration and stream for a batch of devices + machine_config config(GAME_NAME(___empty), lookup_options); + std::ostringstream stream; + stream.imbue(std::locale::classic()); + for (auto type : batch) + { + // add it at the root of the machine config + device_t *dev; + { + machine_config::token const tok(config.begin_configuration(config.root_device())); + dev = config.device_add("_tmp", *type, 0); + } + + // notify this device and all its subdevices that they are now configured + for (device_t &device : device_enumerator(*dev)) + if (!device.configured()) + device.config_complete(); + + // print details and remove it + output_one_device(stream, config, *dev, dev->tag()); + machine_config::token const tok(config.begin_configuration(config.root_device())); + config.device_remove("_tmp"); + } + + // we're done with the task; decrement the counter and return + active_task_count--; + return std::move(stream).str(); + }; + + // add this task to the queue + active_task_count++; + tasks.emplace(std::async(std::launch::async, std::move(task_proc))); + } + + // we've put as many outstanding tasks out as we can; are there any tasks outstanding? + if (!tasks.empty()) + { + // wait for the oldest task to complete and get the info, in the spirit of determinism + std::string snippet = tasks.front().get(); + tasks.pop(); - // print details and remove it - output_one_device(out, config, *dev, dev->tag()); - machine_config::token const tok(config.begin_configuration(config.root_device())); - config.device_remove("_tmp"); + // emit whatever XML we accumulated in the task + out << snippet; + } + } }; // run through devices if (filter) - { - for (std::add_pointer_t<device_type> type : *filter) action(*type); - } + action(*filter, [] (auto &x) { return x; }); else - { - for (device_type type : registered_device_types) action(type); - } + action(registered_device_types, [] (auto &x) { return &x; }); } diff --git a/src/lib/util/delegate.h b/src/lib/util/delegate.h index df1d6ebcba3..3c0745bf0c5 100644 --- a/src/lib/util/delegate.h +++ b/src/lib/util/delegate.h @@ -969,4 +969,13 @@ public: } }; +template <class FunctionClass, typename ReturnType, typename... Params> +delegate(ReturnType (FunctionClass::*)(Params...), FunctionClass *) -> delegate<ReturnType (Params...)>; + +template <class FunctionClass, typename ReturnType, typename... Params> +delegate(ReturnType (FunctionClass::*)(Params...) const, FunctionClass *) -> delegate<ReturnType (Params...)>; + +template <class FunctionClass, typename ReturnType, typename... Params> +delegate(ReturnType (*)(FunctionClass &, Params...), FunctionClass *) -> delegate<ReturnType (Params...)>; + #endif // MAME_LIB_UTIL_DELEGATE_H diff --git a/src/mame/brother/lw350.cpp b/src/mame/brother/lw350.cpp index f8fcd85655d..e59ecefb151 100644 --- a/src/mame/brother/lw350.cpp +++ b/src/mame/brother/lw350.cpp @@ -193,9 +193,9 @@ private: map(0x00000, 0x01fff).rom(); map(0x02000, 0x05fff).ram(); map(0x06000, 0x3ffff).rom(); - map(0x40000, 0x5ffff).bankr("rom"); + map(0x40000, 0x5ffff).bankr(rombank); map(0x60000, 0x617ff).ram(); - map(0x61800, 0x63fff).ram().share("vram"); + map(0x61800, 0x63fff).ram().share(vram); map(0x64000, 0x71fff).ram(); map(0x72000, 0x75fff).rom().region("maincpu", 0x2000); // => ROM 0x02000-0x05fff map(0x76000, 0x7ffff).ram(); @@ -209,8 +209,9 @@ private: // floppy map(0x78, 0x78).rw(fdc, FUNC(upd765a_device::msr_r), FUNC(hd63266f_device::abort_w)); - map(0x79, 0x79).lrw8([this](){ return (fdc_drq ? fdc->dma_r() : fdc->fifo_r()); }, "fdc_r", - [this](u8 data) { fdc_drq ? fdc->dma_w(data) : fdc->fifo_w(data); }, "fdc_w"); + map(0x79, 0x79).lrw8( + [this] () { return (fdc_drq ? fdc->dma_r() : fdc->fifo_r()); }, "fdc_r", + [this] (u8 data) { fdc_drq ? fdc->dma_w(data) : fdc->fifo_w(data); }, "fdc_w"); map(0x7a, 0x7a).r(fdc, FUNC(hd63266f_device::extstat_r)); map(0x7e, 0x7e).rw(FUNC(lw350_state::io_7e_r), FUNC(lw350_state::io_7e_w)); map(0x90, 0x90).r(FUNC(lw350_state::io_90_r)); @@ -663,11 +664,11 @@ void lw450_state::map_program(address_map &map) map(0x00000, 0x01fff).rom(); map(0x02000, 0x05fff).ram(); map(0x06000, 0x3ffff).rom(); - map(0x40000, 0x5ffff).bankr("dictionary"); + map(0x40000, 0x5ffff).bankr(rombank); map(0x62000, 0x71fff).ram(); // D-RAM UPPER/LOWER map(0x72000, 0x75fff).r(FUNC(lw450_state::rom72000_r)); // => ROM 0x02000-0x05fff map(0x78000, 0x7ffff).ram(); // PS-RAM - map(0xf8000, 0xfffff).ram().share("vram"); // VRAM + map(0xf8000, 0xfffff).ram().share(vram); // VRAM // text vram @ F8000-F8C80 (2*80 bytes/line) // font @ FC000-FD000 pitch 16 } diff --git a/src/mame/psikyo/psikyo.cpp b/src/mame/psikyo/psikyo.cpp index d2110b0e168..11bfb568f7c 100644 --- a/src/mame/psikyo/psikyo.cpp +++ b/src/mame/psikyo/psikyo.cpp @@ -1174,7 +1174,7 @@ void psikyo_state::s1945(machine_config &config) /* video hardware */ SCREEN(config, m_screen, SCREEN_TYPE_RASTER); - m_screen->set_raw(14.3181_MHz_XTAL / 2, 456, 0, 320, 262, 0, 223); // Approximately 59.923Hz, 39 HSync pulses in VBlank + m_screen->set_raw(14.318181_MHz_XTAL / 2, 456, 0, 320, 262, 0, 223); // Approximately 59.923Hz, 39 HSync pulses in VBlank m_screen->set_screen_update(FUNC(psikyo_state::screen_update)); m_screen->screen_vblank().set(FUNC(psikyo_state::screen_vblank)); diff --git a/src/mame/sanyo/mbc200.cpp b/src/mame/sanyo/mbc200.cpp index ff7d1d14fd9..75025256720 100644 --- a/src/mame/sanyo/mbc200.cpp +++ b/src/mame/sanyo/mbc200.cpp @@ -125,7 +125,7 @@ void mbc200_state::main_mem(address_map &map) void mbc200_state::p1_portc_w(u8 data) { - m_speaker->level_w(BIT(data,4)); // used by beep command in basic + m_speaker->level_w(BIT(data, 4)); // used by beep command in basic } void mbc200_state::pm_porta_w(u8 data) @@ -137,13 +137,12 @@ void mbc200_state::pm_porta_w(u8 data) void mbc200_state::pm_portb_w(u8 data) { - floppy_image_device *floppy = nullptr; - // The BIOS supports up tp 4 drives, (2 internal + 2 external) // E: and F: are virtual swaps of A: and B: - u8 tmp = (data & 0x70)>>4; - if (tmp < 4) - floppy = m_floppy[tmp]->get_device(); + u8 const drivenum = (data & 0x70) >> 4; + floppy_image_device *floppy = nullptr; + if (drivenum < 4) + floppy = m_floppy[drivenum]->get_device(); m_fdc->set_floppy(floppy); diff --git a/src/mame/sega/segas16a.cpp b/src/mame/sega/segas16a.cpp index 03bafb7bb11..0e3d6be97d0 100644 --- a/src/mame/sega/segas16a.cpp +++ b/src/mame/sega/segas16a.cpp @@ -152,9 +152,11 @@ Tetris - - - - EPR12169 EPR12170 - #include "fd1089.h" #include "fd1094.h" + #include "machine/nvram.h" #include "machine/segacrp2_device.h" #include "sound/dac.h" + #include "speaker.h" @@ -3927,7 +3929,7 @@ void segas16a_state::init_aceattaca() void segas16a_state::init_dumpmtmt() { init_generic(); - m_i8751_vblank_hook = i8751_sim_delegate(&segas16a_state::dumpmtmt_i8751_sim, this); + m_i8751_vblank_hook = delegate(&segas16a_state::dumpmtmt_i8751_sim, this); } void segas16a_state::init_mjleague() @@ -3952,7 +3954,7 @@ void segas16a_state::init_sjryukoa() { init_generic(); m_custom_io_r = read16sm_delegate(*this, FUNC(segas16a_state::sjryuko_custom_io_r)); - m_lamp_changed_w = lamp_changed_delegate(&segas16a_state::sjryuko_lamp_changed_w, this); + m_lamp_changed_w = delegate(&segas16a_state::sjryuko_lamp_changed_w, this); } diff --git a/src/mame/skeleton/freedom220.cpp b/src/mame/skeleton/freedom220.cpp index 94ac92a763f..1050ad3c861 100644 --- a/src/mame/skeleton/freedom220.cpp +++ b/src/mame/skeleton/freedom220.cpp @@ -90,6 +90,9 @@ private: required_shared_ptr_array<uint8_t, 2> m_charram; required_shared_ptr_array<uint8_t, 2> m_attrram; + uint8_t m_current_line; + bool m_nmi_enabled; + void mem_map(address_map &map); void io_map(address_map &map); @@ -101,9 +104,7 @@ private: SCN2674_DRAW_CHARACTER_MEMBER(draw_character); void nmi_control_w(uint8_t data); - - uint8_t m_current_line; - bool m_nmi_enabled; + void nmi_w(int state); }; diff --git a/src/osd/modules/debugger/win/consolewininfo.cpp b/src/osd/modules/debugger/win/consolewininfo.cpp index 1c70cb8e7a0..3a4a52be2e2 100644 --- a/src/osd/modules/debugger/win/consolewininfo.cpp +++ b/src/osd/modules/debugger/win/consolewininfo.cpp @@ -556,9 +556,11 @@ void consolewin_info::open_image_file(device_image_interface &device) window(), CLSID_FileOpenDialog, true, - [&device] (std::string_view selection) + [this, &device] (std::string_view selection) { - device.load(selection); + auto [err, message] = device.load(selection); + if (err) + machine().debugger().console().printf("Error mounting image file: %s\n", !message.empty() ? message : err.message()); }); } @@ -570,9 +572,11 @@ void consolewin_info::create_image_file(device_image_interface &device) window(), CLSID_FileSaveDialog, false, - [&device] (std::string_view selection) + [this, &device] (std::string_view selection) { - device.create(selection, device.device_get_indexed_creatable_format(0), nullptr); + auto [err, message] = device.create(selection, device.device_get_indexed_creatable_format(0), nullptr); + if (err) + machine().debugger().console().printf("Error creating image file: %s\n", !message.empty() ? message : err.message()); }); } diff --git a/src/osd/modules/lib/osdlib.h b/src/osd/modules/lib/osdlib.h index c84901002ad..72815d687db 100644 --- a/src/osd/modules/lib/osdlib.h +++ b/src/osd/modules/lib/osdlib.h @@ -78,7 +78,7 @@ std::error_condition osd_set_clipboard_text(std::string_view text) noexcept; namespace osd { -bool invalidate_instruction_cache(void const *start, std::size_t size); +bool invalidate_instruction_cache(void const *start, std::size_t size) noexcept; class virtual_memory_allocation @@ -98,12 +98,12 @@ public: virtual_memory_allocation(virtual_memory_allocation const &) = delete; virtual_memory_allocation &operator=(virtual_memory_allocation const &) = delete; - virtual_memory_allocation() { } - virtual_memory_allocation(std::initializer_list<std::size_t> blocks, unsigned intent) + virtual_memory_allocation() noexcept { } + virtual_memory_allocation(std::initializer_list<std::size_t> blocks, unsigned intent) noexcept { m_memory = do_alloc(blocks, intent, m_size, m_page_size); } - virtual_memory_allocation(virtual_memory_allocation &&that) : m_memory(that.m_memory), m_size(that.m_size), m_page_size(that.m_page_size) + virtual_memory_allocation(virtual_memory_allocation &&that) noexcept : m_memory(that.m_memory), m_size(that.m_size), m_page_size(that.m_page_size) { that.m_memory = nullptr; that.m_size = that.m_page_size = 0U; @@ -114,12 +114,12 @@ public: do_free(m_memory, m_size); } - explicit operator bool() const { return bool(m_memory); } - void *get() { return m_memory; } - std::size_t size() const { return m_size; } - std::size_t page_size() const { return m_page_size; } + explicit operator bool() const noexcept { return bool(m_memory); } + void *get() noexcept { return m_memory; } + std::size_t size() const noexcept { return m_size; } + std::size_t page_size() const noexcept { return m_page_size; } - bool set_access(std::size_t start, std::size_t size, unsigned access) + bool set_access(std::size_t start, std::size_t size, unsigned access) noexcept { if ((start % m_page_size) || (size % m_page_size) || (start > m_size) || ((m_size - start) < size)) return false; @@ -127,7 +127,7 @@ public: return do_set_access(reinterpret_cast<std::uint8_t *>(m_memory) + start, size, access); } - virtual_memory_allocation &operator=(std::nullptr_t) + virtual_memory_allocation &operator=(std::nullptr_t) noexcept { if (m_memory) do_free(m_memory, m_size); @@ -136,7 +136,7 @@ public: return *this; } - virtual_memory_allocation &operator=(virtual_memory_allocation &&that) + virtual_memory_allocation &operator=(virtual_memory_allocation &&that) noexcept { if (&that != this) { @@ -152,9 +152,9 @@ public: } private: - static void *do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size); - static void do_free(void *start, std::size_t size); - static bool do_set_access(void *start, std::size_t size, unsigned access); + static void *do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) noexcept; + static void do_free(void *start, std::size_t size) noexcept; + static bool do_set_access(void *start, std::size_t size, unsigned access) noexcept; void *m_memory = nullptr; std::size_t m_size = 0U, m_page_size = 0U; diff --git a/src/osd/modules/lib/osdlib_macosx.cpp b/src/osd/modules/lib/osdlib_macosx.cpp index 8f61bb4e998..9d13f118ff2 100644 --- a/src/osd/modules/lib/osdlib_macosx.cpp +++ b/src/osd/modules/lib/osdlib_macosx.cpp @@ -218,7 +218,7 @@ std::error_condition osd_set_clipboard_text(std::string_view text) noexcept // osd_getpid //============================================================ -int osd_getpid() +int osd_getpid() noexcept { return getpid(); } @@ -282,7 +282,7 @@ private: } // anonymous namespace -bool invalidate_instruction_cache(void const *start, std::size_t size) +bool invalidate_instruction_cache(void const *start, std::size_t size) noexcept { char const *const begin(reinterpret_cast<char const *>(start)); char const *const end(begin + size); @@ -291,7 +291,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size) } -void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) +void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) noexcept { long const p(sysconf(_SC_PAGE_SIZE)); if (0 >= p) @@ -310,12 +310,12 @@ void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blo return result; } -void virtual_memory_allocation::do_free(void *start, std::size_t size) +void virtual_memory_allocation::do_free(void *start, std::size_t size) noexcept { munmap(start, size); } -bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) +bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) noexcept { int prot((NONE == access) ? PROT_NONE : 0); if (access & READ) diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp index 0c6eb8622ab..20f6a9ab40c 100644 --- a/src/osd/modules/lib/osdlib_unix.cpp +++ b/src/osd/modules/lib/osdlib_unix.cpp @@ -135,7 +135,7 @@ std::error_condition osd_set_clipboard_text(std::string_view text) noexcept // osd_getpid //============================================================ -int osd_getpid() +int osd_getpid() noexcept { return getpid(); } @@ -199,7 +199,7 @@ private: } // anonymous namespace -bool invalidate_instruction_cache(void const *start, std::size_t size) +bool invalidate_instruction_cache(void const *start, std::size_t size) noexcept { #if !defined(SDLMAME_EMSCRIPTEN) char const *const begin(reinterpret_cast<char const *>(start)); @@ -210,7 +210,7 @@ bool invalidate_instruction_cache(void const *start, std::size_t size) } -void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) +void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) noexcept { long const p(sysconf(_SC_PAGE_SIZE)); if (0 >= p) @@ -247,12 +247,12 @@ void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blo return result; } -void virtual_memory_allocation::do_free(void *start, std::size_t size) +void virtual_memory_allocation::do_free(void *start, std::size_t size) noexcept { munmap(reinterpret_cast<char *>(start), size); } -bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) +bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) noexcept { int prot((NONE == access) ? PROT_NONE : 0); if (access & READ) diff --git a/src/osd/modules/lib/osdlib_win32.cpp b/src/osd/modules/lib/osdlib_win32.cpp index 23e75bf9dc2..d42ad14d3df 100644 --- a/src/osd/modules/lib/osdlib_win32.cpp +++ b/src/osd/modules/lib/osdlib_win32.cpp @@ -253,7 +253,7 @@ std::error_condition osd_set_clipboard_text(std::string_view text) noexcept // osd_getpid //============================================================ -int osd_getpid() +int osd_getpid() noexcept { return GetCurrentProcessId(); } @@ -324,13 +324,13 @@ private: } // anonymous namespace -bool invalidate_instruction_cache(void const *start, std::size_t size) +bool invalidate_instruction_cache(void const *start, std::size_t size) noexcept { return FlushInstructionCache(GetCurrentProcess(), start, size) != 0; } -void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) +void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blocks, unsigned intent, std::size_t &size, std::size_t &page_size) noexcept { SYSTEM_INFO info; GetSystemInfo(&info); @@ -349,12 +349,12 @@ void *virtual_memory_allocation::do_alloc(std::initializer_list<std::size_t> blo return result; } -void virtual_memory_allocation::do_free(void *start, std::size_t size) +void virtual_memory_allocation::do_free(void *start, std::size_t size) noexcept { VirtualFree(start, 0, MEM_RELEASE); } -bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) +bool virtual_memory_allocation::do_set_access(void *start, std::size_t size, unsigned access) noexcept { DWORD p; if (access & EXECUTE) diff --git a/src/osd/osdcore.h b/src/osd/osdcore.h index c714b4b313e..f3f5fc2e9b3 100644 --- a/src/osd/osdcore.h +++ b/src/osd/osdcore.h @@ -35,7 +35,7 @@ const char *osd_getenv(const char *name); /// \brief Get current process ID /// /// \return The process ID of the current process. -int osd_getpid(); +int osd_getpid() noexcept; /*----------------------------------------------------------------------------- diff --git a/src/osd/osdsync.cpp b/src/osd/osdsync.cpp index 3fa32f9141c..b2300e93ee6 100644 --- a/src/osd/osdsync.cpp +++ b/src/osd/osdsync.cpp @@ -104,26 +104,27 @@ int osd_get_num_processors(bool heavy_mt) struct work_thread_info { work_thread_info(uint32_t aid, osd_work_queue &aqueue) - : queue(aqueue) - , handle(nullptr) - , wakeevent(true, false) // manual reset, not signalled - , id(aid) + : queue(aqueue) + , handle(nullptr) + , wakeevent(true, false) // manual reset, not signalled + , id(aid) #if KEEP_STATISTICS - , itemsdone(0) - , actruntime(0) - , runtime(0) - , spintime(0) - , waittime(0) + , itemsdone(0) + , actruntime(0) + , runtime(0) + , spintime(0) + , waittime(0) #endif { } + osd_work_queue & queue; // pointer back to the queue std::thread * handle; // handle to the thread osd_event wakeevent; // wake event for the thread - uint32_t id; + uint32_t id; #if KEEP_STATISTICS - int32_t itemsdone; + int32_t itemsdone; osd_ticks_t actruntime; osd_ticks_t runtime; osd_ticks_t spintime; @@ -135,21 +136,21 @@ struct work_thread_info struct osd_work_queue { osd_work_queue() - : list(nullptr) - , tailptr(nullptr) - , free(nullptr) - , items(0) - , livethreads(0) - , waiting(0) - , exiting(0) - , threads(0) - , flags(0) - , doneevent(true, true) // manual reset, signalled + : list(nullptr) + , tailptr(nullptr) + , free(nullptr) + , items(0) + , livethreads(0) + , waiting(0) + , exiting(0) + , threads(0) + , flags(0) + , doneevent(true, true) // manual reset, signalled #if KEEP_STATISTICS - , itemsqueued(0) - , setevents(0) - , extraitems(0) - , spinloops(0) + , itemsqueued(0) + , setevents(0) + , extraitems(0) + , spinloops(0) #endif { } @@ -179,14 +180,14 @@ struct osd_work_queue struct osd_work_item { osd_work_item(osd_work_queue &aqueue) - : next(nullptr) - , queue(aqueue) - , callback(nullptr) - , param(nullptr) - , result(nullptr) - , event(nullptr) // manual reset, not signalled - , flags(0) - , done(false) + : next(nullptr) + , queue(aqueue) + , callback(nullptr) + , param(nullptr) + , result(nullptr) + , event(nullptr) // manual reset, not signalled + , flags(0) + , done(false) { } @@ -196,7 +197,7 @@ struct osd_work_item void * param; // callback parameter void * result; // callback result osd_event * event; // event signalled when complete - uint32_t flags; // creation flags + uint32_t flags; // creation flags std::atomic<int32_t> done; // is the item done? }; @@ -211,7 +212,7 @@ int osd_num_processors = 0; //============================================================ static int effective_num_processors(bool heavy_mt); -static void * worker_thread_entry(void *param); +static void *worker_thread_entry(void *param); static void worker_thread_process(osd_work_queue *queue, work_thread_info *thread); static bool queue_has_list_items(osd_work_queue *queue); |