diff options
author | 2015-03-20 12:19:40 +0100 | |
---|---|---|
committer | 2015-03-20 12:19:40 +0100 | |
commit | c61c31ee062f3df7881f938372a7a8a4993acdce (patch) | |
tree | 6ff13a1e74b0de95a41b770aa35b7e75eff50ea8 /src | |
parent | 9f29fc0916ea0e39150572194fb99b0d45f77a7c (diff) |
moved assert replacement inside emucore.h so it is actually used / removed assert.h include from some headers and added it to lots of source
Diffstat (limited to 'src')
51 files changed, 81 insertions, 20 deletions
diff --git a/src/emu/emucore.h b/src/emu/emucore.h index 23f8808a739..a9ca5b35ef9 100644 --- a/src/emu/emucore.h +++ b/src/emu/emucore.h @@ -31,6 +31,21 @@ #include <exception> #include <typeinfo> +// standard assertion macros +#undef assert +#undef assert_always + +#ifdef MAME_DEBUG_FAST +#define assert(x) ((void)0) +#define assert_always(x, msg) ((void)0) +#elif MAME_DEBUG +#define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) +#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) +#else +#define assert(x) do { } while (0) +#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) +#endif + // core system includes #include "osdcomm.h" #include "astring.h" @@ -214,19 +229,6 @@ inline void operator--(_Type &value, int) { value = (_Type)((int)value - 1); } #define FUNC_NULL NULL, "(null)" -// standard assertion macros -#undef assert -#undef assert_always - -#ifdef MAME_DEBUG -#define assert(x) do { if (!(x)) throw emu_fatalerror("assert: %s:%d: %s", __FILE__, __LINE__, #x); } while (0) -#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s\nCaused by assert: %s:%d: %s", msg, __FILE__, __LINE__, #x); } while (0) -#else -#define assert(x) do { } while (0) -#define assert_always(x, msg) do { if (!(x)) throw emu_fatalerror("Fatal error: %s (%s:%d)", msg, __FILE__, __LINE__); } while (0) -#endif - - // macros to convert radians to degrees and degrees to radians #define RADIAN_TO_DEGREE(x) ((180.0 / M_PI) * (x)) #define DEGREE_TO_RADIAN(x) ((M_PI / 180.0) * (x)) diff --git a/src/emu/sound/wavwrite.c b/src/emu/sound/wavwrite.c index 36cae72ded5..4e4a5677c51 100644 --- a/src/emu/sound/wavwrite.c +++ b/src/emu/sound/wavwrite.c @@ -1,4 +1,4 @@ -#include "coretmpl.h" +#include "emu.h" #include "sound/wavwrite.h" struct wav_file diff --git a/src/lib/formats/ami_dsk.c b/src/lib/formats/ami_dsk.c index 230310c4995..a222208d46d 100644 --- a/src/lib/formats/ami_dsk.c +++ b/src/lib/formats/ami_dsk.c @@ -8,6 +8,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/ami_dsk.h" adf_format::adf_format() : floppy_image_format_t() diff --git a/src/lib/formats/ap2_dsk.c b/src/lib/formats/ap2_dsk.c index 668a44c113a..c62033eb2ff 100644 --- a/src/lib/formats/ap2_dsk.c +++ b/src/lib/formats/ap2_dsk.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <string.h> +#include <assert.h> #include "ap2_dsk.h" #include "basicdsk.h" diff --git a/src/lib/formats/atari_dsk.c b/src/lib/formats/atari_dsk.c index 3e721adc0ff..cbfbcc3d21f 100644 --- a/src/lib/formats/atari_dsk.c +++ b/src/lib/formats/atari_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/atari_dsk.h" static FLOPPY_IDENTIFY( atari_dsk_identify ) diff --git a/src/lib/formats/atarist_dsk.c b/src/lib/formats/atarist_dsk.c index 7901ba2a55d..aa0761465bf 100644 --- a/src/lib/formats/atarist_dsk.c +++ b/src/lib/formats/atarist_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/atarist_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/basicdsk.c b/src/lib/formats/basicdsk.c index d20a29cc7b0..6b6b11ee4d1 100644 --- a/src/lib/formats/basicdsk.c +++ b/src/lib/formats/basicdsk.c @@ -8,6 +8,7 @@ #include <stdlib.h> #include <string.h> +#include <assert.h> #include "basicdsk.h" diff --git a/src/lib/formats/cassimg.c b/src/lib/formats/cassimg.c index bb527ce91f5..7de195315ef 100644 --- a/src/lib/formats/cassimg.c +++ b/src/lib/formats/cassimg.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "imageutl.h" #include "cassimg.h" diff --git a/src/lib/formats/coco_dsk.c b/src/lib/formats/coco_dsk.c index d583813823a..00b785d3e8b 100644 --- a/src/lib/formats/coco_dsk.c +++ b/src/lib/formats/coco_dsk.c @@ -8,6 +8,7 @@ #include <string.h> #include <time.h> +#include <assert.h> #include "formats/coco_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/cqm_dsk.c b/src/lib/formats/cqm_dsk.c index ca8ae98039b..0061af8c869 100644 --- a/src/lib/formats/cqm_dsk.c +++ b/src/lib/formats/cqm_dsk.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "flopimg.h" #define CQM_HEADER_SIZE 133 diff --git a/src/lib/formats/csw_cas.c b/src/lib/formats/csw_cas.c index 39ceb594e8f..e6b51b78c1e 100644 --- a/src/lib/formats/csw_cas.c +++ b/src/lib/formats/csw_cas.c @@ -23,6 +23,7 @@ Offset Value Type Description #include <string.h> #include <zlib.h> +#include <assert.h> #include "uef_cas.h" #include "csw_cas.h" diff --git a/src/lib/formats/fdi_dsk.c b/src/lib/formats/fdi_dsk.c index 9bf9019f5d3..9d556f66e9a 100644 --- a/src/lib/formats/fdi_dsk.c +++ b/src/lib/formats/fdi_dsk.c @@ -14,6 +14,7 @@ */ +#include <assert.h> #include "imageutl.h" #include "flopimg.h" diff --git a/src/lib/formats/hect_dsk.c b/src/lib/formats/hect_dsk.c index d3644afd536..50e112f0774 100644 --- a/src/lib/formats/hect_dsk.c +++ b/src/lib/formats/hect_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/hect_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/kc_cas.c b/src/lib/formats/kc_cas.c index 9198a98c4d5..7791afd2e7a 100644 --- a/src/lib/formats/kc_cas.c +++ b/src/lib/formats/kc_cas.c @@ -13,6 +13,8 @@ ********************************************************************/ +#include <assert.h> + #include "kc_cas.h" #define SMPLO -32768 diff --git a/src/lib/formats/msx_dsk.c b/src/lib/formats/msx_dsk.c index df1a318ab6e..11817d8ab32 100644 --- a/src/lib/formats/msx_dsk.c +++ b/src/lib/formats/msx_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/msx_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/nes_dsk.c b/src/lib/formats/nes_dsk.c index 99878833f27..ce62b4fba0e 100644 --- a/src/lib/formats/nes_dsk.c +++ b/src/lib/formats/nes_dsk.c @@ -8,6 +8,7 @@ #include <string.h> +#include <assert.h> #include "formats/nes_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/pc98_dsk.c b/src/lib/formats/pc98_dsk.c index df527f92cc4..6ef28d01eeb 100644 --- a/src/lib/formats/pc98_dsk.c +++ b/src/lib/formats/pc98_dsk.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "formats/pc98_dsk.h" diff --git a/src/lib/formats/pc_dsk.c b/src/lib/formats/pc_dsk.c index 45a076cc91c..152dffed15a 100644 --- a/src/lib/formats/pc_dsk.c +++ b/src/lib/formats/pc_dsk.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "formats/pc_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/sorc_dsk.c b/src/lib/formats/sorc_dsk.c index e7939456139..3c7aee10c33 100644 --- a/src/lib/formats/sorc_dsk.c +++ b/src/lib/formats/sorc_dsk.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "sorc_dsk.h" #include "basicdsk.h" diff --git a/src/lib/formats/svi_dsk.c b/src/lib/formats/svi_dsk.c index e94b2e2f94d..23dbb9a17e2 100644 --- a/src/lib/formats/svi_dsk.c +++ b/src/lib/formats/svi_dsk.c @@ -7,6 +7,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "svi_dsk.h" #include "basicdsk.h" diff --git a/src/lib/formats/thom_dsk.c b/src/lib/formats/thom_dsk.c index b3cf47234a2..4f7230f2421 100644 --- a/src/lib/formats/thom_dsk.c +++ b/src/lib/formats/thom_dsk.c @@ -9,6 +9,7 @@ *********************************************************************/ #include <string.h> +#include <assert.h> #include "thom_dsk.h" #include "basicdsk.h" diff --git a/src/lib/formats/trs_dsk.c b/src/lib/formats/trs_dsk.c index 36c5a271622..ebe6090bcdc 100644 --- a/src/lib/formats/trs_dsk.c +++ b/src/lib/formats/trs_dsk.c @@ -1,4 +1,5 @@ #include <string.h> +#include <assert.h> #include "trs_dsk.h" #include "basicdsk.h" #include "coco_dsk.h" diff --git a/src/lib/formats/vt_dsk.c b/src/lib/formats/vt_dsk.c index c4d1fdf91d8..0021b66eaa4 100644 --- a/src/lib/formats/vt_dsk.c +++ b/src/lib/formats/vt_dsk.c @@ -8,6 +8,7 @@ #include <stdio.h> #include <string.h> +#include <assert.h> #include "formats/vt_dsk.h" #include "formats/basicdsk.h" diff --git a/src/lib/formats/vtech1_dsk.c b/src/lib/formats/vtech1_dsk.c index 4ee02c89104..d7194224ebd 100644 --- a/src/lib/formats/vtech1_dsk.c +++ b/src/lib/formats/vtech1_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "formats/vtech1_dsk.h" static FLOPPY_IDENTIFY( vtech1_dsk_identify ) diff --git a/src/lib/formats/z80ne_dsk.c b/src/lib/formats/z80ne_dsk.c index be521761f64..967fecd27f5 100644 --- a/src/lib/formats/z80ne_dsk.c +++ b/src/lib/formats/z80ne_dsk.c @@ -6,6 +6,8 @@ *********************************************************************/ +#include <assert.h> + #include "z80ne_dsk.h" #include "basicdsk.h" #include "imageutl.h" diff --git a/src/lib/util/avhuff.c b/src/lib/util/avhuff.c index d2642b99b35..6684c6d7ae9 100644 --- a/src/lib/util/avhuff.c +++ b/src/lib/util/avhuff.c @@ -58,6 +58,8 @@ ***************************************************************************/ +#include <assert.h> + #include "avhuff.h" #include "huffman.h" #include "chd.h" diff --git a/src/lib/util/aviio.c b/src/lib/util/aviio.c index 7dd2e3bb9c1..0d0403809f8 100644 --- a/src/lib/util/aviio.c +++ b/src/lib/util/aviio.c @@ -9,6 +9,7 @@ ***************************************************************************/ #include <stdlib.h> +#include <assert.h> #include "aviio.h" diff --git a/src/lib/util/bitmap.c b/src/lib/util/bitmap.c index 4d1f8502f50..a6e7b02f957 100644 --- a/src/lib/util/bitmap.c +++ b/src/lib/util/bitmap.c @@ -8,6 +8,8 @@ ***************************************************************************/ +#include <assert.h> + #include "bitmap.h" #include <new> diff --git a/src/lib/util/bitmap.h b/src/lib/util/bitmap.h index a82ec7eebfe..91d693124e1 100644 --- a/src/lib/util/bitmap.h +++ b/src/lib/util/bitmap.h @@ -15,7 +15,6 @@ #include "osdcore.h" #include "palette.h" -#include <assert.h> //************************************************************************** diff --git a/src/lib/util/cdrom.c b/src/lib/util/cdrom.c index 15c10a44452..90024420555 100644 --- a/src/lib/util/cdrom.c +++ b/src/lib/util/cdrom.c @@ -16,6 +16,8 @@ ***************************************************************************/ +#include <assert.h> + #include "cdrom.h" #include <stdlib.h> diff --git a/src/lib/util/chd.c b/src/lib/util/chd.c index 43539103d33..c00daf7b7cf 100644 --- a/src/lib/util/chd.c +++ b/src/lib/util/chd.c @@ -8,6 +8,8 @@ ***************************************************************************/ +#include <assert.h> + #include "chd.h" #include "avhuff.h" #include "hashing.h" diff --git a/src/lib/util/chdcd.c b/src/lib/util/chdcd.c index 8690cc65ffa..0e6077dd70f 100644 --- a/src/lib/util/chdcd.c +++ b/src/lib/util/chdcd.c @@ -10,6 +10,7 @@ #include <ctype.h> #include <stdlib.h> +#include <assert.h> #include "osdcore.h" #include "chd.h" #include "chdcd.h" diff --git a/src/lib/util/chdcodec.c b/src/lib/util/chdcodec.c index e1a001e2ebd..3bf1d6dfd63 100644 --- a/src/lib/util/chdcodec.c +++ b/src/lib/util/chdcodec.c @@ -8,6 +8,8 @@ ***************************************************************************/ +#include <assert.h> + #include "chd.h" #include "hashing.h" #include "avhuff.h" diff --git a/src/lib/util/coretmpl.h b/src/lib/util/coretmpl.h index e1dd388511b..93c71f0c84b 100644 --- a/src/lib/util/coretmpl.h +++ b/src/lib/util/coretmpl.h @@ -13,7 +13,6 @@ #ifndef __CORETMPL_H__ #define __CORETMPL_H__ -#include <assert.h> #include "osdcore.h" #include "corealloc.h" diff --git a/src/lib/util/cstrpool.c b/src/lib/util/cstrpool.c index 874e5192ea0..ea5c637e4d4 100644 --- a/src/lib/util/cstrpool.c +++ b/src/lib/util/cstrpool.c @@ -6,6 +6,8 @@ ***************************************************************************/ +#include <assert.h> + #include "cstrpool.h" diff --git a/src/lib/util/flac.c b/src/lib/util/flac.c index bfaa519cf53..d2f576e637e 100644 --- a/src/lib/util/flac.c +++ b/src/lib/util/flac.c @@ -8,6 +8,8 @@ ***************************************************************************/ +#include <assert.h> + #include "flac.h" #include <new> diff --git a/src/lib/util/harddisk.c b/src/lib/util/harddisk.c index 87967d41f1b..46d8f5bab9a 100644 --- a/src/lib/util/harddisk.c +++ b/src/lib/util/harddisk.c @@ -8,6 +8,8 @@ ***************************************************************************/ +#include <assert.h> + #include "harddisk.h" #include <stdlib.h> diff --git a/src/lib/util/huffman.c b/src/lib/util/huffman.c index eee176e13ba..2da37df8194 100644 --- a/src/lib/util/huffman.c +++ b/src/lib/util/huffman.c @@ -97,6 +97,7 @@ ***************************************************************************/ #include <stdlib.h> +#include <assert.h> #include "coretmpl.h" #include "huffman.h" diff --git a/src/lib/util/opresolv.c b/src/lib/util/opresolv.c index d275e47d03b..b7870842b08 100644 --- a/src/lib/util/opresolv.c +++ b/src/lib/util/opresolv.c @@ -9,13 +9,12 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <assert.h> #include "pool.h" #include "corestr.h" #include "opresolv.h" -#include <assert.h> - enum resolution_entry_state { RESOLUTION_ENTRY_STATE_UNSPECIFIED, diff --git a/src/lib/util/palette.c b/src/lib/util/palette.c index 6b3847f61da..4be66ee9f7b 100644 --- a/src/lib/util/palette.c +++ b/src/lib/util/palette.c @@ -8,6 +8,8 @@ ******************************************************************************/ +#include <assert.h> + #include "palette.h" #include <stdlib.h> #include <math.h> diff --git a/src/lib/util/png.c b/src/lib/util/png.c index b88af8df44b..076b1b02965 100644 --- a/src/lib/util/png.c +++ b/src/lib/util/png.c @@ -10,6 +10,7 @@ #include <math.h> #include <stdlib.h> +#include <assert.h> #include <zlib.h> #include "png.h" diff --git a/src/mess/tools/floptool/main.c b/src/mess/tools/floptool/main.c index 3d823d99a58..2cb36f3a873 100644 --- a/src/mess/tools/floptool/main.c +++ b/src/mess/tools/floptool/main.c @@ -16,6 +16,7 @@ #include <stdlib.h> #include <time.h> #include <stdarg.h> +#include <assert.h> #include "corestr.h" diff --git a/src/mess/tools/imgtool/iflopimg.c b/src/mess/tools/imgtool/iflopimg.c index 26a91ccf749..765245cb8ff 100644 --- a/src/mess/tools/imgtool/iflopimg.c +++ b/src/mess/tools/imgtool/iflopimg.c @@ -6,8 +6,8 @@ *********************************************************************/ -#include "formats/flopimg.h" #include "imgtool.h" +#include "formats/flopimg.h" #include "library.h" #include "iflopimg.h" diff --git a/src/mess/tools/imgtool/imgterrs.c b/src/mess/tools/imgtool/imgterrs.c index dac8b9d0572..696aafdfa1a 100644 --- a/src/mess/tools/imgtool/imgterrs.c +++ b/src/mess/tools/imgtool/imgterrs.c @@ -6,9 +6,9 @@ ***************************************************************************/ +#include "imgtool.h" #include "imgterrs.h" #include "osdcomm.h" -#include <assert.h> static const char *const msgs[] = { diff --git a/src/mess/tools/imgtool/imgtool.h b/src/mess/tools/imgtool/imgtool.h index 43d1ffe1017..459712fbed5 100644 --- a/src/mess/tools/imgtool/imgtool.h +++ b/src/mess/tools/imgtool/imgtool.h @@ -11,6 +11,7 @@ #include <stdlib.h> #include <stdio.h> +#include <assert.h> #include "corestr.h" #include "formats/flopimg.h" diff --git a/src/mess/tools/imgtool/library.c b/src/mess/tools/imgtool/library.c index fd15243edfe..b17d837aa02 100644 --- a/src/mess/tools/imgtool/library.c +++ b/src/mess/tools/imgtool/library.c @@ -9,6 +9,7 @@ #include <string.h> +#include "imgtool.h" #include "library.h" #include "pool.h" diff --git a/src/tools/chdman.c b/src/tools/chdman.c index 9384566eb54..87e22bd2dbf 100644 --- a/src/tools/chdman.c +++ b/src/tools/chdman.c @@ -6,6 +6,8 @@ ****************************************************************************/ +#include <assert.h> + #include "osdcore.h" #include "corefile.h" #include "chdcd.h" diff --git a/src/tools/ldresample.c b/src/tools/ldresample.c index e027f88ec9a..7851814e0aa 100644 --- a/src/tools/ldresample.c +++ b/src/tools/ldresample.c @@ -13,6 +13,7 @@ #include <stdlib.h> #include <math.h> #include <new> +#include <assert.h> #include "bitmap.h" #include "chd.h" #include "avhuff.h" diff --git a/src/tools/ldverify.c b/src/tools/ldverify.c index b57f987e145..2d8ff1365d2 100644 --- a/src/tools/ldverify.c +++ b/src/tools/ldverify.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <ctype.h> #include <new> +#include <assert.h> #include "coretmpl.h" #include "aviio.h" #include "avhuff.h" diff --git a/src/tools/pngcmp.c b/src/tools/pngcmp.c index f5f1da4a2c5..31753a49be1 100644 --- a/src/tools/pngcmp.c +++ b/src/tools/pngcmp.c @@ -12,6 +12,7 @@ #include <stdlib.h> #include <string.h> #include <ctype.h> +#include <assert.h> #include "osdcore.h" #include "png.h" diff --git a/src/tools/regrep.c b/src/tools/regrep.c index 114d5fa467b..c720ee1354e 100644 --- a/src/tools/regrep.c +++ b/src/tools/regrep.c @@ -11,6 +11,7 @@ #include <string.h> #include <ctype.h> #include <new> +#include <assert.h> #include "osdcore.h" #include "png.h" |