use the magic macros in mips.cpp, change signature of stuff in floppy.h to hint that it needs an array, not just a pointer, although it doesn't actually warn if you just give a pointer anyway (nw)

This commit is contained in:
Vas Crabb 2018-11-29 17:00:05 +11:00
parent 07c6c3e2ab
commit 7bdd411be0
3 changed files with 15 additions and 11 deletions

View File

@ -145,7 +145,7 @@ floppy_connector::~floppy_connector()
{
}
void floppy_connector::set_formats(const floppy_format_type *_formats)
void floppy_connector::set_formats(const floppy_format_type _formats[])
{
formats = _formats;
}
@ -252,11 +252,7 @@ void floppy_image_device::set_formats(const floppy_format_type *formats)
{
extension_list[0] = '\0';
fif_list = nullptr;
// FIXME: this code previously treated formats as an array, but none of the actual formats in src/lib/formats provide an array - they all just supply a single function pointer
// This happens to work by chance if the next poitner-sized piece of BSS data happens to be zero, which it is most of the time.
// However, for some reason on a Linux clang 6 build it sometimes isn't, causing a lovely crash here.
// If this is supposed to be a nullptr-terminated array of function pointers, the code needs to be changed to better enforce it.
for(int cnt=0; /*formats[cnt]*/ !cnt; cnt++)
for(int cnt=0; formats[cnt]; cnt++)
{
// allocate a new format
floppy_image_format_t *fif = formats[cnt]();

View File

@ -317,7 +317,7 @@ class floppy_connector: public device_t,
{
public:
template <typename T>
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, const floppy_format_type *formats, bool fixed = false)
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, const floppy_format_type formats[], bool fixed = false)
: floppy_connector(mconfig, tag, owner, 0)
{
option_reset();
@ -326,7 +326,7 @@ public:
set_fixed(fixed);
set_formats(formats);
}
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, const char *option, const device_type &devtype, bool is_default, const floppy_format_type *formats)
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, const char *option, const device_type &devtype, bool is_default, const floppy_format_type formats[])
: floppy_connector(mconfig, tag, owner, 0)
{
option_reset();
@ -339,7 +339,7 @@ public:
floppy_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 0);
virtual ~floppy_connector();
void set_formats(const floppy_format_type *formats);
void set_formats(const floppy_format_type formats[]);
floppy_image_device *get_device();
void enable_sound(bool doit) { m_enable_sound = doit; }

View File

@ -143,6 +143,14 @@
#define VERBOSE 0
#include "logmacro.h"
namespace {
FLOPPY_FORMATS_MEMBER(mips_floppy_formats)
FLOPPY_PC_FORMAT
FLOPPY_FORMATS_END
} // anonymous namespace
void rx2030_state::machine_start()
{
save_item(NAME(m_mmu));
@ -479,7 +487,7 @@ void rx2030_state::rx2030(machine_config &config)
WD37C65C(config, m_fdc, 16_MHz_XTAL);
m_fdc->intrq_wr_callback().set_inputline(m_iop, INPUT_LINE_IRQ6);
//m_fdc->drq_wr_callback().set();
FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, &FLOPPY_PC_FORMAT).enable_sound(false);
FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, mips_floppy_formats).enable_sound(false);
// scsi bus and devices
NSCSI_BUS(config, m_scsibus, 0);
@ -703,7 +711,7 @@ void rx3230_state::rx3230(machine_config &config)
I82072(config, m_fdc, 16_MHz_XTAL);
m_fdc->intrq_wr_callback().set_inputline(m_cpu, INPUT_LINE_IRQ4);
//m_fdc->drq_wr_callback().set();
FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, &FLOPPY_PC_FORMAT).enable_sound(false);
FLOPPY_CONNECTOR(config, "fdc:0", "35hd", FLOPPY_35_HD, true, mips_floppy_formats).enable_sound(false);
// keyboard
pc_kbdc_device &kbdc(PC_KBDC(config, "pc_kbdc", 0));