Skip to content

Commit b55ba81

Browse files
committed
Fixed things C++20 doesn't allow:
ui/info.cpp, imagedev/cassette.cpp: Deal with UTF-8 strings as a distint type. ui/inputmap.cpp, debugger/qt/dasmwindow.cpp, debugger/qt/mainwindow.cpp, sound/coreaudio_sound.cpp, cpu/drcbec.cpp, mit/tx0_v.cpp, konami/3dom2.cpp: machine/mc68328.cpp, cpu/mips/mips1.cpp, cpu/mips/r4000.cpp, cpu/romp, machine/cammu.cpp, machine/ns32081.cpp: Avoid arithmetic between different enum types. dec/pdp1.cpp, konami/firebeat.cpp, mit/tx0.cpp, sound/lc7535.cpp, sound/spkrdev.cpp: Avoid arithmetic between enum and floating point. gaelco/gaelco3d_m.cpp: Fixed deprecated uses of volatile variables. sound/discrete.h: Avoid comparing enum to floatint point. ui/toolbar.ipp: Don't use UTF-8 qualifier on pure ASCII strings, just assume char is ASCII-like. cpu/unsp: Use default constructor for compiler_state. sgi/pm2_mmu.cpp: Avoid conflict between file static access and identically named function in unistd.h. osd/interface/audio.h: Provide an explicit constructor. util/server_http_impl.hpp: Fixed uninitialised class member warning.
1 parent 8653a44 commit b55ba81

31 files changed

Lines changed: 681 additions & 767 deletions

src/devices/cpu/drcbec.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -609,27 +609,27 @@ void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_
609609

610610
// pre-expand opcodes that encode size/scale in them
611611
if (opcode == OP_LOAD)
612-
opcode = opcode_t(OP_LOAD1 + inst.param(3).size() * 4 + inst.param(3).scale());
612+
opcode = opcode_t(OP_LOAD1 + unsigned(inst.param(3).size() * 4 + inst.param(3).scale()));
613613
if (opcode == OP_LOADS)
614-
opcode = opcode_t(OP_LOADS1 + inst.param(3).size() * 4 + inst.param(3).scale());
614+
opcode = opcode_t(OP_LOADS1 + unsigned(inst.param(3).size() * 4 + inst.param(3).scale()));
615615
if (opcode == OP_STORE)
616-
opcode = opcode_t(OP_STORE1 + inst.param(3).size() * 4 + inst.param(3).scale());
616+
opcode = opcode_t(OP_STORE1 + unsigned(inst.param(3).size() * 4 + inst.param(3).scale()));
617617
if (opcode == OP_READ)
618-
opcode = opcode_t(OP_READ1 + inst.param(2).size());
618+
opcode = opcode_t(OP_READ1 + unsigned(inst.param(2).size()));
619619
if (opcode == OP_READM)
620-
opcode = opcode_t(OP_READM1 + inst.param(3).size());
620+
opcode = opcode_t(OP_READM1 + unsigned(inst.param(3).size()));
621621
if (opcode == OP_WRITE)
622-
opcode = opcode_t(OP_WRITE1 + inst.param(2).size());
622+
opcode = opcode_t(OP_WRITE1 + unsigned(inst.param(2).size()));
623623
if (opcode == OP_WRITEM)
624-
opcode = opcode_t(OP_WRITEM1 + inst.param(3).size());
624+
opcode = opcode_t(OP_WRITEM1 + unsigned(inst.param(3).size()));
625625
if (opcode == OP_SEXT)
626-
opcode = opcode_t(OP_SEXT1 + inst.param(2).size());
626+
opcode = opcode_t(OP_SEXT1 + unsigned(inst.param(2).size()));
627627
if (opcode == OP_FTOINT)
628-
opcode = opcode_t(OP_FTOI4T + 5 * (inst.param(2).size() - 2) + inst.param(3).rounding());
628+
opcode = opcode_t(OP_FTOI4T + unsigned(5 * (inst.param(2).size() - 2) + inst.param(3).rounding()));
629629
if (opcode == OP_FFRINT)
630-
opcode = opcode_t(OP_FFRI4 + (inst.param(2).size() - 2));
630+
opcode = opcode_t(OP_FFRI4 + unsigned(inst.param(2).size() - 2));
631631
if (opcode == OP_FFRFLT)
632-
opcode = opcode_t(OP_FFRFS + (inst.param(2).size() - 2));
632+
opcode = opcode_t(OP_FFRFS + unsigned(inst.param(2).size() - 2));
633633

634634
// count how many bytes of immediates we need
635635
int immedbytes = 0;

src/devices/cpu/mips/mips1.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,21 @@ enum exception : u32
5858
EXCEPTION_BADCOP3 = 0x3000002c,
5959
};
6060

61-
enum cop0_reg : u8
62-
{
63-
COP0_Index = 0,
64-
COP0_Random = 1,
65-
COP0_EntryLo = 2,
66-
COP0_BusCtrl = 2, // r3041 only
67-
COP0_Config = 3, // r3041/r3071/r3081 only
68-
COP0_Context = 4,
69-
COP0_BadVAddr = 8,
70-
COP0_Count = 9, // r3041 only
71-
COP0_EntryHi = 10,
72-
COP0_PortSize = 10, // r3041 only
73-
COP0_Compare = 11, // r3041 only
74-
COP0_Status = 12,
75-
COP0_Cause = 13,
76-
COP0_EPC = 14,
77-
COP0_PRId = 15,
78-
};
61+
constexpr u8 COP0_Index = 0;
62+
constexpr u8 COP0_Random = 1;
63+
constexpr u8 COP0_EntryLo = 2;
64+
constexpr u8 COP0_BusCtrl = 2; // r3041 only
65+
constexpr u8 COP0_Config = 3; // r3041/r3071/r3081 only
66+
constexpr u8 COP0_Context = 4;
67+
constexpr u8 COP0_BadVAddr = 8;
68+
constexpr u8 COP0_Count = 9; // r3041 only
69+
constexpr u8 COP0_EntryHi = 10;
70+
constexpr u8 COP0_PortSize = 10; // r3041 only
71+
constexpr u8 COP0_Compare = 11; // r3041 only
72+
constexpr u8 COP0_Status = 12;
73+
constexpr u8 COP0_Cause = 13;
74+
constexpr u8 COP0_EPC = 14;
75+
constexpr u8 COP0_PRId = 15;
7976

8077
enum sr_mask : u32
8178
{

src/devices/cpu/mips/r4000.h

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,31 @@ class r4000_base_device : public cpu_device
5959
};
6060
r4000_base_device(machine_config const &mconfig, device_type type, char const *tag, device_t *owner, u32 clock, u32 prid, u32 fcr, cache_size icache_size, cache_size dcache_size, unsigned m32, unsigned m64, unsigned d32, unsigned d64, bool timer_interrupt_disabled);
6161

62-
enum cp0_reg : int
63-
{
64-
CP0_Index = 0,
65-
CP0_Random = 1,
66-
CP0_EntryLo0 = 2,
67-
CP0_EntryLo1 = 3,
68-
CP0_Context = 4,
69-
CP0_PageMask = 5,
70-
CP0_Wired = 6,
71-
CP0_BadVAddr = 8,
72-
CP0_Count = 9,
73-
CP0_EntryHi = 10,
74-
CP0_Compare = 11,
75-
CP0_Status = 12,
76-
CP0_Cause = 13,
77-
CP0_EPC = 14,
78-
CP0_PRId = 15,
79-
CP0_Config = 16,
80-
CP0_LLAddr = 17,
81-
CP0_WatchLo = 18,
82-
CP0_WatchHi = 19,
83-
CP0_XContext = 20,
84-
CP0_ECC = 26,
85-
CP0_CacheErr = 27,
86-
CP0_TagLo = 28,
87-
CP0_TagHi = 29,
88-
CP0_ErrorEPC = 30,
89-
};
62+
static constexpr int CP0_Index = 0;
63+
static constexpr int CP0_Random = 1;
64+
static constexpr int CP0_EntryLo0 = 2;
65+
static constexpr int CP0_EntryLo1 = 3;
66+
static constexpr int CP0_Context = 4;
67+
static constexpr int CP0_PageMask = 5;
68+
static constexpr int CP0_Wired = 6;
69+
static constexpr int CP0_BadVAddr = 8;
70+
static constexpr int CP0_Count = 9;
71+
static constexpr int CP0_EntryHi = 10;
72+
static constexpr int CP0_Compare = 11;
73+
static constexpr int CP0_Status = 12;
74+
static constexpr int CP0_Cause = 13;
75+
static constexpr int CP0_EPC = 14;
76+
static constexpr int CP0_PRId = 15;
77+
static constexpr int CP0_Config = 16;
78+
static constexpr int CP0_LLAddr = 17;
79+
static constexpr int CP0_WatchLo = 18;
80+
static constexpr int CP0_WatchHi = 19;
81+
static constexpr int CP0_XContext = 20;
82+
static constexpr int CP0_ECC = 26;
83+
static constexpr int CP0_CacheErr = 27;
84+
static constexpr int CP0_TagLo = 28;
85+
static constexpr int CP0_TagHi = 29;
86+
static constexpr int CP0_ErrorEPC = 30;
9087

9188
enum cp0_sr_mask : u32
9289
{

src/devices/cpu/romp/romp.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,16 @@ class romp_device : public cpu_device
2525
ROMP_GPR = 16,
2626
};
2727

28-
enum scr : unsigned
29-
{
30-
COUS = 6, // counter source
31-
COU = 7, // counter
32-
TS = 8, // timer status
33-
ECR = 9, // exception control (advanced/enhanced only)
34-
MQ = 10, // multiplier quotient
35-
MPCS = 11, // machine/program check status
36-
IRB = 12, // interrupt request buffer
37-
IAR = 13, // instruction address register
38-
ICS = 14, // interrupt control status
39-
CS = 15, // condition status
40-
};
28+
static constexpr unsigned COUS = 6; // counter source
29+
static constexpr unsigned COU = 7; // counter
30+
static constexpr unsigned TS = 8; // timer status
31+
static constexpr unsigned ECR = 9; // exception control (advanced/enhanced only)
32+
static constexpr unsigned MQ = 10; // multiplier quotient
33+
static constexpr unsigned MPCS = 11; // machine/program check status
34+
static constexpr unsigned IRB = 12; // interrupt request buffer
35+
static constexpr unsigned IAR = 13; // instruction address register
36+
static constexpr unsigned ICS = 14; // interrupt control status
37+
static constexpr unsigned CS = 15; // condition status
4138

4239
enum ts_mask : u32
4340
{

src/devices/cpu/unsp/unsp.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ class unsp_device : public cpu_device
131131
/* internal compiler state */
132132
struct compiler_state
133133
{
134+
compiler_state() = default;
134135
compiler_state(compiler_state const&) = delete;
135136
compiler_state& operator=(compiler_state const&) = delete;
136137

137-
uint32_t m_cycles; /* accumulated cycles */
138-
uml::code_label m_labelnum; /* index for local labels */
138+
uint32_t m_cycles = 0; /* accumulated cycles */
139+
uml::code_label m_labelnum = 0; /* index for local labels */
139140
};
140141

141142
struct internal_unsp_state

src/devices/cpu/unsp/unspdrc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void unsp_device::code_flush_cache()
162162

163163
void unsp_device::code_compile_block(offs_t pc)
164164
{
165-
compiler_state compiler = { 0 };
165+
compiler_state compiler;
166166
const opcode_desc *seqhead, *seqlast;
167167
bool override = false;
168168

src/devices/imagedev/cassette.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "util/ioprocs.h"
1818
#include "util/ioprocsfilter.h"
1919

20+
#include <array>
2021
#include <regex>
2122

2223
#define LOG_WARN (1U << 1) // Warnings
@@ -410,7 +411,7 @@ std::string cassette_image_device::call_display()
410411
// only show the image when a cassette is loaded and the motor is on
411412
if (exists() && !is_stopped() && motor_on())
412413
{
413-
static char const *const shapes[] = { u8"\u2500", u8"\u2572", u8"\u2502", u8"\u2571" };
414+
static std::array const shapes{ u8"\u2500", u8"\u2572", u8"\u2502", u8"\u2571" };
414415

415416
// figure out where we are in the cassette
416417
double position = get_position();
@@ -421,20 +422,20 @@ std::string cassette_image_device::call_display()
421422
int n = (int(position) / ANIMATION_FPS) % std::size(shapes);
422423

423424
// play or record
424-
const char *status_icon = (uistate == CASSETTE_PLAY)
425+
auto const *const status_icon = (uistate == CASSETTE_PLAY)
425426
? u8"\u25ba"
426427
: u8"\u25cf";
427428

428429
// create information string
429430
result = string_format("%s %s %02d:%02d (%04d) [%02d:%02d (%04d)]",
430431
shapes[n], // animation
431432
status_icon, // play or record
432-
((int)position / 60),
433-
((int)position % 60),
434-
(int)position,
435-
((int)length / 60),
436-
((int)length % 60),
437-
(int)length);
433+
int(position) / 60,
434+
int(position) % 60,
435+
int(position),
436+
int(length) / 60,
437+
int(length) % 60,
438+
int(length));
438439

439440
// make sure tape stops at end when playing
440441
if ((m_state & CASSETTE_MASK_UISTATE) == CASSETTE_PLAY)

src/devices/machine/cammu.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -598,18 +598,14 @@ class cammu_c3_device : public cammu_device
598598
CNTL_UST = 0x00000030, // unmapped system tag
599599
CNTL_CV = 0x00000100, // clear valid
600600
CNTL_ATE = 0x00000200, // alignment trap enable
601-
CNTL_CID = 0xff000000 // cammu id
602-
};
603-
enum control_ust_mask : u32
604-
{
605-
UST_0 = 0x00000000, // private, write-through, main memory space
606-
UST_1 = 0x00000010, // shared, write-through, main memory space
607-
UST_2 = 0x00000020, // private, copy-back, main memory space
608-
UST_3 = 0x00000030 // noncacheable, main memory space
609-
};
610-
enum control_cid_mask : u32
611-
{
612-
CID_C3 = 0x00000000 // unknown
601+
CNTL_CID = 0xff000000, // cammu id
602+
603+
UST_0 = 0x00000000, // private, write-through, main memory space
604+
UST_1 = 0x00000010, // shared, write-through, main memory space
605+
UST_2 = 0x00000020, // private, copy-back, main memory space
606+
UST_3 = 0x00000030, // noncacheable, main memory space
607+
608+
CID_C3 = 0x00000000 // unknown
613609
};
614610

615611
enum reset_mask : u32

0 commit comments

Comments
 (0)