diff options
58 files changed, 620 insertions, 532 deletions
@@ -143,6 +143,9 @@ BUILD_ZLIB = 1 # (default is OPTIMIZE = 3 normally, or OPTIMIZE = 0 with symbols) # OPTIMIZE = 3 +# experimental: uncomment to compile everything as C++ for stricter type checking +# CPP_COMPILE = 1 + ########################################################################### ################## END USER-CONFIGURABLE OPTIONS ###################### @@ -207,6 +210,11 @@ ifdef DEBUG DEBUGSUFFIX = d endif +# cpp builds get a 'pp' suffix +ifdef CPP_COMPILE +CPPSUFFIX = pp +endif + # the name is just 'target' if no subtarget; otherwise it is # the concatenation of the two (e.g., mametiny) ifeq ($(TARGET),$(SUBTARGET)) @@ -216,7 +224,7 @@ NAME = $(TARGET)$(SUBTARGET) endif # fullname is prefix+name+suffix+debugsuffix -FULLNAME = $(PREFIX)$(NAME)$(SUFFIX)$(DEBUGSUFFIX) +FULLNAME = $(PREFIX)$(NAME)$(CPPSUFFIX)$(SUFFIX)$(DEBUGSUFFIX) # add an EXE suffix to get the final emulator name EMULATOR = $(FULLNAME)$(EXE) @@ -278,57 +286,74 @@ endif #------------------------------------------------- # compile flags +# CCOMFLAGS are common flags +# CONLYFLAGS are flags only used when compiling for C +# CPPONLYFLAGS are flags only used when compiling for C++ #------------------------------------------------- -# we compile to C89 standard with GNU extensions -CFLAGS = -std=gnu89 +# start with empties for everything +CCOMFLAGS = +CONLYFLAGS = +CPPONLYFLAGS = + +# CFLAGS is defined based on C or C++ targets +# (remember, expansion only happens when used, so doing it here is ok) +ifdef CPP_COMPILE +CFLAGS = $(CCOMFLAGS) $(CPPONLYFLAGS) +else +CFLAGS = $(CCOMFLAGS) $(CONLYFLAGS) +endif + +# we compile C-only to C89 standard with GNU extensions +# we compile C++ code to C++98 standard with GNU extensions +CONLYFLAGS += -std=gnu89 +CPPONLYFLAGS += -x c++ -std=gnu++98 # this speeds it up a bit by piping between the preprocessor/compiler/assembler -CFLAGS += -pipe +CCOMFLAGS += -pipe -# add -g if we need symbols +# add -g if we need symbols, and ensure we have frame pointers ifdef SYMBOLS -CFLAGS += -g +CCOMFLAGS += -g -fno-omit-frame-pointer endif # add -v if we need verbose build information ifdef VERBOSE -CFLAGS += -v +CCOMFLAGS += -v endif -# add a basic set of warnings -CFLAGS += \ - -Wall \ - -Wpointer-arith \ - -Wbad-function-cast \ - -Wcast-align \ - -Wstrict-prototypes \ - -Wundef \ - -Wformat-security \ - -Wwrite-strings \ - # add profiling information for the compiler ifdef PROFILE -CFLAGS += -pg -endif - -# this warning is not supported on the os2 compilers -ifneq ($(TARGETOS),os2) -CFLAGS += -Wdeclaration-after-statement +CCOMFLAGS += -pg endif # add the optimization flag -CFLAGS += -O$(OPTIMIZE) +CCOMFLAGS += -O$(OPTIMIZE) # if we are optimizing, include optimization options # and make all errors into warnings ifneq ($(OPTIMIZE),0) -CFLAGS += -Werror $(ARCHOPTS) -fno-strict-aliasing +CCOMFLAGS += -Werror -fno-strict-aliasing $(ARCHOPTS) endif -# if symbols are on, make sure we have frame pointers -ifdef SYMBOLS -CFLAGS += -fno-omit-frame-pointer +# add a basic set of warnings +CCOMFLAGS += \ + -Wall \ + -Wcast-align \ + -Wundef \ + -Wformat-security \ + -Wwrite-strings \ + -Wno-sign-compare + +# warnings only applicable to C compiles +CONLYFLAGS += \ + -Wpointer-arith \ + -Wbad-function-cast \ + -Wstrict-prototypes + +# this warning is not supported on the os2 compilers +ifneq ($(TARGETOS),os2) +CONLYFLAGS += -Wdeclaration-after-statement endif @@ -338,7 +363,7 @@ endif #------------------------------------------------- # add core include paths -CFLAGS += \ +CCOMFLAGS += \ -I$(SRC)/$(TARGET) \ -I$(SRC)/$(TARGET)/includes \ -I$(OBJ)/$(TARGET)/layout \ @@ -419,7 +444,7 @@ LIBS = # add expat XML library ifdef BUILD_EXPAT -CFLAGS += -I$(SRC)/lib/expat +CCOMFLAGS += -I$(SRC)/lib/expat EXPAT = $(OBJ)/libexpat.a else LIBS += -lexpat @@ -428,7 +453,7 @@ endif # add ZLIB compression library ifdef BUILD_ZLIB -CFLAGS += -I$(SRC)/lib/zlib +CCOMFLAGS += -I$(SRC)/lib/zlib ZLIB = $(OBJ)/libz.a else LIBS += -lz @@ -444,6 +469,8 @@ endif all: maketree buildtools emulator tools + + #------------------------------------------------- # defines needed by multiple make files #------------------------------------------------- @@ -452,6 +479,8 @@ BUILDSRC = $(SRC)/build BUILDOBJ = $(OBJ)/build BUILDOUT = $(BUILDOBJ) + + #------------------------------------------------- # include the various .mak files #------------------------------------------------- diff --git a/src/emu/cpu/apexc/apexcdsm.c b/src/emu/cpu/apexc/apexcdsm.c index 672f67db878..63454cafe52 100644 --- a/src/emu/cpu/apexc/apexcdsm.c +++ b/src/emu/cpu/apexc/apexcdsm.c @@ -52,10 +52,13 @@ For vector instructions, replace the first space on the right of the mnemonic with a 'v'. */ +enum _format_type {branch, shiftl, shiftr, multiply, store, swap, one_address, two_address}; +typedef enum _format_type format_type; + typedef struct instr_desc { const char *mnemonic; - enum {branch, shiftl, shiftr, multiply, store, swap, one_address, two_address} format; /* -> X and Y are format */ + format_type format; /* -> X and Y are format */ } instr_desc; static const instr_desc instructions[16] = diff --git a/src/emu/cpu/asap/asap.c b/src/emu/cpu/asap/asap.c index f68d86afc61..e24d7d26e67 100644 --- a/src/emu/cpu/asap/asap.c +++ b/src/emu/cpu/asap/asap.c @@ -135,7 +135,7 @@ static void leah_c0(asap_state *); static void subr(asap_state *); static void subr_c(asap_state *); static void subr_c0(asap_state *); -static void xor(asap_state *); +static void xor_(asap_state *); static void xor_c(asap_state *); static void xor_c0(asap_state *); static void xorn(asap_state *); @@ -153,13 +153,13 @@ static void addc_c0(asap_state *); static void subc(asap_state *); static void subc_c(asap_state *); static void subc_c0(asap_state *); -static void and(asap_state *); +static void and_(asap_state *); static void and_c(asap_state *); static void and_c0(asap_state *); static void andn(asap_state *); static void andn_c(asap_state *); static void andn_c0(asap_state *); -static void or(asap_state *); +static void or_(asap_state *); static void or_c(asap_state *); static void or_c0(asap_state *); static void orn(asap_state *); @@ -225,15 +225,15 @@ static void (*const opcodetable[32][4])(asap_state *) = { lea, noop, lea_c, lea_c0 }, { leah, noop, leah_c, leah_c0 }, { subr, noop, subr_c, subr_c0 }, - { xor, noop, xor_c, xor_c0 }, + { xor_, noop, xor_c, xor_c0 }, { xorn, noop, xorn_c, xorn_c0 }, { add, noop, add_c, add_c0 }, { sub, noop, sub_c, sub_c0 }, { addc, noop, addc_c, addc_c0 }, { subc, noop, subc_c, subc_c0 }, - { and, noop, and_c, and_c0 }, + { and_, noop, and_c, and_c0 }, { andn, noop, andn_c, andn_c0 }, - { or, noop, or_c, or_c0 }, + { or_, noop, or_c, or_c0 }, { orn, noop, orn_c, orn_c0 }, { ld, ld_0, ld_c, ld_c0 }, { ldh, ldh_0, ldh_c, ldh_c0 }, @@ -949,7 +949,7 @@ static void subr_c0(asap_state *asap) /**************************** XOR ******************************/ -static void xor(asap_state *asap) +static void xor_(asap_state *asap) { DSTVAL(asap) = SRC1VAL(asap) ^ SRC2VAL(asap); } @@ -1093,7 +1093,7 @@ static void subc_c0(asap_state *asap) /**************************** AND ******************************/ -static void and(asap_state *asap) +static void and_(asap_state *asap) { DSTVAL(asap) = SRC1VAL(asap) & SRC2VAL(asap); } @@ -1133,7 +1133,7 @@ static void andn_c0(asap_state *asap) /**************************** OR ******************************/ -static void or(asap_state *asap) +static void or_(asap_state *asap) { DSTVAL(asap) = SRC1VAL(asap) | SRC2VAL(asap); } diff --git a/src/emu/cpu/cop400/cop400.c b/src/emu/cpu/cop400/cop400.c index d9a74db2d90..feec2f9d158 100644 --- a/src/emu/cpu/cop400/cop400.c +++ b/src/emu/cpu/cop400/cop400.c @@ -407,7 +407,7 @@ static void cop410_op33(cop400_state *cpustate, UINT8 opcode) static const cop400_opcode_map COP410_OPCODE_MAP[] = { - {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, + {1, clra },{1, skmbz0 },{1, xor_ },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, {0, illegal },{1, skmbz1 },{0, illegal },{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, @@ -538,7 +538,7 @@ static void cop420_op33(cop400_state *cpustate, UINT8 opcode) static const cop400_opcode_map COP420_OPCODE_MAP[] = { - {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, + {1, clra },{1, skmbz0 },{1, xor_ },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, {1, casc },{1, skmbz1 },{1, xabr },{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, @@ -669,7 +669,7 @@ static void cop444_op33(cop400_state *cpustate, UINT8 opcode) static const cop400_opcode_map COP444_OPCODE_MAP[256] = { - {1, clra },{1, skmbz0 },{1, xor },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, + {1, clra },{1, skmbz0 },{1, xor_ },{1, skmbz2 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, {1, casc },{1, skmbz1 },{1, cop444_xabr},{1, skmbz3 },{1, xis },{1, ld },{1, x },{1, xds }, {1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi },{1, lbi }, diff --git a/src/emu/cpu/cop400/cop400op.c b/src/emu/cpu/cop400/cop400op.c index cf4c68b4b22..9c737f0807e 100644 --- a/src/emu/cpu/cop400/cop400op.c +++ b/src/emu/cpu/cop400/cop400op.c @@ -193,7 +193,7 @@ INSTRUCTION( sc ) */ -INSTRUCTION( xor ) +INSTRUCTION( xor_ ) { A = A ^ RAM_R(B); } diff --git a/src/emu/cpu/saturn/saturnds.c b/src/emu/cpu/saturn/saturnds.c index d2ad8441cfd..9803d88413b 100644 --- a/src/emu/cpu/saturn/saturnds.c +++ b/src/emu/cpu/saturn/saturnds.c @@ -552,38 +552,44 @@ static const struct { }; +enum _opcode_sel +{ + Complete=-1, + Illegal, + Opcode0, Opcode0E, Opcode0Ea, + Opcode1, Opcode10, Opcode11, Opcode12, Opcode13, Opcode14, Opcode15, + Opcode8, Opcode80, Opcode808, Opcode8081, + Opcode81, Opcode818, Opcode818a, Opcode819, Opcode819a, + Opcode81A, Opcode81Aa, Opcode81Aa0,Opcode81Aa1, Opcode81Aa2, Opcode81B, + Opcode8A, Opcode8B, + Opcode9, Opcode9a, Opcode9b, + OpcodeA, OpcodeAa, OpcodeAb, + OpcodeB, OpcodeBa, OpcodeBb, + OpcodeC, + OpcodeD, + OpcodeE, + OpcodeF +}; +typedef enum _opcode_sel opcode_sel; + +enum _opcode_adr +{ + AdrNone, + AdrAF, AdrA, AdrB, AdrCount, + BranchReturn, TestBranchRet, ImmBranch, + ABranchReturn, // address field A + xBranchReturn, // address field specified in previous opcode entry + Imm, ImmCount, ImmCload, Imm2, Imm4, Imm5, + Dis3, Dis3Call, Dis4, Dis4Call, Abs, + FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW, FieldA, + AdrImmCount +}; +typedef enum _opcode_adr opcode_adr; + typedef struct { - enum - { - Complete=-1, - Illegal, - Opcode0, Opcode0E, Opcode0Ea, - Opcode1, Opcode10, Opcode11, Opcode12, Opcode13, Opcode14, Opcode15, - Opcode8, Opcode80, Opcode808, Opcode8081, - Opcode81, Opcode818, Opcode818a, Opcode819, Opcode819a, - Opcode81A, Opcode81Aa, Opcode81Aa0,Opcode81Aa1, Opcode81Aa2, Opcode81B, - Opcode8A, Opcode8B, - Opcode9, Opcode9a, Opcode9b, - OpcodeA, OpcodeAa, OpcodeAb, - OpcodeB, OpcodeBa, OpcodeBb, - OpcodeC, - OpcodeD, - OpcodeE, - OpcodeF - } sel; - enum - { - AdrNone, - AdrAF, AdrA, AdrB, AdrCount, - BranchReturn, TestBranchRet, ImmBranch, - ABranchReturn, // address field A - xBranchReturn, // address field specified in previous opcode entry - Imm, ImmCount, ImmCload, Imm2, Imm4, Imm5, - Dis3, Dis3Call, Dis4, Dis4Call, Abs, - FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW, FieldA, - AdrImmCount - } adr; + opcode_sel sel; + opcode_adr adr; MNEMONICS mnemonic; } OPCODE; diff --git a/src/emu/cpu/tms34010/34010ops.h b/src/emu/cpu/tms34010/34010ops.h index b52f3f62793..55c0be7680f 100644 --- a/src/emu/cpu/tms34010/34010ops.h +++ b/src/emu/cpu/tms34010/34010ops.h @@ -43,7 +43,7 @@ INLINE void TMS34010_WRMEM_DWORD(tms34010_state *tms, offs_t A,UINT32 V) /* IO registers accessor */ #define IOREG(T,reg) ((T)->IOregs[reg]) -#define SMART_IOREG(T,reg) ((T)->IOregs[(T)->is_34020 ? REG020_##reg : REG_##reg]) +#define SMART_IOREG(T,reg) ((T)->IOregs[(T)->is_34020 ? (int)REG020_##reg : (int)REG_##reg]) #define PBH(T) (IOREG(T, REG_CONTROL) & 0x0100) #define PBV(T) (IOREG(T, REG_CONTROL) & 0x0200) diff --git a/src/emu/cpu/tms7000/7000dasm.c b/src/emu/cpu/tms7000/7000dasm.c index e9831ef4c26..c0dcebe83da 100644 --- a/src/emu/cpu/tms7000/7000dasm.c +++ b/src/emu/cpu/tms7000/7000dasm.c @@ -10,7 +10,7 @@ typedef struct { typedef struct { int opcode; - char name[7]; + char name[8]; int operand; UINT32 s_flag; } opcodeinfo; diff --git a/src/emu/cpuexec.c b/src/emu/cpuexec.c index 08f4fe9e241..b02bc425c72 100644 --- a/src/emu/cpuexec.c +++ b/src/emu/cpuexec.c @@ -160,7 +160,7 @@ static int get_register_string_max_width(const device_config *device, void *base INLINE cpu_class_data *get_class_data(const device_config *device) { assert(device != NULL); - assert(device->class == DEVICE_CLASS_CPU_CHIP); + assert(device->devclass == DEVICE_CLASS_CPU_CHIP); assert(device->token != NULL); return (cpu_class_data *)cpu_get_class_header(device) - 1; } diff --git a/src/emu/cpuexec.h b/src/emu/cpuexec.h index 19028ae9272..a104750c5c0 100644 --- a/src/emu/cpuexec.h +++ b/src/emu/cpuexec.h @@ -317,7 +317,7 @@ void cpu_set_irq_callback(const device_config *cpu, cpu_irq_callback callback); INLINE cpu_type cpu_get_type(const device_config *device) { - const cpu_config *config = device->inline_config; + const cpu_config *config = (const cpu_config *)device->inline_config; return config->type; } diff --git a/src/emu/devcb.h b/src/emu/devcb.h index c5bd10e1d3e..aa1eea6afca 100644 --- a/src/emu/devcb.h +++ b/src/emu/devcb.h @@ -229,7 +229,7 @@ void devcb_resolve_write8(devcb_resolved_write8 *resolved, const devcb_write8 *c INLINE int devcb_call_read_line(const devcb_resolved_read_line *resolved) { - return (resolved->read != NULL) ? (*resolved->read)(resolved->target) : 0; + return (resolved->read != NULL) ? (*resolved->read)((const device_config *)resolved->target) : 0; } @@ -240,7 +240,7 @@ INLINE int devcb_call_read_line(const devcb_resolved_read_line *resolved) INLINE int devcb_call_read8(const devcb_resolved_read8 *resolved, offs_t offset) { - return (resolved->read != NULL) ? (*resolved->read)(resolved->target, offset) : 0; + return (resolved->read != NULL) ? (*resolved->read)((const device_config *)resolved->target, offset) : 0; } @@ -252,7 +252,7 @@ INLINE int devcb_call_read8(const devcb_resolved_read8 *resolved, offs_t offset) INLINE void devcb_call_write_line(const devcb_resolved_write_line *resolved, int state) { if (resolved->write != NULL) - (*resolved->write)(resolved->target, state); + (*resolved->write)((const device_config *)resolved->target, state); } @@ -264,7 +264,7 @@ INLINE void devcb_call_write_line(const devcb_resolved_write_line *resolved, int INLINE void devcb_call_write8(const devcb_resolved_write8 *resolved, offs_t offset, UINT8 data) { if (resolved->write != NULL) - (*resolved->write)(resolved->target, offset, data); + (*resolved->write)((const device_config *)resolved->target, offset, data); } diff --git a/src/emu/devintrf.c b/src/emu/devintrf.c index 0384c604599..de079258f06 100644 --- a/src/emu/devintrf.c +++ b/src/emu/devintrf.c @@ -121,7 +121,7 @@ device_config *device_list_add(device_config **listheadptr, const device_config /* populate device properties */ device->type = type; - device->class = devtype_get_info_int(type, DEVINFO_INT_CLASS); + device->devclass = devtype_get_info_int(type, DEVINFO_INT_CLASS); device->set_info = (device_set_info_func)devtype_get_info_fct(type, DEVINFO_FCT_SET_INFO); device->execute = NULL; @@ -153,7 +153,7 @@ device_config *device_list_add(device_config **listheadptr, const device_config *tempdevptr = device; /* and to the end of the class list */ - tempdevice = (device_config *)device_list_class_first(*listheadptr, device->class); + tempdevice = (device_config *)device_list_class_first(*listheadptr, device->devclass); for (tempdevptr = &tempdevice; *tempdevptr != NULL; tempdevptr = &(*tempdevptr)->classnext) ; *tempdevptr = device; @@ -192,7 +192,7 @@ void device_list_remove(device_config **listheadptr, device_type type, const cha *tempdevptr = device->typenext; /* and from the class list */ - tempdevice = (device_config *)device_list_class_first(*listheadptr, device->class); + tempdevice = (device_config *)device_list_class_first(*listheadptr, device->devclass); for (tempdevptr = &tempdevice; *tempdevptr != device; tempdevptr = &(*tempdevptr)->classnext) ; assert(*tempdevptr == device); *tempdevptr = device->classnext; @@ -426,13 +426,13 @@ const device_config *device_list_find_by_index(const device_config *listhead, de items of a given class -------------------------------------------------*/ -int device_list_class_items(const device_config *listhead, device_class class) +int device_list_class_items(const device_config *listhead, device_class devclass) { const device_config *curdev; int count = 0; /* locate all devices of a given class */ - for (curdev = listhead; curdev != NULL && curdev->class != class; curdev = curdev->next) ; + for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; for ( ; curdev != NULL; curdev = curdev->classnext) count++; @@ -445,12 +445,12 @@ int device_list_class_items(const device_config *listhead, device_class class) device in the list of a given class -------------------------------------------------*/ -const device_config *device_list_class_first(const device_config *listhead, device_class class) +const device_config *device_list_class_first(const device_config *listhead, device_class devclass) { const device_config *curdev; /* first of a given class */ - for (curdev = listhead; curdev != NULL && curdev->class != class; curdev = curdev->next) ; + for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; return curdev; } @@ -460,7 +460,7 @@ const device_config *device_list_class_first(const device_config *listhead, devi device in the list of a given class -------------------------------------------------*/ -const device_config *device_list_class_next(const device_config *prevdevice, device_class class) +const device_config *device_list_class_next(const device_config *prevdevice, device_class devclass) { assert(prevdevice != NULL); return prevdevice->classnext; @@ -472,14 +472,14 @@ const device_config *device_list_class_next(const device_config *prevdevice, dev device configuration based on a class and tag -------------------------------------------------*/ -const device_config *device_list_class_find_by_tag(const device_config *listhead, device_class class, const char *tag) +const device_config *device_list_class_find_by_tag(const device_config *listhead, device_class devclass, const char *tag) { const device_config *curdev; assert(tag != NULL); /* locate among all devices of a given class */ - for (curdev = listhead; curdev != NULL && curdev->class != class; curdev = curdev->next) ; + for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; for ( ; curdev != NULL; curdev = curdev->classnext) if (strcmp(tag, curdev->tag) == 0) return curdev; @@ -494,7 +494,7 @@ const device_config *device_list_class_find_by_tag(const device_config *listhead device based on its class and tag -------------------------------------------------*/ -int device_list_class_index(const device_config *listhead, device_class class, const char *tag) +int device_list_class_index(const device_config *listhead, device_class devclass, const char *tag) { const device_config *curdev; int index = 0; @@ -502,7 +502,7 @@ int device_list_class_index(const device_config *listhead, device_class class, c assert(tag != NULL); /* locate among all devices of a given class */ - for (curdev = listhead; curdev != NULL && curdev->class != class; curdev = curdev->next) ; + for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; for ( ; curdev != NULL; curdev = curdev->classnext) { if (strcmp(tag, curdev->tag) == 0) @@ -520,12 +520,12 @@ int device_list_class_index(const device_config *listhead, device_class class, c index -------------------------------------------------*/ -const device_config *device_list_class_find_by_index(const device_config *listhead, device_class class, int index) +const device_config *device_list_class_find_by_index(const device_config *listhead, device_class devclass, int index) { const device_config *curdev; /* locate among all devices of a given class */ - for (curdev = listhead; curdev != NULL && curdev->class != class; curdev = curdev->next) ; + for (curdev = listhead; curdev != NULL && curdev->devclass != devclass; curdev = curdev->next) ; for ( ; curdev != NULL; curdev = curdev->classnext) if (index-- == 0) return curdev; diff --git a/src/emu/devintrf.h b/src/emu/devintrf.h index 06027ab3d09..587a138ded0 100644 --- a/src/emu/devintrf.h +++ b/src/emu/devintrf.h @@ -235,7 +235,7 @@ struct _device_config /* device properties (always valid) */ device_type type; /* device type */ - device_class class; /* device class */ + device_class devclass; /* device class */ device_set_info_func set_info; /* quick pointer to set_info callback */ /* device configuration (always valid) */ @@ -306,22 +306,22 @@ const device_config *device_list_find_by_index(const device_config *listhead, de /* ----- class-based device access ----- */ /* return the number of items of a given class */ -int device_list_class_items(const device_config *listhead, device_class class); +int device_list_class_items(const device_config *listhead, device_class devclass); /* return the first device in the list of a given class */ -const device_config *device_list_class_first(const device_config *listhead, device_class class); +const device_config *device_list_class_first(const device_config *listhead, device_class devclass); /* return the next device in the list of a given class */ -const device_config *device_list_class_next(const device_config *prevdevice, device_class class); +const device_config *device_list_class_next(const device_config *prevdevice, device_class devclass); /* retrieve a device configuration based on a class and tag */ -const device_config *device_list_class_find_by_tag(const device_config *listhead, device_class class, const char *tag); +const device_config *device_list_class_find_by_tag(const device_config *listhead, device_class devclass, const char *tag); /* return the index of a device based on its class and tag */ -int device_list_class_index(const device_config *listhead, device_class class, const char *tag); +int device_list_class_index(const device_config *listhead, device_class devclass, const char *tag); /* retrieve a device configuration based on a class and index */ -const device_config *device_list_class_find_by_index(const device_config *listhead, device_class class, int index); +const device_config *device_list_class_find_by_index(const device_config *listhead, device_class devclass, int index); diff --git a/src/emu/input.h b/src/emu/input.h index 7f33b4e5d7f..06a6f874479 100644 --- a/src/emu/input.h +++ b/src/emu/input.h @@ -42,7 +42,7 @@ #define INPUT_CODE_DEVINDEX(c) ((UINT8)(((c) >> 20) & 0x0f)) #define INPUT_CODE_ITEMCLASS(c) ((input_item_class)(((c) >> 16) & 0x0f)) #define INPUT_CODE_MODIFIER(c) ((input_item_modifier)(((c) >> 12) & 0x0f)) -#define INPUT_CODE_ITEMID(c) ((int)((c) & 0xfff)) +#define INPUT_CODE_ITEMID(c) ((input_item_id)(int)((c) & 0xfff)) /* build or modify input codes */ #define INPUT_CODE(d,x,i,m,o) ((((d) & 0x0f) << 24) | (((x) & 0x0f) << 20) | (((i) & 0x0f) << 16) | (((m) & 0x0f) << 12) | ((o) & 0xfff)) @@ -331,7 +331,7 @@ enum _input_item_id ITEM_ID_MAXIMUM, /* absolute maximum ID */ - ITEM_ID_ABSOLUTE_MAXIMUM = INPUT_CODE_ITEMID(~0) + ITEM_ID_ABSOLUTE_MAXIMUM = 0xfff }; typedef enum _input_item_id input_item_id; diff --git a/src/emu/rendersw.c b/src/emu/rendersw.c index 54576d34507..e4cea22028c 100644 --- a/src/emu/rendersw.c +++ b/src/emu/rendersw.c @@ -201,7 +201,7 @@ INLINE UINT32 get_texel_palette16_nearest(const render_texinfo *texture, INT32 c INLINE UINT32 get_texel_palette16_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT16 *texbase = texture->base; + const UINT16 *texbase = (const UINT16 *)texture->base; rgb_t pix00, pix01, pix10, pix11; INT32 u0, u1, v0, v1; @@ -245,7 +245,7 @@ INLINE UINT32 get_texel_palette16a_nearest(const render_texinfo *texture, INT32 INLINE UINT32 get_texel_palette16a_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT16 *texbase = texture->base; + const UINT16 *texbase = (const UINT16 *)texture->base; rgb_t pix00, pix01, pix10, pix11; INT32 u0, u1, v0, v1; @@ -288,7 +288,7 @@ INLINE UINT32 get_texel_rgb15_nearest(const render_texinfo *texture, INT32 curu, INLINE UINT32 get_texel_rgb15_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT16 *texbase = texture->base; + const UINT16 *texbase = (const UINT16 *)texture->base; rgb_t pix00, pix01, pix10, pix11, filtered; INT32 u0, u1, v0, v1; @@ -337,7 +337,7 @@ INLINE UINT32 get_texel_yuy16_nearest(const render_texinfo *texture, INT32 curu, INLINE UINT32 get_texel_yuy16_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT16 *texbase = texture->base; + const UINT16 *texbase = (const UINT16 *)texture->base; rgb_t pix00, pix01, pix10, pix11; INT32 u0, u1, v0, v1; @@ -406,7 +406,7 @@ INLINE UINT32 get_texel_rgb32_nearest(const render_texinfo *texture, INT32 curu, INLINE UINT32 get_texel_rgb32_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT32 *texbase = texture->base; + const UINT32 *texbase = (const UINT32 *)texture->base; rgb_t pix00, pix01, pix10, pix11; INT32 u0, u1, v0, v1; @@ -450,7 +450,7 @@ INLINE UINT32 get_texel_argb32_nearest(const render_texinfo *texture, INT32 curu INLINE UINT32 get_texel_argb32_bilinear(const render_texinfo *texture, INT32 curu, INT32 curv) { - const UINT32 *texbase = texture->base; + const UINT32 *texbase = (const UINT32 *)texture->base; rgb_t pix00, pix01, pix10, pix11; INT32 u0, u1, v0, v1; diff --git a/src/emu/sound.c b/src/emu/sound.c index d3fea90ab0a..6918e52b404 100644 --- a/src/emu/sound.c +++ b/src/emu/sound.c @@ -132,7 +132,7 @@ INLINE sound_class_data *get_class_data(const device_config *device) { assert(device != NULL); assert(device->type == SOUND); - assert(device->class == DEVICE_CLASS_SOUND_CHIP); + assert(device->devclass == DEVICE_CLASS_SOUND_CHIP); assert(device->token != NULL); return (sound_class_data *)((UINT8 *)device->token + device->tokenbytes) - 1; } diff --git a/src/emu/sound.h b/src/emu/sound.h index 48ebafe097a..d910125cd39 100644 --- a/src/emu/sound.h +++ b/src/emu/sound.h @@ -198,7 +198,7 @@ DEVICE_GET_INFO( speaker_output ); INLINE sound_type sound_get_type(const device_config *device) { - const sound_config *config = device->inline_config; + const sound_config *config = (const sound_config *)device->inline_config; return config->type; } diff --git a/src/emu/sound/rf5c400.c b/src/emu/sound/rf5c400.c index db172bd5104..70fdcc7b05a 100644 --- a/src/emu/sound/rf5c400.c +++ b/src/emu/sound/rf5c400.c @@ -19,6 +19,35 @@ #include "streams.h" #include "rf5c400.h" +typedef struct _rf5c400_channel rf5c400_channel; +struct _rf5c400_channel +{ + UINT16 startH; + UINT16 startL; + UINT16 freq; + UINT16 endL; + UINT16 endHloopH; + UINT16 loopL; + UINT16 pan; + UINT16 effect; + UINT16 volume; + + UINT16 attack; + UINT16 decay; + UINT16 release; + + UINT16 cutoff; + + UINT64 pos; + UINT64 step; + UINT16 keyon; + + UINT8 env_phase; + double env_level; + double env_step; + double env_scale; +}; + typedef struct _rf5c400_state rf5c400_state; struct _rf5c400_state { @@ -31,33 +60,7 @@ struct _rf5c400_state double env_dr_table[0x9f]; double env_rr_table[0x9f]; - struct RF5C400_CHANNEL - { - UINT16 startH; - UINT16 startL; - UINT16 freq; - UINT16 endL; - UINT16 endHloopH; - UINT16 loopL; - UINT16 pan; - UINT16 effect; - UINT16 volume; - - UINT16 attack; - UINT16 decay; - UINT16 release; - - UINT16 cutoff; - - UINT64 pos; - UINT64 step; - UINT16 keyon; - - UINT8 env_phase; - double env_level; - double env_step; - double env_scale; - } channels[32]; + rf5c400_channel channels[32]; }; static int volume_table[256]; @@ -129,7 +132,7 @@ static STREAM_UPDATE( rf5c400_update ) for (ch=0; ch < 32; ch++) { - struct RF5C400_CHANNEL *channel = &info->channels[ch]; + rf5c400_channel *channel = &info->channels[ch]; stream_sample_t *buf0 = outputs[0]; stream_sample_t *buf1 = outputs[1]; @@ -460,7 +463,7 @@ WRITE16_DEVICE_HANDLER( rf5c400_w ) int ch = (offset >> 5) & 0x1f; int reg = (offset & 0x1f); - struct RF5C400_CHANNEL *channel = &info->channels[ch]; + rf5c400_channel *channel = &info->channels[ch]; switch (reg) { diff --git a/src/emu/tokenize.h b/src/emu/tokenize.h index 82152411938..fc139e404b6 100644 --- a/src/emu/tokenize.h +++ b/src/emu/tokenize.h @@ -62,7 +62,7 @@ struct _generic_token /* ----- compile-time token generation macros ----- */ /* GCC and C99 compilers can use designated initializers for type safety */ -#if (defined(__GNUC__) && (__GNUC__ >= 3)) || (defined(_STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) +#if (defined(__GNUC__) && (__GNUC__ >= 3) && !defined(__cplusplus)) || (defined(_STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) #define TOKEN_VALUE(field,a) { .field = (a) } #else #define TOKEN_VALUE(field,a) { (FPTR)(a) } diff --git a/src/emu/video/vooddefs.h b/src/emu/video/vooddefs.h index 36e48287f48..02aa816524b 100644 --- a/src/emu/video/vooddefs.h +++ b/src/emu/video/vooddefs.h @@ -3492,7 +3492,7 @@ while (0) \ static void raster_##name(void *destbase, INT32 y, const poly_extent *extent, const void *extradata, int threadid) \ { \ - const poly_extra_data *extra = extradata; \ + const poly_extra_data *extra = (const poly_extra_data *)extradata; \ voodoo_state *v = extra->state; \ stats_block *stats = &v->thread_stats[threadid]; \ DECLARE_DITHER_POINTERS; \ diff --git a/src/lib/lib.mak b/src/lib/lib.mak index 66d91b71d89..b61b3b4e6fd 100644 --- a/src/lib/lib.mak +++ b/src/lib/lib.mak @@ -10,6 +10,7 @@ ########################################################################### +LIBSRC = $(SRC)/lib LIBOBJ = $(OBJ)/lib OBJDIRS += \ @@ -62,6 +63,10 @@ EXPATOBJS = \ $(OBJ)/libexpat.a: $(EXPATOBJS) +$(LIBOBJ)/expat/%.o: $(LIBSRC)/explat/%.c | $(OSPREBUILD) + @echo Compiling $<... + $(CC) $(CDEFS) $(CCOMFLAGS) $(CONLYFLAGS) -c $< -o $@ + #------------------------------------------------- @@ -83,3 +88,7 @@ ZLIBOBJS = \ $(LIBOBJ)/zlib/zutil.o $(OBJ)/libz.a: $(ZLIBOBJS) + +$(LIBOBJ)/zlib/%.o: $(LIBSRC)/zlib/%.c | $(OSPREBUILD) + @echo Compiling $<... + $(CC) $(CDEFS) $(CCOMFLAGS) $(CONLYFLAGS) -c $< -o $@ diff --git a/src/lib/util/astring.c b/src/lib/util/astring.c index df05efaafbe..cb5d23098a3 100644 --- a/src/lib/util/astring.c +++ b/src/lib/util/astring.c @@ -65,7 +65,7 @@ INLINE int ensure_room(astring *str, int length) /* allocate a new buffer with some slop */ alloclen = length + 256; - newbuf = malloc(alloclen); + newbuf = (char *)malloc(alloclen); if (newbuf == NULL) return FALSE; @@ -124,7 +124,7 @@ astring *astring_alloc(void) astring *str; /* allocate memory; if we fail, return the dummy */ - str = malloc(sizeof(*str)); + str = (astring *)malloc(sizeof(*str)); if (str == NULL) return &dummy_astring; memset(str, 0, sizeof(*str)); diff --git a/src/lib/util/avcomp.c b/src/lib/util/avcomp.c index c42d100d888..ad3f4fefeee 100644 --- a/src/lib/util/avcomp.c +++ b/src/lib/util/avcomp.c @@ -139,7 +139,7 @@ avcomp_state *avcomp_init(UINT32 maxwidth, UINT32 maxheight, UINT32 maxchannels) return NULL; /* allocate memory for state block */ - state = malloc(sizeof(*state)); + state = (avcomp_state *)malloc(sizeof(*state)); if (state == NULL) return NULL; @@ -152,7 +152,7 @@ avcomp_state *avcomp_init(UINT32 maxwidth, UINT32 maxheight, UINT32 maxchannels) state->maxchannels = maxchannels; /* now allocate data buffers */ - state->audiodata = malloc(65536 * state->maxchannels * 2); + state->audiodata = (UINT8 *)malloc(65536 * state->maxchannels * 2); if (state->audiodata == NULL) goto cleanup; @@ -300,7 +300,7 @@ avcomp_error avcomp_encode_data(avcomp_state *state, const UINT8 *source, UINT8 videostride = width = height = 0; if (state->compress.video != NULL) { - videostart = state->compress.video->base; + videostart = (const UINT8 *)state->compress.video->base; videostride = state->compress.video->rowpixels * 2; width = state->compress.video->width; height = state->compress.video->height; @@ -455,7 +455,7 @@ avcomp_error avcomp_decode_data(avcomp_state *state, const UINT8 *source, UINT32 metastart = state->decompress.metadata; for (chnum = 0; chnum < channels; chnum++) audiostart[chnum] = (UINT8 *)state->decompress.audio[chnum]; - videostart = (state->decompress.video != NULL) ? state->decompress.video->base : NULL; + videostart = (state->decompress.video != NULL) ? (UINT8 *)state->decompress.video->base : NULL; videostride = (state->decompress.video != NULL) ? state->decompress.video->rowpixels * 2 : 0; /* data is assumed to be native-endian */ diff --git a/src/lib/util/aviio.c b/src/lib/util/aviio.c index 8a8f1cd04b6..d213d291013 100644 --- a/src/lib/util/aviio.c +++ b/src/lib/util/aviio.c @@ -374,7 +374,7 @@ INLINE avi_error set_stream_chunk_info(avi_stream *stream, UINT32 index, UINT64 if (index >= stream->chunksalloc) { UINT32 newcount = MAX(index, stream->chunksalloc + 1000); - stream->chunk = realloc(stream->chunk, newcount * sizeof(stream->chunk[0])); + stream->chunk = (avi_chunk_list *)realloc(stream->chunk, newcount * sizeof(stream->chunk[0])); if (stream->chunk == NULL) return AVIERR_NO_MEMORY; stream->chunksalloc = newcount; @@ -450,7 +450,7 @@ INLINE avi_error expand_tempbuffer(avi_file *file, UINT32 length) if (length > file->tempbuffersize) { file->tempbuffersize = 2 * length; - file->tempbuffer = realloc(file->tempbuffer, file->tempbuffersize); + file->tempbuffer = (UINT8 *)realloc(file->tempbuffer, file->tempbuffersize); if (file->tempbuffer == NULL) return AVIERR_NO_MEMORY; } @@ -475,7 +475,7 @@ avi_error avi_open(const char *filename, avi_file **file) UINT64 length; /* allocate the file */ - newfile = malloc(sizeof(*newfile)); + newfile = (avi_file *)malloc(sizeof(*newfile)); if (newfile == NULL) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); @@ -541,7 +541,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file return AVIERR_UNSUPPORTED_AUDIO_FORMAT; /* allocate the file */ - newfile = malloc(sizeof(*newfile)); + newfile = (avi_file *)malloc(sizeof(*newfile)); if (newfile == NULL) return AVIERR_NO_MEMORY; memset(newfile, 0, sizeof(*newfile)); @@ -561,7 +561,7 @@ avi_error avi_create(const char *filename, const avi_movie_info *info, avi_file newfile->info.audio_numsamples = 0; /* allocate two streams */ - newfile->stream = malloc(2 * sizeof(newfile->stream[0])); + newfile->stream = (avi_stream *)malloc(2 * sizeof(newfile->stream[0])); if (newfile->stream == NULL) { avierr = AVIERR_NO_MEMORY; @@ -1058,7 +1058,7 @@ static avi_error read_chunk_data(avi_file *file, const avi_chunk *chunk, UINT8 * UINT32 bytes_read; /* allocate memory for the data */ - *buffer = malloc(chunk->size); + *buffer = (UINT8 *)malloc(chunk->size); if (*buffer == NULL) return AVIERR_NO_MEMORY; @@ -1392,7 +1392,7 @@ static avi_error parse_avih_chunk(avi_file *file, avi_chunk *avih) file->streams = fetch_32bits(&chunkdata[24]); /* allocate memory for the streams */ - file->stream = malloc(sizeof(*file->stream) * file->streams); + file->stream = (avi_stream *)malloc(sizeof(*file->stream) * file->streams); if (file->stream == NULL) goto error; memset(file->stream, 0, sizeof(*file->stream) * file->streams); @@ -2044,7 +2044,7 @@ static avi_error write_indx_chunk(avi_file *file, avi_stream *stream, int initia continue; /* allocate memory */ - tempbuf = malloc(24 + 8 * chunks_this_index); + tempbuf = (UINT8 *)malloc(24 + 8 * chunks_this_index); if (tempbuf == NULL) return AVIERR_NO_MEMORY; memset(tempbuf, 0, 24 + 8 * chunks_this_index); @@ -2113,7 +2113,7 @@ static avi_error write_idx1_chunk(avi_file *file) UINT8 *tempbuf; /* allocate a temporary buffer */ - tempbuf = malloc(tempbuflength); + tempbuf = (UINT8 *)malloc(tempbuflength); if (tempbuf == NULL) return AVIERR_NO_MEMORY; @@ -2170,7 +2170,7 @@ static avi_error soundbuf_initialize(avi_file *file) file->soundbuf_samples = file->info.audio_samplerate * SOUND_BUFFER_MSEC / 1000; /* allocate a buffer */ - file->soundbuf = malloc(file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); + file->soundbuf = (INT16 *)malloc(file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); if (file->soundbuf == NULL) return AVIERR_NO_MEMORY; memset(file->soundbuf, 0, file->soundbuf_samples * file->info.audio_channels * sizeof(file->soundbuf[0])); @@ -2447,7 +2447,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda int tabnum; /* allocate memory for the data */ - stream->huffyuv = malloc(sizeof(*stream->huffyuv)); + stream->huffyuv = (huffyuv_data *)malloc(sizeof(*stream->huffyuv)); if (stream->huffyuv == NULL) { avierr = AVIERR_NO_MEMORY; @@ -2535,7 +2535,7 @@ static avi_error huffyuv_extract_tables(avi_stream *stream, const UINT8 *chunkda /* allocate the number of extra lookup tables we need */ if (bitsat16 > 0) { - table->extralookup = malloc(bitsat16 * 65536 * sizeof(table->extralookup[0])); + table->extralookup = (UINT16 *)malloc(bitsat16 * 65536 * sizeof(table->extralookup[0])); if (table->extralookup == NULL) { avierr = AVIERR_NO_MEMORY; diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c index 26af203b702..5ffe709654d 100644 --- a/src/lib/util/bitmap.c +++ b/src/lib/util/bitmap.c @@ -45,7 +45,7 @@ bitmap_t *bitmap_alloc_slop(int width, int height, int xslop, int yslop, bitmap_ return NULL; /* allocate the bitmap itself */ - bitmap = malloc(sizeof(*bitmap)); + bitmap = (bitmap_t *)malloc(sizeof(*bitmap)); if (bitmap == NULL) return NULL; memset(bitmap, 0, sizeof(*bitmap)); @@ -96,7 +96,7 @@ bitmap_t *bitmap_wrap(void *base, int width, int height, int rowpixels, bitmap_f return NULL; /* allocate memory */ - bitmap = malloc(sizeof(*bitmap)); + bitmap = (bitmap_t *)malloc(sizeof(*bitmap)); if (bitmap == NULL) return NULL; memset(bitmap, 0, sizeof(*bitmap)); diff --git a/src/lib/util/cdrom.c b/src/lib/util/cdrom.c index 03427cb0a54..152c73cea4a 100644 --- a/src/lib/util/cdrom.c +++ b/src/lib/util/cdrom.c @@ -115,7 +115,7 @@ cdrom_file *cdrom_open(chd_file *chd) return NULL; /* allocate memory for the CD-ROM file */ - file = malloc(sizeof(cdrom_file)); + file = (cdrom_file *)malloc(sizeof(cdrom_file)); if (file == NULL) return NULL; @@ -163,7 +163,7 @@ cdrom_file *cdrom_open(chd_file *chd) file->cdtoc.tracks[i].chdframeofs = chdofs; /* allocate a cache */ - file->cache = malloc(chd_get_header(chd)->hunkbytes); + file->cache = (UINT8 *)malloc(chd_get_header(chd)->hunkbytes); if (file->cache == NULL) { free(file); diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c index aa21bb8a1ae..5ad19c57f95 100644 --- a/src/lib/util/chd.c +++ b/src/lib/util/chd.c @@ -593,7 +593,7 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** EARLY_EXIT(err = CHDERR_INVALID_PARAMETER); /* allocate memory for the final result */ - newchd = malloc(sizeof(**chd)); + newchd = (chd_file *)malloc(sizeof(**chd)); if (newchd == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); memset(newchd, 0, sizeof(*newchd)); @@ -645,15 +645,15 @@ chd_error chd_open_file(core_file *file, int mode, chd_file *parent, chd_file ** EARLY_EXIT(err); /* allocate and init the hunk cache */ - newchd->cache = malloc(newchd->header.hunkbytes); - newchd->compare = malloc(newchd->header.hunkbytes); + newchd->cache = (UINT8 *)malloc(newchd->header.hunkbytes); + newchd->compare = (UINT8 *)malloc(newchd->header.hunkbytes); if (newchd->cache == NULL || newchd->compare == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); newchd->cachehunk = ~0; newchd->comparehunk = ~0; /* allocate the temporary compressed buffer */ - newchd->compressed = malloc(newchd->header.hunkbytes); + newchd->compressed = (UINT8 *)malloc(newchd->header.hunkbytes); if (newchd->compressed == NULL) EARLY_EXIT(err = CHDERR_OUT_OF_MEMORY); @@ -994,7 +994,7 @@ chd_error chd_read(chd_file *chd, UINT32 hunknum, void *buffer) wait_for_pending_async(chd); /* perform the read */ - return hunk_read_into_memory(chd, hunknum, buffer); + return hunk_read_into_memory(chd, hunknum, (UINT8 *)buffer); } @@ -1048,7 +1048,7 @@ chd_error chd_write(chd_file *chd, UINT32 hunknum, const void *buffer) wait_for_pending_async(chd); /* then write out the hunk */ - return hunk_write_from_memory(chd, hunknum, buffer); + return hunk_write_from_memory(chd, hunknum, (const UINT8 *)buffer); } @@ -1105,7 +1105,7 @@ chd_error chd_async_complete(chd_file *chd) osd_work_item_release(chd->workitem); chd->workitem = NULL; - return (chd_error)result; + return (chd_error)(ptrdiff_t)result; } @@ -1291,7 +1291,7 @@ chd_error chd_clone_metadata(chd_file *source, chd_file *dest) /* otherwise, allocate a bigger temporary buffer */ else { - UINT8 *allocbuffer = malloc(metasize); + UINT8 *allocbuffer = (UINT8 *)malloc(metasize); if (allocbuffer == NULL) { err = CHDERR_OUT_OF_MEMORY; @@ -1377,7 +1377,7 @@ chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio) return CHDERR_INVALID_STATE; /* write out the hunk */ - err = hunk_write_from_memory(chd, thishunk, data); + err = hunk_write_from_memory(chd, thishunk, (const UINT8 *)data); if (err != CHDERR_NONE) return err; @@ -1396,8 +1396,8 @@ chd_error chd_compress_hunk(chd_file *chd, const void *data, double *curratio) } if (bytestochecksum > 0) { - MD5Update(&chd->compmd5, crcdata, bytestochecksum); - sha1_update(&chd->compsha1, bytestochecksum, crcdata); + MD5Update(&chd->compmd5, (const unsigned char *)crcdata, bytestochecksum); + sha1_update(&chd->compsha1, bytestochecksum, (const UINT8 *)crcdata); } /* update our CRC map */ @@ -1594,11 +1594,11 @@ const char *chd_get_codec_name(UINT32 codec) static void *async_read_callback(void *param, int threadid) { - chd_file *chd = param; + chd_file *chd = (chd_file *)param; chd_error err; /* read the hunk into the cache */ - err = hunk_read_into_memory(chd, chd->async_hunknum, chd->async_buffer); + err = hunk_read_into_memory(chd, chd->async_hunknum, (UINT8 *)chd->async_buffer); /* return the error */ return (void *)err; @@ -1612,11 +1612,11 @@ static void *async_read_callback(void *param, int threadid) static void *async_write_callback(void *param, int threadid) { - chd_file *chd = param; + chd_file *chd = (chd_file *)param; chd_error err; /* write the hunk from memory */ - err = hunk_write_from_memory(chd, chd->async_hunknum, chd->async_buffer); + err = hunk_write_from_memory(chd, chd->async_hunknum, (const UINT8 *)chd->async_buffer); /* return the error */ return (void *)err; @@ -2131,10 +2131,11 @@ static chd_error map_read(chd_file *chd) UINT64 fileoffset, maxoffset = 0; UINT8 cookie[MAP_ENTRY_SIZE]; UINT32 count; - int i, err; + chd_error err; + int i; /* first allocate memory */ - chd->map = malloc(sizeof(chd->map[0]) * chd->header.totalhunks); + chd->map = (map_entry *)malloc(sizeof(chd->map[0]) * chd->header.totalhunks); if (!chd->map) return CHDERR_OUT_OF_MEMORY; @@ -2224,12 +2225,12 @@ static void crcmap_init(chd_file *chd, int prepopulate) chd->crctable = NULL; /* allocate a list; one for each hunk */ - chd->crcmap = malloc(chd->header.totalhunks * sizeof(chd->crcmap[0])); + chd->crcmap = (crcmap_entry *)malloc(chd->header.totalhunks * sizeof(chd->crcmap[0])); if (chd->crcmap == NULL) return; /* allocate a CRC map table */ - chd->crctable = malloc(CRCMAP_HASH_SIZE * sizeof(chd->crctable[0])); + chd->crctable = (crcmap_entry **)malloc(CRCMAP_HASH_SIZE * sizeof(chd->crctable[0])); if (chd->crctable == NULL) { free(chd->crcmap); @@ -2466,7 +2467,7 @@ static chd_error zlib_codec_init(chd_file *chd) int zerr; /* allocate memory for the 2 stream buffers */ - data = malloc(sizeof(*data)); + data = (zlib_codec_data *)malloc(sizeof(*data)); if (data == NULL) return CHDERR_OUT_OF_MEMORY; @@ -2517,7 +2518,7 @@ static chd_error zlib_codec_init(chd_file *chd) static void zlib_codec_free(chd_file *chd) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; /* deinit the streams */ if (data != NULL) @@ -2543,11 +2544,11 @@ static void zlib_codec_free(chd_file *chd) static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *length) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; int zerr; /* reset the decompressor */ - data->deflater.next_in = (void *)src; + data->deflater.next_in = (Bytef *)src; data->deflater.avail_in = chd->header.hunkbytes; data->deflater.total_in = 0; data->deflater.next_out = chd->compressed; @@ -2577,14 +2578,14 @@ static chd_error zlib_codec_compress(chd_file *chd, const void *src, UINT32 *len static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *dest) { - zlib_codec_data *data = chd->codecdata; + zlib_codec_data *data = (zlib_codec_data *)chd->codecdata; int zerr; /* reset the decompressor */ data->inflater.next_in = chd->compressed; data->inflater.avail_in = srclength; data->inflater.total_in = 0; - data->inflater.next_out = dest; + data->inflater.next_out = (Bytef *)dest; data->inflater.avail_out = chd->header.hunkbytes; data->inflater.total_out = 0; zerr = inflateReset(&data->inflater); @@ -2607,7 +2608,7 @@ static chd_error zlib_codec_decompress(chd_file *chd, UINT32 srclength, void *de static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) { - zlib_codec_data *data = opaque; + zlib_codec_data *data = (zlib_codec_data *)opaque; UINT32 *ptr; int i; @@ -2627,7 +2628,7 @@ static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) } /* alloc a new one */ - ptr = malloc(size + sizeof(UINT32)); + ptr = (UINT32 *)malloc(size + sizeof(UINT32)); if (!ptr) return NULL; @@ -2652,7 +2653,7 @@ static voidpf zlib_fast_alloc(voidpf opaque, uInt items, uInt size) static void zlib_fast_free(voidpf opaque, voidpf address) { - zlib_codec_data *data = opaque; + zlib_codec_data *data = (zlib_codec_data *)opaque; UINT32 *ptr = (UINT32 *)address - 1; int i; @@ -2705,7 +2706,7 @@ static chd_error av_codec_init(chd_file *chd) av_codec_data *data; /* allocate memory for the 2 stream buffers */ - data = malloc(sizeof(*data)); + data = (av_codec_data *)malloc(sizeof(*data)); if (data == NULL) return CHDERR_OUT_OF_MEMORY; @@ -2727,7 +2728,7 @@ static chd_error av_codec_init(chd_file *chd) static void av_codec_free(chd_file *chd) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; /* deinit avcomp */ if (data != NULL) @@ -2746,7 +2747,7 @@ static void av_codec_free(chd_file *chd) static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *length) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; int averr; int size; @@ -2761,14 +2762,14 @@ static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *lengt /* make sure short frames are padded with 0 */ if (src != NULL) { - size = av_raw_data_size(src); + size = av_raw_data_size((const UINT8 *)src); while (size < chd->header.hunkbytes) if (((const UINT8 *)src)[size++] != 0) return CHDERR_INVALID_DATA; } /* encode the audio and video */ - averr = avcomp_encode_data(data->compstate, src, chd->compressed, length); + averr = avcomp_encode_data(data->compstate, (const UINT8 *)src, chd->compressed, length); if (averr != AVCERR_NONE || *length > chd->header.hunkbytes) return CHDERR_COMPRESSION_ERROR; @@ -2783,7 +2784,7 @@ static chd_error av_codec_compress(chd_file *chd, const void *src, UINT32 *lengt static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; const UINT8 *source; avcomp_error averr; int size; @@ -2798,14 +2799,14 @@ static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest /* decode the audio and video */ source = chd->compressed; - averr = avcomp_decode_data(data->compstate, source, srclength, dest); + averr = avcomp_decode_data(data->compstate, source, srclength, (UINT8 *)dest); if (averr != AVCERR_NONE) return CHDERR_DECOMPRESSION_ERROR; /* pad short frames with 0 */ if (dest != NULL) { - size = av_raw_data_size(dest); + size = av_raw_data_size((const UINT8 *)dest); while (size < chd->header.hunkbytes) ((UINT8 *)dest)[size++] = 0; } @@ -2821,7 +2822,7 @@ static chd_error av_codec_decompress(chd_file *chd, UINT32 srclength, void *dest static chd_error av_codec_config(chd_file *chd, int param, void *config) { - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; /* if we're getting the compression configuration, apply it now */ if (param == AV_CODEC_COMPRESS_CONFIG) @@ -2856,7 +2857,7 @@ static chd_error av_codec_postinit(chd_file *chd) { int fps, fpsfrac, width, height, interlaced, channels, rate; UINT32 fps_times_1million, max_samples_per_frame, bytes_per_frame; - av_codec_data *data = chd->codecdata; + av_codec_data *data = (av_codec_data *)chd->codecdata; char metadata[256]; chd_error err; diff --git a/src/lib/util/corefile.c b/src/lib/util/corefile.c index 52aaef54ef8..94c6c410f65 100644 --- a/src/lib/util/corefile.c +++ b/src/lib/util/corefile.c @@ -127,7 +127,7 @@ file_error core_fopen(const char *filename, UINT32 openflags, core_file **file) file_error filerr = FILERR_NOT_FOUND; /* allocate the file itself */ - *file = malloc(sizeof(**file)); + *file = (core_file *)malloc(sizeof(**file)); if (*file == NULL) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -161,7 +161,7 @@ static file_error core_fopen_ram_internal(const void *data, size_t length, int c return FILERR_INVALID_ACCESS; /* allocate the file itself */ - *file = malloc(sizeof(**file) + (copy_buffer ? length : 0)); + *file = (core_file *)malloc(sizeof(**file) + (copy_buffer ? length : 0)); if (*file == NULL) return FILERR_OUT_OF_MEMORY; memset(*file, 0, sizeof(**file)); @@ -284,7 +284,7 @@ file_error core_fcompress(core_file *file, int level) int zerr; /* allocate memory */ - file->zdata = malloc(sizeof(*file->zdata)); + file->zdata = (zlib_data *)malloc(sizeof(*file->zdata)); if (file->zdata == NULL) return FILERR_OUT_OF_MEMORY; memset(file->zdata, 0, sizeof(*file->zdata)); @@ -666,7 +666,7 @@ const void *core_fbuffer(core_file *file) return file->data; /* allocate some memory */ - file->data = malloc(file->length); + file->data = (UINT8 *)malloc(file->length); if (file->data == NULL) return NULL; file->data_allocated = TRUE; @@ -735,9 +735,9 @@ int core_fputs(core_file *f, const char *s) /* is this the beginning of the file? if so, write a byte order mark */ if (f->offset == 0 && !(f->openflags & OPEN_FLAG_NO_BOM)) { - *pconvbuf++ = 0xef; - *pconvbuf++ = 0xbb; - *pconvbuf++ = 0xbf; + *pconvbuf++ = (char)0xef; + *pconvbuf++ = (char)0xbb; + *pconvbuf++ = (char)0xbf; } /* convert '\n' to platform dependant line endings */ @@ -890,7 +890,7 @@ static file_error osd_or_zlib_read(core_file *file, void *buffer, UINT64 offset, return FILERR_INVALID_ACCESS; /* set up the destination */ - file->zdata->stream.next_out = buffer; + file->zdata->stream.next_out = (Bytef *)buffer; file->zdata->stream.avail_out = length; while (file->zdata->stream.avail_out != 0) { @@ -943,7 +943,7 @@ static file_error osd_or_zlib_write(core_file *file, const void *buffer, UINT64 return FILERR_INVALID_ACCESS; /* set up the source */ - file->zdata->stream.next_in = (void *)buffer; + file->zdata->stream.next_in = (Bytef *)buffer; file->zdata->stream.avail_in = length; while (file->zdata->stream.avail_in != 0) { diff --git a/src/lib/util/corestr.c b/src/lib/util/corestr.c index caedad7c0e1..c3780c9632b 100644 --- a/src/lib/util/corestr.c +++ b/src/lib/util/corestr.c @@ -112,7 +112,7 @@ char *core_strdup(const char *str) char *cpy = NULL; if (str != NULL) { - cpy = malloc(strlen(str) + 1); + cpy = (char *)malloc(strlen(str) + 1); if (cpy != NULL) strcpy(cpy, str); } diff --git a/src/lib/util/harddisk.c b/src/lib/util/harddisk.c index 0ac715d4efb..97e18a99929 100644 --- a/src/lib/util/harddisk.c +++ b/src/lib/util/harddisk.c @@ -58,7 +58,7 @@ hard_disk_file *hard_disk_open(chd_file *chd) return NULL; /* allocate memory for the hard disk file */ - file = malloc(sizeof(hard_disk_file)); + file = (hard_disk_file *)malloc(sizeof(hard_disk_file)); if (file == NULL) return NULL; @@ -72,7 +72,7 @@ hard_disk_file *hard_disk_open(chd_file *chd) file->cachehunk = -1; /* allocate a cache */ - file->cache = malloc(chd_get_header(chd)->hunkbytes); + file->cache = (UINT8 *)malloc(chd_get_header(chd)->hunkbytes); if (file->cache == NULL) { free(file); diff --git a/src/lib/util/huffman.c b/src/lib/util/huffman.c index 74be6e54ab0..2e62e9be846 100644 --- a/src/lib/util/huffman.c +++ b/src/lib/util/huffman.c @@ -424,7 +424,7 @@ huffman_error huffman_create_context(huffman_context **context, int maxbits) return HUFFERR_TOO_MANY_BITS; /* allocate a context */ - *context = malloc(sizeof(**context)); + *context = (huffman_context *)malloc(sizeof(**context)); if (*context == NULL) return HUFFERR_OUT_OF_MEMORY; @@ -1630,7 +1630,7 @@ static huffman_error build_lookup_table(huffman_context *context, UINT32 numcode /* allocate a table if needed */ if (context->lookup == NULL) - context->lookup = malloc((UINT32)sizeof(context->lookup[0]) * (UINT32)(1 << context->maxbits)); + context->lookup = (huffman_lookup_value *)malloc((UINT32)sizeof(context->lookup[0]) * (UINT32)(1 << context->maxbits)); if (context->lookup == NULL) return HUFFERR_OUT_OF_MEMORY; diff --git a/src/lib/util/jedparse.c b/src/lib/util/jedparse.c index 8e1c79de48f..1bcf1323a35 100644 --- a/src/lib/util/jedparse.c +++ b/src/lib/util/jedparse.c @@ -191,7 +191,7 @@ static void process_field(jed_data *data, const UINT8 *cursrc, const UINT8 *srce int jed_parse(const void *data, size_t length, jed_data *result) { - const UINT8 *cursrc = data; + const UINT8 *cursrc = (const UINT8 *)data; const UINT8 *srcend = cursrc + length; const UINT8 *scan; parse_info pinfo; @@ -285,7 +285,7 @@ int jed_parse(const void *data, size_t length, jed_data *result) size_t jed_output(const jed_data *data, void *result, size_t length) { - UINT8 *curdst = result; + UINT8 *curdst = (UINT8 *)result; UINT8 *dstend = curdst + length; int i, zeros, ones; char tempbuf[256]; @@ -357,7 +357,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) /* now compute the transmission checksum */ checksum = 0; - for (temp = result; temp < curdst && temp < dstend; temp++) + for (temp = (UINT8 *)result; temp < curdst && temp < dstend; temp++) checksum += *temp & 0x7f; checksum += 0x03; @@ -381,7 +381,7 @@ size_t jed_output(const jed_data *data, void *result, size_t length) int jedbin_parse(const void *data, size_t length, jed_data *result) { - const UINT8 *cursrc = data; + const UINT8 *cursrc = (const UINT8 *)data; /* initialize the output */ memset(result, 0, sizeof(*result)); @@ -414,7 +414,7 @@ int jedbin_parse(const void *data, size_t length, jed_data *result) size_t jedbin_output(const jed_data *data, void *result, size_t length) { - UINT8 *curdst = result; + UINT8 *curdst = (UINT8 *)result; /* ensure we have enough room */ if (length >= 4 + (data->numfuses + 7) / 8) diff --git a/src/lib/util/options.c b/src/lib/util/options.c index bb4f9132c89..3d1673fd0d2 100644 --- a/src/lib/util/options.c +++ b/src/lib/util/options.c @@ -289,7 +289,7 @@ int options_add_entries(core_options *opts, const options_entry *entrylist) int i; /* allocate a new item */ - options_data *data = malloc(sizeof(*data)); + options_data *data = (options_data *)malloc(sizeof(*data)); if (data == NULL) return FALSE; memset(data, 0, sizeof(*data)); @@ -845,7 +845,7 @@ options_enumerator *options_enumerator_begin(core_options *opts) options_enumerator *enumerator; /* allocate memory for the enumerator */ - enumerator = malloc(sizeof(*enumerator)); + enumerator = (options_enumerator *)malloc(sizeof(*enumerator)); if (enumerator == NULL) return NULL; diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c index e553157d614..e0854d820eb 100644 --- a/src/lib/util/palette.c +++ b/src/lib/util/palette.c @@ -107,7 +107,7 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) UINT32 index; /* allocate memory */ - palette = malloc(sizeof(*palette)); + palette = (palette_t *)malloc(sizeof(*palette)); if (palette == NULL) goto error; memset(palette, 0, sizeof(*palette)); @@ -120,8 +120,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) palette->gamma_map[index] = index; /* allocate an array of palette entries and individual contrasts for each */ - palette->entry_color = malloc(sizeof(*palette->entry_color) * numcolors); - palette->entry_contrast = malloc(sizeof(*palette->entry_contrast) * numcolors); + palette->entry_color = (rgb_t *)malloc(sizeof(*palette->entry_color) * numcolors); + palette->entry_contrast = (float *)malloc(sizeof(*palette->entry_contrast) * numcolors); if (palette->entry_color == NULL || palette->entry_contrast == NULL) goto error; @@ -133,8 +133,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) } /* allocate an array of brightness and contrast for each group */ - palette->group_bright = malloc(sizeof(*palette->group_bright) * numgroups); - palette->group_contrast = malloc(sizeof(*palette->group_contrast) * numgroups); + palette->group_bright = (float *)malloc(sizeof(*palette->group_bright) * numgroups); + palette->group_contrast = (float *)malloc(sizeof(*palette->group_contrast) * numgroups); if (palette->group_bright == NULL || palette->group_contrast == NULL) goto error; @@ -146,8 +146,8 @@ palette_t *palette_alloc(UINT32 numcolors, UINT32 numgroups) } /* allocate arrays for the adjusted colors */ - palette->adjusted_color = malloc(sizeof(*palette->adjusted_color) * (numcolors * numgroups + 2)); - palette->adjusted_rgb15 = malloc(sizeof(*palette->adjusted_rgb15) * (numcolors * numgroups + 2)); + palette->adjusted_color = (rgb_t *)malloc(sizeof(*palette->adjusted_color) * (numcolors * numgroups + 2)); + palette->adjusted_rgb15 = (rgb_t *)malloc(sizeof(*palette->adjusted_rgb15) * (numcolors * numgroups + 2)); if (palette->adjusted_color == NULL || palette->adjusted_rgb15 == NULL) goto error; @@ -280,14 +280,14 @@ palette_client *palette_client_alloc(palette_t *palette) palette_client *client; /* allocate memory for the client */ - client = malloc(sizeof(*client)); + client = (palette_client *)malloc(sizeof(*client)); if (client == NULL) goto error; memset(client, 0, sizeof(*client)); /* allocate dirty lists */ - client->live.dirty = malloc(dirty_dwords * sizeof(UINT32)); - client->previous.dirty = malloc(dirty_dwords * sizeof(UINT32)); + client->live.dirty = (UINT32 *)malloc(dirty_dwords * sizeof(UINT32)); + client->previous.dirty = (UINT32 *)malloc(dirty_dwords * sizeof(UINT32)); if (client->live.dirty == NULL || client->previous.dirty == NULL) goto error; diff --git a/src/lib/util/png.c b/src/lib/util/png.c index 2346419c2df..e6a1fd242fc 100644 --- a/src/lib/util/png.c +++ b/src/lib/util/png.c @@ -271,7 +271,7 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 case PNG_CN_IDAT: /* allocate a new image data descriptor */ - *png->idata_next = malloc(sizeof(**png->idata_next)); + *png->idata_next = (image_data_chunk *)malloc(sizeof(**png->idata_next)); if (*png->idata_next == NULL) return PNGERR_OUT_OF_MEMORY; @@ -301,7 +301,7 @@ static png_error process_chunk(png_private *png, UINT8 *data, UINT32 type, UINT3 png_text *text, *pt, *ct; /* allocate a new text item */ - text = malloc(sizeof(*text)); + text = (png_text *)malloc(sizeof(*text)); if (text == NULL) return PNGERR_OUT_OF_MEMORY; @@ -668,7 +668,7 @@ png_error png_expand_buffer_8bit(png_info *pnginfo) return PNGERR_NONE; /* allocate a new buffer at 8-bit */ - outbuf = malloc(pnginfo->width * pnginfo->height); + outbuf = (UINT8 *)malloc(pnginfo->width * pnginfo->height); if (outbuf == NULL) return PNGERR_OUT_OF_MEMORY; @@ -713,13 +713,13 @@ png_error png_add_text(png_info *pnginfo, const char *keyword, const char *text) int keylen; /* allocate a new text element */ - newtext = malloc(sizeof(*newtext)); + newtext = (png_text *)malloc(sizeof(*newtext)); if (newtext == NULL) return PNGERR_OUT_OF_MEMORY; /* allocate a string long enough to hold both */ keylen = (int)strlen(keyword); - textdata = malloc(keylen + 1 + strlen(text) + 1); + textdata = (char *)malloc(keylen + 1 + strlen(text) + 1); if (textdata == NULL) { free(newtext); @@ -887,7 +887,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap rowbytes = pnginfo->width; /* allocate memory for the palette */ - pnginfo->palette = malloc(3 * 256); + pnginfo->palette = (UINT8 *)malloc(3 * 256); if (pnginfo->palette == NULL) return PNGERR_OUT_OF_MEMORY; @@ -902,7 +902,7 @@ static png_error convert_bitmap_to_image_palette(png_info *pnginfo, const bitmap } /* allocate memory for the image */ - pnginfo->image = malloc(pnginfo->height * (rowbytes + 1)); + pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); if (pnginfo->image == NULL) { free(pnginfo->palette); @@ -944,7 +944,7 @@ static png_error convert_bitmap_to_image_rgb(png_info *pnginfo, const bitmap_t * rowbytes = pnginfo->width * (alpha ? 4 : 3); /* allocate memory for the image */ - pnginfo->image = malloc(pnginfo->height * (rowbytes + 1)); + pnginfo->image = (UINT8 *)malloc(pnginfo->height * (rowbytes + 1)); if (pnginfo->image == NULL) return PNGERR_OUT_OF_MEMORY; diff --git a/src/lib/util/pool.c b/src/lib/util/pool.c index 479c61cbd21..387c23e2a50 100644 --- a/src/lib/util/pool.c +++ b/src/lib/util/pool.c @@ -140,7 +140,7 @@ object_pool *pool_alloc(void (*fail)(const char *message)) object_pool *pool; /* allocate memory for the pool itself */ - pool = malloc(sizeof(*pool)); + pool = (object_pool *)malloc(sizeof(*pool)); if (pool == NULL) return NULL; memset(pool, 0, sizeof(*pool)); @@ -168,7 +168,7 @@ void pool_type_register(object_pool *pool, object_type type, const char *friendl if (newtype == NULL) { /* allocate a new entry */ - newtype = malloc(sizeof(*newtype)); + newtype = (objtype_entry *)malloc(sizeof(*newtype)); if (newtype == NULL) { report_failure(pool, "Error adding new type %s\n", friendly); @@ -286,7 +286,7 @@ void *pool_object_add_file_line(object_pool *pool, object_type _type, void *obje int entrynum; /* if we need a new block, allocate that now */ - block = malloc(sizeof(*block)); + block = (object_entry_block *)malloc(sizeof(*block)); if (block == NULL) return NULL; memset(block, 0, sizeof(*block)); @@ -403,7 +403,7 @@ object_pool_iterator *pool_iterate_begin(object_pool *pool, object_type type) object_pool_iterator *iter; /* allocate the iterator */ - iter = malloc(sizeof(*iter)); + iter = (object_pool_iterator *)malloc(sizeof(*iter)); if (iter == NULL) return NULL; memset(iter, 0, sizeof(*iter)); @@ -505,7 +505,7 @@ void *pool_realloc_file_line(object_pool *pool, void *ptr, size_t size, const ch char *pool_strdup_file_line(object_pool *pool, const char *str, const char *file, int line) { - char *ptr = pool_malloc_file_line(pool, strlen(str) + 1, file, line); + char *ptr = (char *)pool_malloc_file_line(pool, strlen(str) + 1, file, line); if (ptr != NULL) strcpy(ptr, str); return ptr; diff --git a/src/lib/util/unzip.c b/src/lib/util/unzip.c index 5e9ec06c325..e49fc4c4057 100644 --- a/src/lib/util/unzip.c +++ b/src/lib/util/unzip.c @@ -149,7 +149,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* allocate memory for the zip_file structure */ - newzip = malloc(sizeof(*newzip)); + newzip = (zip_file *)malloc(sizeof(*newzip)); if (newzip == NULL) return ZIPERR_OUT_OF_MEMORY; memset(newzip, 0, sizeof(*newzip)); @@ -175,7 +175,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* allocate memory for the central directory */ - newzip->cd = malloc(newzip->ecd.cd_size + 1); + newzip->cd = (UINT8 *)malloc(newzip->ecd.cd_size + 1); if (newzip->cd == NULL) { ziperr = ZIPERR_OUT_OF_MEMORY; @@ -191,7 +191,7 @@ zip_error zip_file_open(const char *filename, zip_file **zip) } /* make a copy of the filename for caching purposes */ - string = malloc(strlen(filename) + 1); + string = (char *)malloc(strlen(filename) + 1); if (string == NULL) { ziperr = ZIPERR_OUT_OF_MEMORY; @@ -427,7 +427,7 @@ static zip_error read_ecd(zip_file *zip) buflen = zip->length; /* allocate buffer */ - buffer = malloc(buflen + 1); + buffer = (UINT8 *)malloc(buflen + 1); if (buffer == NULL) return ZIPERR_OUT_OF_MEMORY; @@ -556,7 +556,7 @@ static zip_error decompress_data_type_8(zip_file *zip, UINT64 offset, void *buff /* reset the stream */ memset(&stream, 0, sizeof(stream)); - stream.next_out = buffer; + stream.next_out = (Bytef *)buffer; stream.avail_out = length; /* initialize the decompressor */ diff --git a/src/lib/util/xmlfile.c b/src/lib/util/xmlfile.c index 70adc563f8f..b400349a06d 100644 --- a/src/lib/util/xmlfile.c +++ b/src/lib/util/xmlfile.c @@ -75,7 +75,7 @@ static const char *copystring(const char *input) return NULL; /* make a lower-case copy if the allocation worked */ - newstr = malloc(strlen(input) + 1); + newstr = (char *)malloc(strlen(input) + 1); if (newstr != NULL) strcpy(newstr, input); @@ -99,7 +99,7 @@ static const char *copystring_lower(const char *input) return NULL; /* make a lower-case copy if the allocation worked */ - newstr = malloc(strlen(input) + 1); + newstr = (char *)malloc(strlen(input) + 1); if (newstr != NULL) { for (i = 0; input[i] != 0; i++) @@ -126,7 +126,7 @@ xml_data_node *xml_file_create(void) xml_data_node *rootnode; /* create a root node */ - rootnode = malloc(sizeof(*rootnode)); + rootnode = (xml_data_node *)malloc(sizeof(*rootnode)); if (rootnode == NULL) return NULL; memset(rootnode, 0, sizeof(*rootnode)); @@ -680,7 +680,7 @@ static void expat_data(void *data, const XML_Char *s, int len) oldlen = (int)strlen((*curnode)->value); /* realloc */ - newdata = realloc((void *)(*curnode)->value, oldlen + len + 1); + newdata = (char *)realloc((void *)(*curnode)->value, oldlen + len + 1); if (newdata == NULL) return; @@ -752,7 +752,7 @@ static xml_data_node *add_child(xml_data_node *parent, const char *name, const c xml_data_node *node; /* new element: create a new node */ - node = malloc(sizeof(*node)); + node = (xml_data_node *)malloc(sizeof(*node)); if (node == NULL) return NULL; @@ -793,7 +793,7 @@ static xml_attribute_node *add_attribute(xml_data_node *node, const char *name, xml_attribute_node *anode, **panode; /* allocate a new attribute node */ - anode = malloc(sizeof(*anode)); + anode = (xml_attribute_node *)malloc(sizeof(*anode)); if (anode == NULL) return NULL; diff --git a/src/osd/osdcomm.h b/src/osd/osdcomm.h index e4f7d7baea1..5a06603081b 100644 --- a/src/osd/osdcomm.h +++ b/src/osd/osdcomm.h @@ -19,6 +19,9 @@ #include <string.h> #include <stdlib.h> +#ifdef __cplusplus +#include <typeinfo> +#endif /*************************************************************************** @@ -31,6 +34,12 @@ #endif +/* In C++ we can do type checking via typeid */ +#ifdef __cplusplus +#define TYPES_COMPATIBLE(a,b) (typeid(a) == typeid(b)) +#endif + + /* Some optimizations/warnings cleanups for GCC */ #if defined(__GNUC__) && (__GNUC__ >= 3) #define ATTR_UNUSED __attribute__((__unused__)) @@ -42,9 +51,11 @@ #define ATTR_FORCE_INLINE __attribute__((always_inline)) #define ATTR_NONNULL __attribute__((nonnull(1))) #define UNEXPECTED(exp) __builtin_expect((exp), 0) -#define TYPES_COMPATIBLE(a,b) __builtin_types_compatible_p(a, b) #define RESTRICT __restrict__ #define SETJMP_GNUC_PROTECT() (void)__builtin_return_address(1) +#ifndef TYPES_COMPATIBLE +#define TYPES_COMPATIBLE(a,b) __builtin_types_compatible_p(a, b) +#endif #else #define ATTR_UNUSED #define ATTR_NORETURN @@ -55,9 +66,11 @@ #define ATTR_FORCE_INLINE #define ATTR_NONNULL #define UNEXPECTED(exp) (exp) -#define TYPES_COMPATIBLE(a,b) 1 #define RESTRICT #define SETJMP_GNUC_PROTECT() do {} while (0) +#ifndef TYPES_COMPATIBLE +#define TYPES_COMPATIBLE(a,b) 1 +#endif #endif diff --git a/src/osd/windows/d3d8intf.c b/src/osd/windows/d3d8intf.c index 6e9526c609d..779d57230ff 100644 --- a/src/osd/windows/d3d8intf.c +++ b/src/osd/windows/d3d8intf.c @@ -104,7 +104,7 @@ d3d *drawd3d8_init(void) } // allocate an object to hold our data - d3dptr = malloc_or_die(sizeof(*d3dptr)); + d3dptr = (d3d *)malloc_or_die(sizeof(*d3dptr)); d3dptr->version = 8; d3dptr->d3dobj = d3d8; d3dptr->dllhandle = dllhandle; diff --git a/src/osd/windows/d3d9intf.c b/src/osd/windows/d3d9intf.c index 4ec727417eb..251201487c8 100644 --- a/src/osd/windows/d3d9intf.c +++ b/src/osd/windows/d3d9intf.c @@ -102,7 +102,7 @@ d3d *drawd3d9_init(void) } // allocate an object to hold our data - d3dptr = malloc_or_die(sizeof(*d3dptr)); + d3dptr = (d3d *)malloc_or_die(sizeof(*d3dptr)); d3dptr->version = 9; d3dptr->d3dobj = d3d9; d3dptr->dllhandle = dllhandle; diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 21b4caf2f28..78e3c794ec0 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -503,7 +503,7 @@ static debugwin_info *debugwin_window_create(running_machine *machine, LPCSTR ti RECT work_bounds; // allocate memory - info = malloc_or_die(sizeof(*info)); + info = (debugwin_info *)malloc_or_die(sizeof(*info)); memset(info, 0, sizeof(*info)); // create the window @@ -584,7 +584,7 @@ static void debugwin_window_draw_contents(debugwin_info *info, HDC dc) // fill the background with light gray GetClientRect(info->wnd, &parent); - FillRect(dc, &parent, GetStockObject(LTGRAY_BRUSH)); + FillRect(dc, &parent, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); // get the parent bounds in screen coords ClientToScreen(info->wnd, &((POINT *)&parent)[0]); @@ -1007,7 +1007,7 @@ static void debugwin_view_draw_contents(debugview_info *view, HDC windc) static void debugwin_view_update(debug_view *view, void *osdprivate) { - debugview_info *info = osdprivate; + debugview_info *info = (debugview_info *)osdprivate; RECT bounds, vscroll_bounds, hscroll_bounds; debug_view_xy totalsize, visiblesize, topleft; int show_vscroll, show_hscroll; @@ -1727,7 +1727,7 @@ static void memory_create_window(running_machine *machine) // create an edit box and override its key handling info->editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), NULL, EDIT_BOX_STYLE, 0, 0, 100, 100, info->wnd, NULL, GetModuleHandle(NULL), NULL); - info->original_editproc = (void *)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); + info->original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); SetWindowLongPtr(info->editwnd, GWLP_USERDATA, (LONG_PTR)info); SetWindowLongPtr(info->editwnd, GWLP_WNDPROC, (LONG_PTR)debugwin_edit_proc); SendMessage(info->editwnd, WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE); @@ -2036,7 +2036,7 @@ static void disasm_create_window(running_machine *machine) // create an edit box and override its key handling info->editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), NULL, EDIT_BOX_STYLE, 0, 0, 100, 100, info->wnd, NULL, GetModuleHandle(NULL), NULL); - info->original_editproc = (void *)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); + info->original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); SetWindowLongPtr(info->editwnd, GWLP_USERDATA, (LONG_PTR)info); SetWindowLongPtr(info->editwnd, GWLP_WNDPROC, (LONG_PTR)debugwin_edit_proc); SendMessage(info->editwnd, WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE); @@ -2370,7 +2370,7 @@ void console_create_window(running_machine *machine) // create an edit box and override its key handling info->editwnd = CreateWindowEx(EDIT_BOX_STYLE_EX, TEXT("EDIT"), NULL, EDIT_BOX_STYLE, 0, 0, 100, 100, info->wnd, NULL, GetModuleHandle(NULL), NULL); - info->original_editproc = (void *)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); + info->original_editproc = (WNDPROC)(FPTR)GetWindowLongPtr(info->editwnd, GWLP_WNDPROC); SetWindowLongPtr(info->editwnd, GWLP_USERDATA, (LONG_PTR)info); SetWindowLongPtr(info->editwnd, GWLP_WNDPROC, (LONG_PTR)debugwin_edit_proc); SendMessage(info->editwnd, WM_SETFONT, (WPARAM)debug_font, (LPARAM)FALSE); diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index 150ea5c7449..99f0bff8e14 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -302,9 +302,9 @@ INLINE void set_filter(d3d_info *d3d, int filter) if (filter != d3d->last_filter) { d3d->last_filter = filter; - result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, D3DTSS_MINFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); + result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_MINFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture_stage_state call\n", (int)result); - result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, D3DTSS_MAGFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); + result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_MAGFILTER, filter ? D3DTEXF_LINEAR : D3DTEXF_POINT); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture_stage_state call\n", (int)result); } } @@ -316,9 +316,9 @@ INLINE void set_wrap(d3d_info *d3d, int wrap) if (wrap != d3d->last_wrap) { d3d->last_wrap = wrap; - result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, D3DTSS_ADDRESSU, wrap ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); + result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESSU, wrap ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture_stage_state call\n", (int)result); - result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, D3DTSS_ADDRESSV, wrap ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); + result = (*d3dintf->device.set_texture_stage_state)(d3d->device, 0, (D3DTEXTURESTAGESTATETYPE)D3DTSS_ADDRESSV, wrap ? D3DTADDRESS_WRAP : D3DTADDRESS_CLAMP); if (result != D3D_OK) mame_printf_verbose("Direct3D: Error %08X during device set_texture_stage_state call\n", (int)result); } } @@ -500,7 +500,7 @@ static int drawd3d_window_init(win_window_info *window) d3d_info *d3d; // allocate memory for our structures - d3d = malloc_or_die(sizeof(*d3d)); + d3d = (d3d_info *)malloc_or_die(sizeof(*d3d)); memset(d3d, 0, sizeof(*d3d)); window->drawdata = d3d; @@ -537,7 +537,7 @@ error: static void drawd3d_window_destroy(win_window_info *window) { - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; // skip if nothing if (d3d == NULL) @@ -563,7 +563,7 @@ static void drawd3d_window_destroy(win_window_info *window) static const render_primitive_list *drawd3d_window_get_primitives(win_window_info *window) { - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; RECT client; GetClientRectExceptMenu(window->hwnd, &client, window->fullscreen); @@ -583,7 +583,7 @@ static const render_primitive_list *drawd3d_window_get_primitives(win_window_inf static int drawd3d_window_draw(win_window_info *window, HDC dc, int update) { - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; const render_primitive *prim; HRESULT result; @@ -669,7 +669,7 @@ mtlog_add("drawd3d_window_draw: present end"); static int device_create(win_window_info *window) { - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; HRESULT result; int verify; @@ -819,7 +819,7 @@ static int device_create_resources(d3d_info *d3d) } // set the vertex format - result = (*d3dintf->device.set_vertex_shader)(d3d->device, VERTEX_FORMAT); + result = (*d3dintf->device.set_vertex_shader)(d3d->device, (D3DFORMAT)VERTEX_FORMAT); if (result != D3D_OK) { mame_printf_error("Error setting vertex shader (%08X)", (UINT32)result); @@ -1126,7 +1126,7 @@ static int device_test_cooperative(d3d_info *d3d) static int config_adapter_mode(win_window_info *window) { d3d_adapter_identifier identifier; - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; HRESULT result; // choose the monitor number @@ -1244,7 +1244,7 @@ static void pick_best_mode(win_window_info *window) const device_config *primary_screen = video_screen_first(window->machine->config); double target_refresh = 60.0; INT32 target_width, target_height; - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; INT32 minwidth, minheight; float best_score = 0.0f; int maxmodes; @@ -1253,7 +1253,7 @@ static void pick_best_mode(win_window_info *window) // determine the refresh rate of the primary screen if (primary_screen != NULL) { - const screen_config *config = primary_screen->inline_config; + const screen_config *config = (const screen_config *)primary_screen->inline_config; target_refresh = ATTOSECONDS_TO_HZ(config->refresh); } @@ -1288,7 +1288,7 @@ static void pick_best_mode(win_window_info *window) continue; // compute initial score based on difference between target and current - size_score = 1.0f / (1.0f + fabs(mode.Width - target_width) + fabs(mode.Height - target_height)); + size_score = 1.0f / (1.0f + fabs((float)(mode.Width - target_width)) + fabs((float)(mode.Height - target_height))); // if the mode is too small, give a big penalty if (mode.Width < minwidth || mode.Height < minheight) @@ -1338,7 +1338,7 @@ static void pick_best_mode(win_window_info *window) static int update_window_size(win_window_info *window) { - d3d_info *d3d = window->drawdata; + d3d_info *d3d = (d3d_info *)window->drawdata; RECT client; // get the current window bounds @@ -1658,7 +1658,7 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour HRESULT result; // allocate a new texture - texture = malloc_or_die(sizeof(*texture)); + texture = (texture_info *)malloc_or_die(sizeof(*texture)); memset(texture, 0, sizeof(*texture)); // fill in the core data @@ -1687,7 +1687,7 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour { D3DFORMAT format; DWORD usage = d3d->dynamic_supported ? D3DUSAGE_DYNAMIC : 0; - DWORD pool = d3d->dynamic_supported ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; + D3DPOOL pool = d3d->dynamic_supported ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED; int maxdim = MAX(d3d->presentation.BackBufferWidth, d3d->presentation.BackBufferHeight); int attempt; @@ -1734,7 +1734,7 @@ static texture_info *texture_create(d3d_info *d3d, const render_texinfo *texsour else { int scwidth, scheight; - int finalfmt; + D3DFORMAT finalfmt; // use an offscreen plain surface for stretching if supported // (won't work for YUY textures) @@ -2306,32 +2306,32 @@ static void texture_set_data(d3d_info *d3d, texture_info *texture, const render_ switch (PRIMFLAG_GET_TEXFORMAT(flags)) { case TEXFORMAT_PALETTE16: - copyline_palette16(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_palette16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; case TEXFORMAT_PALETTEA16: - copyline_palettea16(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_palettea16((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; case TEXFORMAT_RGB15: - copyline_rgb15(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_rgb15((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; case TEXFORMAT_RGB32: - copyline_rgb32(dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_rgb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; case TEXFORMAT_ARGB32: - copyline_argb32(dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_argb32((UINT32 *)dst, (UINT32 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; case TEXFORMAT_YUY16: if (d3d->yuv_format == D3DFMT_YUY2) - copyline_yuy16_to_yuy2(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_yuy16_to_yuy2((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); else if (d3d->yuv_format == D3DFMT_UYVY) - copyline_yuy16_to_uyvy(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_yuy16_to_uyvy((UINT16 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); else - copyline_yuy16_to_argb(dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); + copyline_yuy16_to_argb((UINT32 *)dst, (UINT16 *)texsource->base + srcy * texsource->rowpixels, texsource->width, texsource->palette, texture->xborderpix); break; default: diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c index e0a9557beaf..bff50c0a2af 100644 --- a/src/osd/windows/drawdd.c +++ b/src/osd/windows/drawdd.c @@ -249,7 +249,7 @@ static int drawdd_window_init(win_window_info *window) dd_info *dd; // allocate memory for our structures - dd = malloc_or_die(sizeof(*dd)); + dd = (dd_info *)malloc_or_die(sizeof(*dd)); memset(dd, 0, sizeof(*dd)); window->drawdata = dd; @@ -277,7 +277,7 @@ error: static void drawdd_window_destroy(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; // skip if nothing if (dd == NULL) @@ -299,7 +299,7 @@ static void drawdd_window_destroy(win_window_info *window) static const render_primitive_list *drawdd_window_get_primitives(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; compute_blit_surface_size(window); render_target_set_bounds(window->target, dd->blitwidth, dd->blitheight, 0); @@ -316,7 +316,7 @@ static const render_primitive_list *drawdd_window_get_primitives(win_window_info static int drawdd_window_draw(win_window_info *window, HDC dc, int update) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; const render_primitive *prim; int usemembuffer = FALSE; HRESULT result; @@ -446,7 +446,7 @@ static int drawdd_window_draw(win_window_info *window, HDC dc, int update) static int ddraw_create(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; HRESULT result; int verify; @@ -455,7 +455,7 @@ static int ddraw_create(win_window_info *window) ddraw_delete(window); // create the DirectDraw object - result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, &IID_IDirectDraw7, NULL); + result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); @@ -513,7 +513,7 @@ error: static int ddraw_create_surfaces(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; HRESULT result; // make a description of the primary surface @@ -594,7 +594,7 @@ static int ddraw_create_surfaces(win_window_info *window) if (brightness != 1.0f || contrast != 1.0f || gamma != 1.0f) { // see if we can get a GammaControl object - result = IDirectDrawSurface_QueryInterface(dd->primary, &IID_IDirectDrawGammaControl, (void **)&dd->gamma); + result = IDirectDrawSurface_QueryInterface(dd->primary, WRAP_REFIID(IID_IDirectDrawGammaControl), (void **)&dd->gamma); if (result != DD_OK) { mame_printf_warning("DirectDraw: Warning - device does not support full screen gamma correction.\n"); @@ -636,7 +636,7 @@ error: static void ddraw_delete(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; // free surfaces ddraw_delete_surfaces(window); @@ -663,7 +663,7 @@ static void ddraw_delete(win_window_info *window) static void ddraw_delete_surfaces(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; // release the gamma control if (dd->gamma != NULL) @@ -736,7 +736,7 @@ static int ddraw_verify_caps(dd_info *dd) static int ddraw_test_cooperative(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; HRESULT result; // check our current status; if we lost the device, punt to GDI @@ -806,7 +806,7 @@ static HRESULT create_surface(dd_info *dd, DDSURFACEDESC2 *desc, IDirectDrawSurf static int create_clipper(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; HRESULT result; // create a clipper for the primary surface @@ -843,7 +843,7 @@ static int create_clipper(win_window_info *window) static void compute_blit_surface_size(win_window_info *window) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; INT32 newwidth, newheight; int xscale, yscale; RECT client; @@ -967,7 +967,7 @@ static void calc_fullscreen_margins(win_window_info *window, DWORD desc_width, D static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight) { - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; IDirectDrawSurface7 *target = (dd->back != NULL) ? dd->back : dd->primary; win_monitor_info *monitor = winwindow_video_window_monitor(window, NULL); DDBLTFX blitfx = { sizeof(DDBLTFX) }; @@ -1103,14 +1103,14 @@ static void blit_to_primary(win_window_info *window, int srcwidth, int srcheight static int config_adapter_mode(win_window_info *window) { DDDEVICEIDENTIFIER2 identifier; - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; HRESULT result; // choose the monitor number get_adapter_for_monitor(dd, window->monitor); // create a temporary DirectDraw object - result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, &IID_IDirectDraw7, NULL); + result = (*directdrawcreateex)(dd->adapter_ptr, (LPVOID *)&dd->ddraw, WRAP_REFIID(IID_IDirectDraw7), NULL); if (result != DD_OK) { mame_printf_verbose("DirectDraw: Error %08X during DirectDrawCreateEx call\n", (int)result); @@ -1231,15 +1231,15 @@ static void get_adapter_for_monitor(dd_info *dd, win_monitor_info *monitor) static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) { float size_score, refresh_score, final_score; - mode_enum_info *einfo = context; - dd_info *dd = einfo->window->drawdata; + mode_enum_info *einfo = (mode_enum_info *)context; + dd_info *dd = (dd_info *)einfo->window->drawdata; // skip non-32 bit modes if (desc->ddpfPixelFormat.dwRGBBitCount != 32) return DDENUMRET_OK; // compute initial score based on difference between target and current - size_score = 1.0f / (1.0f + fabs((INT32)desc->dwWidth - einfo->target_width) + fabs((INT32)desc->dwHeight - einfo->target_height)); + size_score = 1.0f / (1.0f + fabs((float)((INT32)desc->dwWidth - einfo->target_width)) + fabs((float)((INT32)desc->dwHeight - einfo->target_height))); // if the mode is too small, give a big penalty if (desc->dwWidth < einfo->minimum_width || desc->dwHeight < einfo->minimum_height) @@ -1288,7 +1288,7 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context) static void pick_best_mode(win_window_info *window) { const device_config *primary_screen = video_screen_first(window->machine->config); - dd_info *dd = window->drawdata; + dd_info *dd = (dd_info *)window->drawdata; mode_enum_info einfo; HRESULT result; @@ -1306,7 +1306,7 @@ static void pick_best_mode(win_window_info *window) einfo.target_refresh = 60.0; if (primary_screen != NULL) { - const screen_config *config = primary_screen->inline_config; + const screen_config *config = (const screen_config *)primary_screen->inline_config; einfo.target_refresh = ATTOSECONDS_TO_HZ(config->refresh); } printf("Target refresh = %f\n", einfo.target_refresh); diff --git a/src/osd/windows/drawgdi.c b/src/osd/windows/drawgdi.c index 58f53944508..2c3cbb238b0 100644 --- a/src/osd/windows/drawgdi.c +++ b/src/osd/windows/drawgdi.c @@ -89,7 +89,7 @@ static int drawgdi_window_init(win_window_info *window) int i; // allocate memory for our structures - gdi = malloc_or_die(sizeof(*gdi)); + gdi = (gdi_info *)malloc_or_die(sizeof(*gdi)); memset(gdi, 0, sizeof(*gdi)); window->drawdata = gdi; @@ -123,7 +123,7 @@ static int drawgdi_window_init(win_window_info *window) static void drawgdi_window_destroy(win_window_info *window) { - gdi_info *gdi = window->drawdata; + gdi_info *gdi = (gdi_info *)window->drawdata; // skip if nothing if (gdi == NULL) @@ -158,7 +158,7 @@ static const render_primitive_list *drawgdi_window_get_primitives(win_window_inf static int drawgdi_window_draw(win_window_info *window, HDC dc, int update) { - gdi_info *gdi = window->drawdata; + gdi_info *gdi = (gdi_info *)window->drawdata; int width, height, pitch; RECT bounds; @@ -178,7 +178,7 @@ static int drawgdi_window_draw(win_window_info *window, HDC dc, int update) if (pitch * height * 4 > gdi->bmsize) { gdi->bmsize = pitch * height * 4 * 2; - gdi->bmdata = realloc(gdi->bmdata, gdi->bmsize); + gdi->bmdata = (UINT8 *)realloc(gdi->bmdata, gdi->bmsize); } // draw the primitives to the bitmap diff --git a/src/osd/windows/eivc.h b/src/osd/windows/eivc.h index bb13b70cd9f..37c55df97a4 100644 --- a/src/osd/windows/eivc.h +++ b/src/osd/windows/eivc.h @@ -47,7 +47,7 @@ unsigned char _BitScanReverse(unsigned long *Index, unsigned long Mask); INLINE UINT8 _count_leading_zeros(UINT32 value) { UINT32 index; - return _BitScanReverse(&index, value) ? (index ^ 31) : 32; + return _BitScanReverse((unsigned long *)&index, value) ? (index ^ 31) : 32; } #endif @@ -62,7 +62,7 @@ INLINE UINT8 _count_leading_zeros(UINT32 value) INLINE UINT8 _count_leading_ones(UINT32 value) { UINT32 index; - return _BitScanReverse(&index, ~value) ? (index ^ 31) : 32; + return _BitScanReverse((unsigned long *)&index, ~value) ? (index ^ 31) : 32; } #endif @@ -83,7 +83,7 @@ INLINE UINT8 _count_leading_ones(UINT32 value) #define compare_exchange32 _compare_exchange32 INLINE INT32 _compare_exchange32(INT32 volatile *ptr, INT32 compare, INT32 exchange) { - return _InterlockedCompareExchange(ptr, exchange, compare); + return _InterlockedCompareExchange((volatile long *)ptr, exchange, compare); } #endif @@ -116,7 +116,7 @@ INLINE INT64 _compare_exchange64(INT64 volatile *ptr, INT64 compare, INT64 excha #define atomic_exchange32 _atomic_exchange32 INLINE INT32 _atomic_exchange32(INT32 volatile *ptr, INT32 exchange) { - return _InterlockedExchange(ptr, exchange); + return _InterlockedExchange((volatile long *)ptr, exchange); } #endif @@ -131,7 +131,7 @@ INLINE INT32 _atomic_exchange32(INT32 volatile *ptr, INT32 exchange) #define atomic_add32 _atomic_add32 INLINE INT32 _atomic_add32(INT32 volatile *ptr, INT32 delta) { - return _InterlockedExchangeAdd(ptr, delta) + delta; + return _InterlockedExchangeAdd((volatile long *)ptr, delta) + delta; } #endif @@ -146,7 +146,7 @@ INLINE INT32 _atomic_add32(INT32 volatile *ptr, INT32 delta) #define atomic_increment32 _atomic_increment32 INLINE INT32 _atomic_increment32(INT32 volatile *ptr) { - return _InterlockedIncrement(ptr); + return _InterlockedIncrement((volatile long *)ptr); } #endif @@ -161,7 +161,7 @@ INLINE INT32 _atomic_increment32(INT32 volatile *ptr) #define atomic_decrement32 _atomic_decrement32 INLINE INT32 _atomic_decrement32(INT32 volatile *ptr) { - return _InterlockedDecrement(ptr); + return _InterlockedDecrement((volatile long *)ptr); } #endif diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 7943730d18d..f77efec3a01 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -433,7 +433,7 @@ INLINE input_item_id keyboard_map_scancode_to_itemid(int scancode) // scan the table for a match for (tablenum = 0; tablenum < ARRAY_LENGTH(win_key_trans_table); tablenum++) if (win_key_trans_table[tablenum][DI_KEY] == scancode) - return win_key_trans_table[tablenum][MAME_KEY]; + return (input_item_id)win_key_trans_table[tablenum][MAME_KEY]; // default to an "other" switch return ITEM_ID_OTHER_SWITCH; @@ -657,7 +657,7 @@ BOOL wininput_handle_raw(HANDLE device) // if necessary, allocate a temporary buffer and fetch the data if (size > sizeof(small_buffer)) { - data = malloc(size); + data = (LPBYTE)malloc(size); if (data == NULL) return result; } @@ -795,7 +795,7 @@ static device_info *generic_device_alloc(running_machine *machine, device_info * device_info *devinfo; // allocate memory for the device object - devinfo = malloc_or_die(sizeof(*devinfo)); + devinfo = (device_info *)malloc_or_die(sizeof(*devinfo)); memset(devinfo, 0, sizeof(*devinfo)); devinfo->head = devlist_head_ptr; devinfo->machine = machine; @@ -890,8 +890,8 @@ static void generic_device_reset(device_info *devinfo) static INT32 generic_button_get_state(void *device_internal, void *item_internal) { - device_info *devinfo = device_internal; - BYTE *itemdata = item_internal; + device_info *devinfo = (device_info *)device_internal; + BYTE *itemdata = (BYTE *)item_internal; // return the current state poll_if_necessary(devinfo->machine); @@ -905,8 +905,8 @@ static INT32 generic_button_get_state(void *device_internal, void *item_internal static INT32 generic_axis_get_state(void *device_internal, void *item_internal) { - device_info *devinfo = device_internal; - LONG *axisdata = item_internal; + device_info *devinfo = (device_info *)device_internal; + LONG *axisdata = (LONG *)item_internal; // return the current state poll_if_necessary(devinfo->machine); @@ -948,7 +948,7 @@ static void win32_init(running_machine *machine) for (axisnum = 0; axisnum < 2; axisnum++) { const char *name = utf8_from_tstring(default_axis_name[axisnum]); - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); free((void *)name); } @@ -956,7 +956,7 @@ static void win32_init(running_machine *machine) for (butnum = 0; butnum < 2; butnum++) { const char *name = utf8_from_tstring(default_button_name(butnum)); - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], ITEM_ID_BUTTON1 + butnum, generic_button_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); free((void *)name); } } @@ -1176,12 +1176,12 @@ static device_info *dinput_device_create(running_machine *machine, device_info * devinfo = generic_device_alloc(machine, devlist_head_ptr, instance->tszInstanceName); // attempt to create a device - result = IDirectInput_CreateDevice(dinput, &instance->guidInstance, &devinfo->dinput.device, NULL); + result = IDirectInput_CreateDevice(dinput, WRAP_REFIID(instance->guidInstance), &devinfo->dinput.device, NULL); if (result != DI_OK) goto error; // try to get a version 2 device for it - result = IDirectInputDevice_QueryInterface(devinfo->dinput.device, &IID_IDirectInputDevice2, (void **)&devinfo->dinput.device2); + result = IDirectInputDevice_QueryInterface(devinfo->dinput.device, WRAP_REFIID(IID_IDirectInputDevice2), (void **)&devinfo->dinput.device2); if (result != DI_OK) devinfo->dinput.device2 = NULL; @@ -1268,7 +1268,7 @@ static const char *dinput_device_item_name(device_info *devinfo, int offset, con return utf8_from_tstring(namestring); // otherwise, allocate space to add the suffix - combined = malloc_or_die(sizeof(TCHAR) * (_tcslen(namestring) + 1 + _tcslen(suffix) + 1)); + combined = (TCHAR *)malloc_or_die(sizeof(TCHAR) * (_tcslen(namestring) + 1 + _tcslen(suffix) + 1)); _tcscpy(combined, namestring); _tcscat(combined, TEXT(" ")); _tcscat(combined, suffix); @@ -1311,7 +1311,7 @@ static HRESULT dinput_device_poll(device_info *devinfo) static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) { - running_machine *machine = ref; + running_machine *machine = (running_machine *)ref; device_info *devinfo; int keynum; @@ -1367,7 +1367,7 @@ static void dinput_keyboard_poll(device_info *devinfo) static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) { device_info *devinfo, *guninfo = NULL; - running_machine *machine = ref; + running_machine *machine = (running_machine *)ref; int axisnum, butnum; HRESULT result; @@ -1412,9 +1412,9 @@ static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) const char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL); // add to the mouse device and optionally to the gun device as well - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); if (guninfo != NULL && axisnum < 2) - input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); free((void *)name); } @@ -1422,13 +1422,14 @@ static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) // populate the buttons for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++) { - const char *name = dinput_device_item_name(devinfo, offsetof(DIMOUSESTATE, rgbButtons[butnum]), default_button_name(butnum), NULL); + FPTR offset = (FPTR)(&((DIMOUSESTATE *)NULL)->rgbButtons[butnum]); + const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL); // add to the mouse device and optionally to the gun device as well // note that the gun device points to the mouse buttons rather than its own - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], ITEM_ID_BUTTON1 + butnum, generic_button_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); if (guninfo != NULL) - input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], ITEM_ID_BUTTON1 + butnum, generic_button_get_state); + input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); free((void *)name); } @@ -1469,7 +1470,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r { DWORD cooperative_level = (HAS_WINDOW_MENU ? DISCL_BACKGROUND : DISCL_FOREGROUND) | DISCL_EXCLUSIVE; int axisnum, axiscount, povnum, butnum; - running_machine *machine = ref; + running_machine *machine = (running_machine *)ref; device_info *devinfo; HRESULT result; @@ -1521,7 +1522,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r // populate the item description as well name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, lX) + axisnum * sizeof(LONG), default_axis_name[axisnum], NULL); - input_device_item_add(devinfo->device, name, &devinfo->joystick.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(devinfo->device, name, &devinfo->joystick.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); free((void *)name); axiscount++; @@ -1556,8 +1557,9 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r // populate the buttons for (butnum = 0; butnum < devinfo->dinput.caps.dwButtons; butnum++) { - const char *name = dinput_device_item_name(devinfo, offsetof(DIJOYSTATE2, rgbButtons[butnum]), default_button_name(butnum), NULL); - input_device_item_add(devinfo->device, name, &devinfo->joystick.state.rgbButtons[butnum], (butnum < 16) ? (ITEM_ID_BUTTON1 + butnum) : ITEM_ID_OTHER_SWITCH, generic_button_get_state); + FPTR offset = (FPTR)(&((DIJOYSTATE2 *)NULL)->rgbButtons[butnum]); + const char *name = dinput_device_item_name(devinfo, offset, default_button_name(butnum), NULL); + input_device_item_add(devinfo->device, name, &devinfo->joystick.state.rgbButtons[butnum], (butnum < 16) ? (input_item_id)(ITEM_ID_BUTTON1 + butnum) : ITEM_ID_OTHER_SWITCH, generic_button_get_state); free((void *)name); } @@ -1592,7 +1594,7 @@ static void dinput_joystick_poll(device_info *devinfo) static INT32 dinput_joystick_pov_get_state(void *device_internal, void *item_internal) { - device_info *devinfo = device_internal; + device_info *devinfo = (device_info *)device_internal; int povnum = (FPTR)item_internal / 4; int povdir = (FPTR)item_internal % 4; INT32 result = 0; @@ -1651,7 +1653,7 @@ static void rawinput_init(running_machine *machine) goto error; if (device_count == 0) goto error; - devlist = malloc_or_die(device_count * sizeof(*devlist)); + devlist = (RAWINPUTDEVICELIST *)malloc_or_die(device_count * sizeof(*devlist)); if ((*get_rawinput_device_list)(devlist, &device_count, sizeof(*devlist)) == -1) goto error; @@ -1731,7 +1733,7 @@ static device_info *rawinput_device_create(running_machine *machine, device_info // determine the length of the device name, allocate it, and fetch it if ((*get_rawinput_device_info)(device->hDevice, RIDI_DEVICENAME, NULL, &name_length) != 0) goto error; - tname = malloc_or_die(name_length * sizeof(*tname)); + tname = (TCHAR *)malloc_or_die(name_length * sizeof(*tname)); if ((*get_rawinput_device_info)(device->hDevice, RIDI_DEVICENAME, tname, &name_length) == -1) goto error; @@ -1790,7 +1792,7 @@ static TCHAR *rawinput_device_improve_name(TCHAR *name) return name; // allocate a temporary string and concatenate the base path plus the name - regpath = malloc_or_die(sizeof(*regpath) * (_tcslen(basepath) + 1 + _tcslen(name))); + regpath = (TCHAR *)malloc_or_die(sizeof(*regpath) * (_tcslen(basepath) + 1 + _tcslen(name))); _tcscpy(regpath, basepath); chdst = regpath + _tcslen(regpath); @@ -1902,7 +1904,7 @@ convert: chsrc++; else chsrc = regstring; - name = malloc_or_die(sizeof(*name) * (_tcslen(chsrc) + 1)); + name = (TCHAR *)malloc_or_die(sizeof(*name) * (_tcslen(chsrc) + 1)); _tcscpy(name, chsrc); exit: @@ -2019,9 +2021,9 @@ static void rawinput_mouse_enum(running_machine *machine, PRAWINPUTDEVICELIST de const char *name = utf8_from_tstring(default_axis_name[axisnum]); // add to the mouse device and optionally to the gun device as well - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); if (guninfo != NULL && axisnum < 2) - input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, ITEM_ID_XAXIS + axisnum, generic_axis_get_state); + input_device_item_add(guninfo->device, name, &guninfo->mouse.state.lX + axisnum, (input_item_id)(ITEM_ID_XAXIS + axisnum), generic_axis_get_state); free((void *)name); } @@ -2033,9 +2035,9 @@ static void rawinput_mouse_enum(running_machine *machine, PRAWINPUTDEVICELIST de // add to the mouse device and optionally to the gun device as well // note that the gun device points to the mouse buttons rather than its own - input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], ITEM_ID_BUTTON1 + butnum, generic_button_get_state); + input_device_item_add(devinfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); if (guninfo != NULL) - input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], ITEM_ID_BUTTON1 + butnum, generic_button_get_state); + input_device_item_add(guninfo->device, name, &devinfo->mouse.state.rgbButtons[butnum], (input_item_id)(ITEM_ID_BUTTON1 + butnum), generic_button_get_state); free((void *)name); } @@ -2130,7 +2132,7 @@ static TCHAR *reg_query_string(HKEY key, const TCHAR *path) return NULL; // allocate a buffer - buffer = malloc_or_die(datalen + sizeof(*buffer)); + buffer = (TCHAR *)malloc_or_die(datalen + sizeof(*buffer)); buffer[datalen / sizeof(*buffer)] = 0; // now get the actual data diff --git a/src/osd/windows/output.c b/src/osd/windows/output.c index 96093969590..bdb821a4f3a 100644 --- a/src/osd/windows/output.c +++ b/src/osd/windows/output.c @@ -228,7 +228,7 @@ static LRESULT register_client(HWND hwnd, LPARAM id) } // add us to the end - *client = malloc_or_die(sizeof(**client)); + *client = (registered_client *)malloc_or_die(sizeof(**client)); (*client)->next = NULL; (*client)->id = id; (*client)->hwnd = hwnd; @@ -287,7 +287,7 @@ static LRESULT send_id_string(running_machine *machine, HWND hwnd, LPARAM id) // allocate memory for the message datalen = sizeof(*temp) + strlen(name); - temp = malloc_or_die(datalen); + temp = (copydata_id_string *)malloc_or_die(datalen); temp->id = id; strcpy(temp->string, name); diff --git a/src/osd/windows/vconv.c b/src/osd/windows/vconv.c index 37d2fc1a7ed..e3a597955f7 100644 --- a/src/osd/windows/vconv.c +++ b/src/osd/windows/vconv.c @@ -49,80 +49,84 @@ struct _translation_info static const translation_info gcc_translate[] = { - { 0, "-D*", "/D*" }, - { 0, "-U*", "/U*" }, - { 0, "-I*", "/I*" }, - { 0, "-o*", "~*" }, - { 0, "-include*", "/FI*" }, - { 0, "-c", "/c~/Fo" }, - { 0, "-E", "/c~/E >" }, - { 0, "-S", "/c~/Fa" }, - { VS7, "-O0", "/Od /GS /Oi" }, - { 0, "-O0", "/Od" }, - { 0, "-O1", "/O2" }, - { 0, "-O2", "/O2" }, - { 0, "-O3", "/O2" }, - { 0, "-Os", "/O1" }, - { 0, "-g", "/Zi" }, - { VS2005, "-fno-strict-aliasing", "" }, // deprecated in VS2005 - { 0, "-fno-strict-aliasing", "/Oa" }, + { 0, "-D*", "/D*" }, + { 0, "-U*", "/U*" }, + { 0, "-I*", "/I*" }, + { 0, "-o*", "~*" }, + { 0, "-include*", "/FI*" }, + { 0, "-c", "/c~/Fo" }, + { 0, "-E", "/c~/E >" }, + { 0, "-S", "/c~/Fa" }, + { VS7, "-O0", "/Od /GS /Oi" }, + { 0, "-O0", "/Od" }, + { 0, "-O1", "/O2" }, + { 0, "-O2", "/O2" }, + { 0, "-O3", "/O2" }, + { 0, "-Os", "/O1" }, + { 0, "-g", "/Zi" }, + { VS2005, "-fno-strict-aliasing", "" }, // deprecated in VS2005 + { 0, "-fno-strict-aliasing", "/Oa" }, { 0, "-fno-omit-frame-pointer", "" }, - { 0, "-Werror", "/WX" }, - { VS7, "-Wall", "/Wall /W3 /wd4018 /wd4146 /wd4242 /wd4244 /wd4619 /wd4702 /wd4706 /wd4710 /wd4711 /wd4738 /wd4826" }, - { 0, "-Wall", "/W0" }, - { VS7, "-Wno-unused", "/wd4100 /wd4101 /wd4102" }, - { 0, "-W*", "" }, - { VS2005, "-march=*", "" }, // deprecated in VS2005 - { 0, "-march=pentium", "/G5" }, - { 0, "-march=pentiumpro", "/G6" }, - { 0, "-march=pentium3", "/G6" }, - { 0, "-march=pentium-m", "/G6" }, - { 0, "-march=athlon", "/G7" }, - { 0, "-march=pentium4", "/G7" }, - { 0, "-march=athlon64", "/G7" }, - { VS71, "-msse2", "/arch:SSE2" }, - { 0, "-msse2", "" }, - { 0, "-msse3", "" }, - { 0, "-mwindows", "" }, - { 0, "-mno-cygwin", "" }, - { 0, "-std=gnu89", "" }, - { 0, "-pipe", "" }, + { 0, "-Werror", "/WX" }, + { VS7, "-Wall", "/Wall /W3 /wd4018 /wd4146 /wd4242 /wd4244 /wd4619 /wd4702 /wd4706 /wd4710 /wd4711 /wd4738 /wd4826" }, + { 0, "-Wall", "/W0" }, + { VS7, "-Wno-unused", "/wd4100 /wd4101 /wd4102" }, + { 0, "-W*", "" }, + { VS2005, "-march=*", "" }, // deprecated in VS2005 + { 0, "-march=pentium", "/G5" }, + { 0, "-march=pentiumpro", "/G6" }, + { 0, "-march=pentium3", "/G6" }, + { 0, "-march=pentium-m", "/G6" }, + { 0, "-march=athlon", "/G7" }, + { 0, "-march=pentium4", "/G7" }, + { 0, "-march=athlon64", "/G7" }, + { VS71, "-msse2", "/arch:SSE2" }, + { 0, "-msse2", "" }, + { 0, "-msse3", "" }, + { 0, "-mwindows", "" }, + { 0, "-mno-cygwin", "" }, + { 0, "-std=gnu89", "" }, + { 0, "-std=gnu++98", "/TP" }, + { 0, "-pipe", "" }, + { 0, "-x", "" }, + { 0, "c++", "" }, { 0 } }; static const translation_info ld_translate[] = { - { VS2008, "-lbufferoverflowu","" }, - { 0, "-l*", "*.lib" }, - { 0, "-o*", "/out:*" }, - { 0, "-Wl,-Map,*", "/map:*" }, + { VS2008, "-lbufferoverflowu", "" }, + { 0, "-l*", "*.lib" }, + { 0, "-o*", "/out:*" }, + { 0, "-Wl,-Map,*", "/map:*" }, { 0, "-Wl,--allow-multiple-definition", "/force:multiple" }, - { 0, "-Wl,--warn-common", "" }, - { 0, "-mno-cygwin", "" }, - { 0, "-s", "" }, - { 0, "-WO", "" }, - { 0, "-mconsole", "/subsystem:console" }, - { 0, "-mwindows", "/subsystem:windows" }, - { 0, "-shared", "/dll" }, + { 0, "-Wl,--warn-common", "" }, + { 0, "-mno-cygwin", "" }, + { 0, "-s", "" }, + { 0, "-WO", "" }, + { 0, "-mconsole", "/subsystem:console" }, + { 0, "-mwindows", "/subsystem:windows" }, + { 0, "-shared", "/dll" }, { 0 } }; static const translation_info ar_translate[] = { - { 0, "-cr", "" }, + { 0, "-cr", "" }, + { 0, "/LTCG", "/LTCG" }, { 0 } }; static const translation_info windres_translate[] = { - { 0, "-D*", "/D*" }, - { 0, "-U*", "/U*" }, - { 0, "-I*", "/I*" }, - { 0, "--include-dir*", "/I*" }, - { 0, "-o*", "/fo*" }, - { 0, "-O*", "" }, - { 0, "-i*", "*" }, + { 0, "-D*", "/D*" }, + { 0, "-U*", "/U*" }, + { 0, "-I*", "/I*" }, + { 0, "--include-dir*", "/I*" }, + { 0, "-o*", "/fo*" }, + { 0, "-O*", "" }, + { 0, "-i*", "*" }, { 0 } }; @@ -272,120 +276,123 @@ static void build_command_line(int argc, char *argv[]) for (param = 2; param < argc; param++) { const char *src = argv[param]; + int firstchar = src[0]; int srclen = strlen(src); + int matched = FALSE; int i; // find a match - if (src[0] == '-') + for (i = 0; !matched && transtable[i].gcc_option != NULL; i++) { - for (i = 0; transtable[i].gcc_option; i++) - { - const char *compare = transtable[i].gcc_option; - const char *replace; - int j; + const char *compare = transtable[i].gcc_option; + const char *replace; + int j; - // check version number - if (exe_version < transtable[i].vc_version) - continue; + // check version number + if (exe_version < transtable[i].vc_version) + continue; - // find a match - for (j = 0; j < srclen; j++) - if (src[j] != compare[j]) - break; + // find a match + for (j = 0; j < srclen; j++) + if (src[j] != compare[j]) + break; - // if we hit an asterisk, we're ok - if (compare[j] == '*') + // if we hit an asterisk, we're ok + if (compare[j] == '*') + { + // if this is the end of the parameter, use the next one + if (src[j] == 0) + src = argv[++param]; + else + src += j; + + // copy the replacement up to the asterisk + replace = transtable[i].vc_option; + while (*replace && *replace != '*') { - // if this is the end of the parameter, use the next one - if (src[j] == 0) - src = argv[++param]; - else - src += j; - - // copy the replacement up to the asterisk - replace = transtable[i].vc_option; - while (*replace && *replace != '*') - { - if (*replace == '~') - { - dst += sprintf(dst, "%s", outstring); - replace++; - } - else - *dst++ = *replace++; - } - - // if we have an asterisk in the replacement, copy the rest of the source - if (*replace == '*') + if (*replace == '~') { - int addquote = (strchr(src, ' ') != NULL); - - if (addquote) - *dst++ = '"'; - while (*src) - { - *dst++ = (*src == '/') ? '\\' : *src; - src++; - } - if (addquote) - *dst++ = '"'; - - // if there's stuff after the asterisk, copy that + dst += sprintf(dst, "%s", outstring); replace++; - while (*replace) - *dst++ = *replace++; } - - // append a final space - *dst++ = ' '; - break; + else + *dst++ = *replace++; } - // if we hit the end, we're also ok - else if (compare[j] == 0 && j == srclen) + // if we have an asterisk in the replacement, copy the rest of the source + if (*replace == '*') { - // copy the replacement up to the tilde - replace = transtable[i].vc_option; - while (*replace && *replace != '~') - *dst++ = *replace++; + int addquote = (strchr(src, ' ') != NULL); - // if we hit a tilde, set the new output - if (*replace == '~') - outstring = replace + 1; + if (addquote) + *dst++ = '"'; + while (*src) + { + *dst++ = (*src == '/') ? '\\' : *src; + src++; + } + if (addquote) + *dst++ = '"'; - // append a final space - *dst++ = ' '; - break; + // if there's stuff after the asterisk, copy that + replace++; + while (*replace) + *dst++ = *replace++; } - // else keep looking + // append a final space + *dst++ = ' '; + matched = TRUE; } - // warn if we didn't get a match - if (!transtable[i].gcc_option) - fprintf(stderr, "Unable to match parameter '%s'\n", src); - } + // if we hit the end, we're also ok + else if (compare[j] == 0 && j == srclen) + { + // copy the replacement up to the tilde + replace = transtable[i].vc_option; + while (*replace && *replace != '~') + *dst++ = *replace++; + + // if we hit a tilde, set the new output + if (*replace == '~') + outstring = replace + 1; + + // append a final space + *dst++ = ' '; + matched = TRUE; + } - // otherwise, assume it's a filename and copy translating slashes - // it can also be a Windows-specific option which is passed through unscathed - else + // else keep looking + } + + // if we didn't match, process + if (!matched) { - int dotrans = (*src != '/'); + // warn if we missed a parameter + if (transtable[i].gcc_option == NULL && firstchar == '-') + fprintf(stderr, "Unable to match parameter '%s'\n", src); - // if the output filename is implicitly first, append the out parameter - if (output_is_first) + // otherwise, assume it's a filename and copy translating slashes + // it can also be a Windows-specific option which is passed through unscathed + else if (firstchar != '-') { - dst += sprintf(dst, "%s", outstring); - output_is_first = 0; - } + int dotrans = (*src != '/'); - // now copy the rest of the string - while (*src) - { - *dst++ = (dotrans && *src == '/') ? '\\' : *src; - src++; + // if the output filename is implicitly first, append the out parameter + if (output_is_first) + { + dst += sprintf(dst, "%s", outstring); + output_is_first = 0; + } + + // now copy the rest of the string + while (*src) + { + *dst++ = (dotrans && *src == '/') ? '\\' : *src; + src++; + } + *dst++ = ' '; } - *dst++ = ' '; } } diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index d1274ce55bb..38c8b837a35 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -255,7 +255,7 @@ static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, assert(result); // allocate a new monitor info - monitor = malloc_or_die(sizeof(*monitor)); + monitor = (win_monitor_info *)malloc_or_die(sizeof(*monitor)); memset(monitor, 0, sizeof(*monitor)); // copy in the data @@ -439,7 +439,7 @@ static void extract_video_config(running_machine *machine) static void load_effect_overlay(running_machine *machine, const char *filename) { const device_config *screen; - char *tempstr = malloc_or_die(strlen(filename) + 5); + char *tempstr = (char *)malloc_or_die(strlen(filename) + 5); char *dest; // append a .PNG extension diff --git a/src/osd/windows/windir.c b/src/osd/windows/windir.c index 7a84cccd81a..6930bee81b8 100644 --- a/src/osd/windows/windir.c +++ b/src/osd/windows/windir.c @@ -51,7 +51,7 @@ osd_directory *osd_opendir(const char *dirname) size_t dirfilter_size; // allocate memory to hold the osd_tool_directory structure - dir = malloc(sizeof(*dir)); + dir = (osd_directory *)malloc(sizeof(*dir)); if (dir == NULL) goto error; memset(dir, 0, sizeof(*dir)); diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 9df5e224c85..d93b34c4bd2 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -582,7 +582,7 @@ void winwindow_video_window_create(running_machine *machine, int index, win_moni assert(GetCurrentThreadId() == main_threadid); // allocate a new window object - window = malloc_or_die(sizeof(*window)); + window = (win_window_info *)malloc_or_die(sizeof(*window)); memset(window, 0, sizeof(*window)); window->maxwidth = config->width; window->maxheight = config->height; diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak index 9ebb1adebeb..6270d54db5e 100644 --- a/src/osd/windows/windows.mak +++ b/src/osd/windows/windows.mak @@ -88,7 +88,7 @@ RCFLAGS = -O coff -I $(WINSRC) -I $(WINOBJ) #------------------------------------------------- ifdef CYGWIN_BUILD -CFLAGS += -mno-cygwin +CCOMFLAGS += -mno-cygwin LDFLAGS += -mno-cygwin endif @@ -115,24 +115,28 @@ RC = @$(VCONV) windres # make sure we use the multithreaded runtime ifdef DEBUG -CC += /MTd +CCOMFLAGS += /MTd else -CC += /MT +CCOMFLAGS += /MT endif # turn on link-time codegen if the MAXOPT flag is also set ifdef MAXOPT -CC += /GL -LD += /LTCG +CCOMFLAGS += /GL +LDFLAGS += /LTCG +AR += /LTCG endif ifdef PTR64 -CC += /wd4267 +CCOMFLAGS += /wd4267 endif +# disable function pointer warnings in C++ which are evil to work around +CPPONLYFLAGS += /wd4191 + # explicitly set the entry point for UNICODE builds ifdef UNICODE -LD += /ENTRY:wmainCRTStartup +LDFLAGS += /ENTRY:wmainCRTStartup endif # add some VC++-specific defines @@ -194,10 +198,10 @@ endif #------------------------------------------------- # add our prefix files to the mix -CFLAGS += -include $(WINSRC)/winprefix.h +CCOMFLAGS += -include $(WINSRC)/winprefix.h ifdef WIN95_MULTIMON -CFLAGS += -DWIN95_MULTIMON +CCOMFLAGS += -DWIN95_MULTIMON endif # add the windows libraries @@ -205,10 +209,10 @@ LIBS += -luser32 -lgdi32 -lddraw -ldsound -ldxguid -lwinmm -ladvapi32 -lcomctl32 ifeq ($(DIRECTINPUT),8) LIBS += -ldinput8 -CFLAGS += -DDIRECTINPUT_VERSION=0x0800 +CCOMFLAGS += -DDIRECTINPUT_VERSION=0x0800 else LIBS += -ldinput -CFLAGS += -DDIRECTINPUT_VERSION=0x0700 +CCOMFLAGS += -DDIRECTINPUT_VERSION=0x0700 endif ifdef PTR64 @@ -263,7 +267,7 @@ OSDOBJS = \ $(WINOBJ)/winmain.o ifeq ($(DIRECT3D),9) -CFLAGS += -DDIRECT3D_VERSION=0x0900 +CCOMFLAGS += -DDIRECT3D_VERSION=0x0900 else OSDOBJS += $(WINOBJ)/d3d8intf.o endif diff --git a/src/osd/windows/winfile.c b/src/osd/windows/winfile.c index e80e3858a2e..696484c8c1c 100644 --- a/src/osd/windows/winfile.c +++ b/src/osd/windows/winfile.c @@ -74,7 +74,7 @@ file_error osd_open(const char *path, UINT32 openflags, osd_file **file, UINT64 } // allocate a file object, plus space for the converted filename - *file = malloc(sizeof(**file) + sizeof(TCHAR) * _tcslen(t_path)); + *file = (osd_file *)malloc(sizeof(**file) + sizeof(TCHAR) * _tcslen(t_path)); if (*file == NULL) { filerr = FILERR_OUT_OF_MEMORY; @@ -320,8 +320,8 @@ int osd_uchar_from_osdchar(UINT32 *uchar, const char *osdchar, size_t count) DWORD create_path_recursive(const TCHAR *path) { - TCHAR *sep = _tcsrchr(path, '\\'); - file_error filerr; + TCHAR *sep = (TCHAR *)_tcsrchr(path, '\\'); + DWORD filerr; // if there's still a separator, and it's not the root, nuke it and recurse if (sep != NULL && sep > path && sep[0] != ':' && sep[-1] != '\\') diff --git a/src/osd/windows/winmain.h b/src/osd/windows/winmain.h index 7a601c051ae..790f7d276e7 100644 --- a/src/osd/windows/winmain.h +++ b/src/osd/windows/winmain.h @@ -82,6 +82,18 @@ //============================================================ +// MACROS +//============================================================ + +#ifdef __cplusplus +#define WRAP_REFIID(x) x +#else +#define WRAP_REFIID(x) &x +#endif + + + +//============================================================ // GLOBAL VARIABLES //============================================================ diff --git a/src/osd/windows/winprefix.h b/src/osd/windows/winprefix.h index dd2f60892a9..ef0f3f1e69b 100644 --- a/src/osd/windows/winprefix.h +++ b/src/osd/windows/winprefix.h @@ -30,7 +30,6 @@ void free_file_line(void *memory, const char *file, int line); #endif #ifdef _MSC_VER -void *__cdecl _alloca(size_t); #define alloca _alloca #if _MSC_VER < 1500 #define vsnprintf _vsnprintf diff --git a/src/osd/windows/winsync.c b/src/osd/windows/winsync.c index bce3f7cd480..cf8b9987a4a 100644 --- a/src/osd/windows/winsync.c +++ b/src/osd/windows/winsync.c @@ -52,7 +52,7 @@ static int checked_for_try_enter = FALSE; osd_lock *osd_lock_alloc(void) { - osd_lock *lock = malloc(sizeof(*lock)); + osd_lock *lock = (osd_lock *)malloc(sizeof(*lock)); if (lock == NULL) return NULL; InitializeCriticalSection(&lock->critsect); diff --git a/src/osd/windows/winwork.c b/src/osd/windows/winwork.c index 6f176466ec4..4b81ad802bf 100644 --- a/src/osd/windows/winwork.c +++ b/src/osd/windows/winwork.c @@ -254,7 +254,7 @@ osd_work_queue *osd_work_queue_alloc(int flags) int threadnum; // allocate a new queue - queue = malloc(sizeof(*queue)); + queue = (osd_work_queue *)malloc(sizeof(*queue)); if (queue == NULL) goto error; memset(queue, 0, sizeof(*queue)); @@ -284,7 +284,7 @@ osd_work_queue *osd_work_queue_alloc(int flags) queue->threads = MIN(queue->threads, WORK_MAX_THREADS); // allocate memory for thread array (+1 to count the calling thread) - queue->thread = malloc((queue->threads + 1) * sizeof(queue->thread[0])); + queue->thread = (work_thread_info *)malloc((queue->threads + 1) * sizeof(queue->thread[0])); if (queue->thread == NULL) goto error; memset(queue->thread, 0, (queue->threads + 1) * sizeof(queue->thread[0])); @@ -512,7 +512,7 @@ osd_work_item *osd_work_item_queue_multiple(osd_work_queue *queue, osd_work_call if (item == NULL) { // allocate the item - item = malloc(sizeof(*item)); + item = (osd_work_item *)malloc(sizeof(*item)); if (item == NULL) return NULL; item->event = NULL; @@ -668,7 +668,7 @@ static int effective_num_processors(void) static unsigned __stdcall worker_thread_entry(void *param) { - work_thread_info *thread = param; + work_thread_info *thread = (work_thread_info *)param; osd_work_queue *queue = thread->queue; // loop until we exit |