From 34d14506fd0c12ee5434fec0f9dec27753e1aab5 Mon Sep 17 00:00:00 2001 From: borutr Date: Wed, 6 Jun 2007 22:32:26 +0000 Subject: [PATCH] * sim/ucsim/*.*, sim/ucsim/configure, sim/ucsim/configure.in: permanent solution to suppress GCC 4.2.0 c++ warning: deprecated conversion from string constant to `char *' use 'const char *' where ever required git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4837 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 9 +++++- sim/ucsim/app.cc | 6 ++-- sim/ucsim/appcl.h | 4 +-- sim/ucsim/avr.src/avr.cc | 11 ++++--- sim/ucsim/avr.src/avrcl.h | 2 +- sim/ucsim/cmd.src/bpcl.h | 6 ++-- sim/ucsim/cmd.src/cmdconf.cc | 2 +- sim/ucsim/cmd.src/cmdpars.cc | 12 +++---- sim/ucsim/cmd.src/cmdpars.y | 4 +-- sim/ucsim/cmd.src/command.cc | 28 +++++++---------- sim/ucsim/cmd.src/commandcl.h | 50 ++++++++++++++--------------- sim/ucsim/cmd.src/newcmd.cc | 16 +++++----- sim/ucsim/cmd.src/newcmdcl.h | 18 +++++------ sim/ucsim/cmd.src/newcmdposix.cc | 4 +-- sim/ucsim/cmd.src/newcmdposixcl.h | 4 +-- sim/ucsim/cmd.src/newcmdwin32.cc | 4 +-- sim/ucsim/cmd.src/newcmdwin32cl.h | 4 +-- sim/ucsim/cmd.src/show.cc | 2 +- sim/ucsim/configure | 4 --- sim/ucsim/configure.in | 4 --- sim/ucsim/error.cc | 8 ++--- sim/ucsim/errorcl.h | 16 +++++----- sim/ucsim/globals.cc | 4 +-- sim/ucsim/hc08.src/hc08.cc | 23 +++++++------- sim/ucsim/hc08.src/hc08cl.h | 6 ++-- sim/ucsim/option.cc | 50 +++++++++++++---------------- sim/ucsim/optioncl.h | 52 +++++++++++++++---------------- sim/ucsim/pobj.cc | 40 ++++++++++++------------ sim/ucsim/pobjcl.h | 34 ++++++++++---------- sim/ucsim/pobjt.h | 2 +- sim/ucsim/s51.src/serial.cc | 2 +- sim/ucsim/s51.src/sim51.cc | 2 +- sim/ucsim/s51.src/timer0.cc | 4 +-- sim/ucsim/s51.src/timer0cl.h | 2 +- sim/ucsim/s51.src/timer1.cc | 4 +-- sim/ucsim/s51.src/timer1cl.h | 2 +- sim/ucsim/s51.src/timer2.cc | 2 +- sim/ucsim/s51.src/timer2cl.h | 2 +- sim/ucsim/s51.src/uc390.cc | 17 +++++----- sim/ucsim/s51.src/uc390cl.h | 8 ++--- sim/ucsim/s51.src/uc51.cc | 14 ++++----- sim/ucsim/s51.src/uc51cl.h | 2 +- sim/ucsim/sim.src/arg.cc | 6 ++-- sim/ucsim/sim.src/argcl.h | 8 ++--- sim/ucsim/sim.src/brk.cc | 4 +-- sim/ucsim/sim.src/brkcl.h | 4 +-- sim/ucsim/sim.src/hw.cc | 2 +- sim/ucsim/sim.src/hwcl.h | 2 +- sim/ucsim/sim.src/itsrc.cc | 12 +++---- sim/ucsim/sim.src/itsrccl.h | 6 ++-- sim/ucsim/sim.src/mem.cc | 12 +++---- sim/ucsim/sim.src/memcl.h | 10 +++--- sim/ucsim/sim.src/stack.cc | 26 ++++++++-------- sim/ucsim/sim.src/stackcl.h | 28 ++++++++--------- sim/ucsim/sim.src/uc.cc | 18 +++++------ sim/ucsim/sim.src/uccl.h | 18 +++++------ sim/ucsim/stypes.h | 12 +++---- sim/ucsim/utils.cc | 22 ++++++------- sim/ucsim/utils.h | 14 ++++----- sim/ucsim/z80.src/z80.cc | 23 +++++++------- sim/ucsim/z80.src/z80cl.h | 6 ++-- 61 files changed, 355 insertions(+), 368 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ea76700..6203bf41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-07 Borut Razem + + * sim/ucsim/*.*, sim/ucsim/configure, sim/ucsim/configure.in: + permanent solution to suppress GCC 4.2.0 c++ warning: + deprecated conversion from string constant to `char *' + use 'const char *' where ever required + 2007-06-04 Maarten Brock * src/SDCCast.c(decorateType): better optimize '!!' and comparisons @@ -56,7 +63,7 @@ * device/lib/pic16/libdev/pic18f[24]5j10.c: search for included source file in local directory * sim/ucsim/configure, sim/ucsim/configure.in: - temporary solution to supress GCC 4.2.0 c++ warning: + temporary solution to suppress GCC 4.2.0 c++ warning: deprecated conversion from string constant to `char *' 2007-06-01 Raphael Neider diff --git a/sim/ucsim/app.cc b/sim/ucsim/app.cc index 44daef00..24145473 100644 --- a/sim/ucsim/app.cc +++ b/sim/ucsim/app.cc @@ -192,7 +192,7 @@ cl_app::done(void) */ static void -print_help(char *name) +print_help(const char *name) { printf("%s: %s\n", name, VERSIONSTR); printf("Usage: %s [-hHVvP] [-p prompt] [-t CPU] [-X freq[k|M]]\n" @@ -793,7 +793,7 @@ cl_app::mk_options(void) int -cl_app::dd_printf(char *format, ...) +cl_app::dd_printf(const char *format, ...) { va_list ap; @@ -807,7 +807,7 @@ cl_app::dd_printf(char *format, ...) } int -cl_app::debug(char *format, ...) +cl_app::debug(const char *format, ...) { va_list ap; diff --git a/sim/ucsim/appcl.h b/sim/ucsim/appcl.h index 70da7d9b..a9a3ced1 100644 --- a/sim/ucsim/appcl.h +++ b/sim/ucsim/appcl.h @@ -116,8 +116,8 @@ protected: virtual void mk_options(void); public: // output functions - virtual int dd_printf(char *format, ...); - virtual int debug(char *format, ...); + virtual int dd_printf(const char *format, ...); + virtual int debug(const char *format, ...); }; diff --git a/sim/ucsim/avr.src/avr.cc b/sim/ucsim/avr.src/avr.cc index 5991f6c3..dbf3b72e 100644 --- a/sim/ucsim/avr.src/avr.cc +++ b/sim/ucsim/avr.src/avr.cc @@ -66,7 +66,7 @@ cl_avr::init(void) return(0); } -char * +const char * cl_avr::id_string(void) { return("unspecified AVR"); @@ -172,7 +172,8 @@ char * cl_avr::disass(t_addr addr, char *sep) { char work[256], temp[20]; - char *buf, *p, *b, *t; + const char *b; + char *buf, *p, *t; uint code, data= 0; int i; @@ -291,10 +292,10 @@ cl_avr::disass(t_addr addr, char *sep) buf= (char *)malloc(6+strlen(p)+1); else buf= (char *)malloc((p-work)+strlen(sep)+strlen(p)+1); - for (p= work, b= buf; *p != ' '; p++, b++) - *b= *p; + for (p= work, t= buf; *p != ' '; p++, t++) + *t= *p; p++; - *b= '\0'; + *t= '\0'; if (sep == NULL) { while (strlen(buf) < 6) diff --git a/sim/ucsim/avr.src/avrcl.h b/sim/ucsim/avr.src/avrcl.h index 34f3c5ea..0e82e492 100644 --- a/sim/ucsim/avr.src/avrcl.h +++ b/sim/ucsim/avr.src/avrcl.h @@ -46,7 +46,7 @@ public: public: cl_avr(class cl_sim *asim); virtual int init(void); - virtual char *id_string(void); + virtual const char *id_string(void); //virtual t_addr get_mem_size(enum mem_class type); //virtual int get_mem_width(enum mem_class type); diff --git a/sim/ucsim/cmd.src/bpcl.h b/sim/ucsim/cmd.src/bpcl.h index 407b6add..117cf35d 100644 --- a/sim/ucsim/cmd.src/bpcl.h +++ b/sim/ucsim/cmd.src/bpcl.h @@ -48,10 +48,10 @@ COMMAND_TAIL; class cl_tbreak_cmd: public cl_break_cmd { public: - cl_tbreak_cmd(char *aname, + cl_tbreak_cmd(const char *aname, int can_rep, - char *short_hlp, - char *long_hlp): + const char *short_hlp, + const char *long_hlp): cl_break_cmd(aname, can_rep, short_hlp, long_hlp) {perm=brkDYNAMIC;} }; diff --git a/sim/ucsim/cmd.src/cmdconf.cc b/sim/ucsim/cmd.src/cmdconf.cc index b0797b6f..7a93118e 100644 --- a/sim/ucsim/cmd.src/cmdconf.cc +++ b/sim/ucsim/cmd.src/cmdconf.cc @@ -74,7 +74,7 @@ conf_objects_cmd_print_node(class cl_console_base *con, int i; for (i= 0; i < indent; i++) con->dd_printf(" "); - char *name= node->get_name("unknown"); + const char *name= node->get_name("unknown"); con->dd_printf("%s\n", name); class cl_base *c= node->first_child(); while (c) diff --git a/sim/ucsim/cmd.src/cmdpars.cc b/sim/ucsim/cmd.src/cmdpars.cc index 8087e4a5..ffd62ce9 100644 --- a/sim/ucsim/cmd.src/cmdpars.cc +++ b/sim/ucsim/cmd.src/cmdpars.cc @@ -726,7 +726,7 @@ do \ YYGOTO(yybackup); \ } \ else \ - { YY_cl_ucsim_parser_ERROR ("syntax error: cannot back up"); YYERROR; } \ + { YY_cl_ucsim_parser_ERROR ((char *)"syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 @@ -936,7 +936,7 @@ YYLABEL(yynewstate) /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { - YY_cl_ucsim_parser_ERROR("parser stack overflow"); + YY_cl_ucsim_parser_ERROR((char *)"parser stack overflow"); __ALLOCA_return(2); } yystacksize *= 2; @@ -1161,7 +1161,7 @@ case 8: #line 92 "cmdpars.y" { if (yyvsp[0].number == 0) - yyerror("Divide by zero"); + yyerror((char *)"Divide by zero"); else yyval.number= yyvsp[-2].number / yyvsp[0].number; ; @@ -1200,7 +1200,7 @@ case 16: yyval.number= yyvsp[0].bit.bit_address; if (yyval.number < 0) { - yyerror("Bit has no address."); + yyerror((char *)"Bit has no address."); yyval.number= 0; } ; @@ -1323,11 +1323,11 @@ YYLABEL(yyerrlab) /* here on detecting error */ free(msg); } else - YY_cl_ucsim_parser_ERROR ("parse error; also virtual memory exceeded"); + YY_cl_ucsim_parser_ERROR ((char *)"parse error; also virtual memory exceeded"); } else #endif /* YY_cl_ucsim_parser_ERROR_VERBOSE */ - YY_cl_ucsim_parser_ERROR("parse error"); + YY_cl_ucsim_parser_ERROR((char *)"parse error"); } YYGOTO(yyerrlab1); diff --git a/sim/ucsim/cmd.src/cmdpars.y b/sim/ucsim/cmd.src/cmdpars.y index 2b106ac5..70f69b3a 100644 --- a/sim/ucsim/cmd.src/cmdpars.y +++ b/sim/ucsim/cmd.src/cmdpars.y @@ -91,7 +91,7 @@ expression: | expression PTOK_SLASH expression { if ($3 == 0) - yyerror("Divide by zero"); + yyerror((char *)"Divide by zero"); else $$= $1 / $3; } @@ -110,7 +110,7 @@ address_of_expression: $$= $2.bit_address; if ($$ < 0) { - yyerror("Bit has no address."); + yyerror((char *)"Bit has no address."); $$= 0; } } diff --git a/sim/ucsim/cmd.src/command.cc b/sim/ucsim/cmd.src/command.cc index cdd40a58..f52e370d 100644 --- a/sim/ucsim/cmd.src/command.cc +++ b/sim/ucsim/cmd.src/command.cc @@ -347,7 +347,7 @@ cl_cmdline::shift(void) int cl_cmdline::repeat(void) { - char *n; + const char *n; return((n= get_name()) && *n == '\n'); } @@ -370,7 +370,7 @@ cl_cmdline::insert_param(int pos, class cl_cmd_arg *param) } bool -cl_cmdline::syntax_match(class cl_uc *uc, char *syntax) +cl_cmdline::syntax_match(class cl_uc *uc, const char *syntax) { if (!syntax) return(DD_FALSE); @@ -383,7 +383,7 @@ cl_cmdline::syntax_match(class cl_uc *uc, char *syntax) if (!params->count) return(DD_FALSE); //printf("syntax %s?\n",syntax); - char *p= syntax; + const char *p= syntax; int iparam= 0; class cl_cmd_arg *parm= (class cl_cmd_arg *)(params->at(iparam)); while (*p && @@ -511,10 +511,10 @@ cl_cmdline::set_data_list(class cl_cmd_arg *parm, int *iparm) */ cl_cmd::cl_cmd(enum cmd_operate_on op_on, - char *aname, + const char *aname, int can_rep, - char *short_hlp, - char *long_hlp): + const char *short_hlp, + const char *long_hlp): cl_base() { operate_on= op_on; @@ -536,21 +536,17 @@ cl_cmd::cl_cmd(enum cmd_operate_on op_on, cl_cmd::~cl_cmd(void) { delete names; - if (short_help) - free(short_help); - if (long_help) - free(long_help); } void -cl_cmd::add_name(char *nam) +cl_cmd::add_name(const char *nam) { if (nam) names->add(strdup(nam)); } int -cl_cmd::name_match(char *aname, int strict) +cl_cmd::name_match(const char *aname, int strict) { int i; @@ -715,7 +711,7 @@ cl_cmdset::get_cmd(class cl_cmdline *cmdline, bool accept_last) } class cl_cmd * -cl_cmdset::get_cmd(char *cmd_name) +cl_cmdset::get_cmd(const char *cmd_name) { int i; @@ -767,10 +763,10 @@ cl_cmdset::replace(char *nam, class cl_cmd *cmd) *____________________________________________________________________________ */ -cl_super_cmd::cl_super_cmd(char *aname, +cl_super_cmd::cl_super_cmd(const char *aname, int can_rep, - char *short_hlp, - char *long_hlp, + const char *short_hlp, + const char *long_hlp, class cl_cmdset *acommands): cl_cmd(operate_on_none, aname, can_rep, short_hlp, long_hlp) { diff --git a/sim/ucsim/cmd.src/commandcl.h b/sim/ucsim/cmd.src/commandcl.h index 7a3a332a..6de3a687 100644 --- a/sim/ucsim/cmd.src/commandcl.h +++ b/sim/ucsim/cmd.src/commandcl.h @@ -57,7 +57,7 @@ public: //char *name; class cl_list *params; class cl_ustrings *tokens; - char *matched_syntax; + const char *matched_syntax; class cl_console_base *con; public: @@ -76,7 +76,7 @@ public: virtual int repeat(void); virtual class cl_cmd_arg *param(int num); virtual void insert_param(int pos, class cl_cmd_arg *param); - virtual bool syntax_match(class cl_uc *uc, char *syntax); + virtual bool syntax_match(class cl_uc *uc, const char *syntax); virtual bool set_data_list(class cl_cmd_arg *parm, int *iparm); virtual int nuof_params(void) { return(params->get_count()); } private: @@ -97,20 +97,20 @@ public: enum cmd_operate_on operate_on; class cl_strings *names; int can_repeat; - char *short_help; - char *long_help; + const char *short_help; + const char *long_help; public: cl_cmd(enum cmd_operate_on opon, - char *aname, + const char *aname, int can_rep, - char *short_hlp, - char *long_hlp); + const char *short_hlp, + const char *long_hlp); virtual ~cl_cmd(void); virtual class cl_cmdset *get_subcommands(void) { return(0); } - virtual void add_name(char *nam); - virtual int name_match(char *aname, int strict); + virtual void add_name(const char *nam); + virtual int name_match(const char *aname, int strict); virtual int name_match(class cl_cmdline *cmdline, int strict); virtual int syntax_ok(class cl_cmdline *cmdline); virtual int work(class cl_app *app, @@ -133,38 +133,38 @@ class CLASS_NAME : public ANCESTOR \ #define COMMAND_METHODS(CLASS_NAME) \ public:\ - CLASS_NAME (char *aname,\ + CLASS_NAME (const char *aname,\ int can_rep,\ - char *short_help,\ - char *long_help):\ + const char *short_help,\ + const char *long_help):\ cl_cmd(operate_on_none, aname, can_rep, short_help, long_help) {}\ virtual int do_work(class cl_cmdline *cmdline, class cl_console_base *con); #define COMMAND_METHODS_ON(ON,CLASS_NAME) \ public:\ - CLASS_NAME (char *aname,\ + CLASS_NAME (const char *aname,\ int can_rep,\ - char *short_help,\ - char *long_help):\ + const char *short_help,\ + const char *long_help):\ cl_cmd(operate_on_ ## ON, aname, can_rep, short_help, long_help) {}\ virtual int do_work(class cl_ ## ON * ON ,\ class cl_cmdline *cmdline, class cl_console_base *con); #define COMMAND_METHODS_ANCESTOR(CLASS_NAME,ANCESTOR) \ public:\ - CLASS_NAME (char *aname,\ + CLASS_NAME (const char *aname,\ int can_rep,\ - char *short_help,\ - char *long_help):\ + const char *short_help,\ + const char *long_help):\ ANCESTOR (aname, can_rep, short_help, long_help) {}\ virtual int do_work(class cl_cmdline *cmdline, class cl_console_base *con); #define COMMAND_METHODS_ANCESTOR_ON(ON,CLASS_NAME,ANCESTOR) \ public:\ - CLASS_NAME (char *aname,\ + CLASS_NAME (const char *aname,\ int can_rep,\ - char *short_help,\ - char *long_help):\ + const char *short_help,\ + const char *long_help):\ ANCESTOR (aname, can_rep, short_help, long_help) {}\ virtual int do_work(class cl_ ## ON * ON ,\ class cl_cmdline *cmdline, class cl_console_base *con); \ @@ -239,7 +239,7 @@ public: //cl_cmdset(class cl_sim *asim); virtual class cl_cmd *get_cmd(class cl_cmdline *cmdline, bool accept_last); - virtual class cl_cmd *get_cmd(char *cmd_name); + virtual class cl_cmd *get_cmd(const char *cmd_name); virtual void del(char *nam); virtual void replace(char *nam, class cl_cmd *cmd); }; @@ -251,10 +251,10 @@ public: class cl_cmdset *commands; public: - cl_super_cmd(char *aname, + cl_super_cmd(const char *aname, int can_rep, - char *short_hlp, - char *long_hlp, + const char *short_hlp, + const char *long_hlp, class cl_cmdset *acommands); virtual ~cl_super_cmd(void); diff --git a/sim/ucsim/cmd.src/newcmd.cc b/sim/ucsim/cmd.src/newcmd.cc index f5e5c9a0..3355443b 100644 --- a/sim/ucsim/cmd.src/newcmd.cc +++ b/sim/ucsim/cmd.src/newcmd.cc @@ -172,7 +172,7 @@ cl_console_base::print_prompt(void) } int -cl_console_base::dd_printf(char *format, ...) +cl_console_base::dd_printf(const char *format, ...) { va_list ap; int ret= 0; @@ -185,7 +185,7 @@ cl_console_base::dd_printf(char *format, ...) } int -cl_console_base::debug(char *format, ...) +cl_console_base::debug(const char *format, ...) { if ((flags & CONS_DEBUG) == 0) return(0); @@ -421,7 +421,7 @@ cl_commander_base::deactivate_console(class cl_console_base *console) */ int -cl_commander_base::all_printf(char *format, ...) +cl_commander_base::all_printf(const char *format, ...) { va_list ap; int i, ret= 0; @@ -454,7 +454,7 @@ cl_commander_base::prompt(void) */ int -cl_commander_base::dd_printf(char *format, va_list ap) +cl_commander_base::dd_printf(const char *format, va_list ap) { int ret= 0; class cl_console_base *con; @@ -479,7 +479,7 @@ cl_commander_base::dd_printf(char *format, va_list ap) } int -cl_commander_base::dd_printf(char *format, ...) +cl_commander_base::dd_printf(const char *format, ...) { va_list ap; int ret= 0; @@ -496,7 +496,7 @@ cl_commander_base::dd_printf(char *format, ...) */ int -cl_commander_base::debug(char *format, ...) +cl_commander_base::debug(const char *format, ...) { va_list ap; int i, ret= 0; @@ -515,7 +515,7 @@ cl_commander_base::debug(char *format, ...) } int -cl_commander_base::debug(char *format, va_list ap) +cl_commander_base::debug(const char *format, va_list ap) { int i, ret= 0; @@ -531,7 +531,7 @@ cl_commander_base::debug(char *format, va_list ap) } int -cl_commander_base::flag_printf(int iflags, char *format, ...) +cl_commander_base::flag_printf(int iflags, const char *format, ...) { va_list ap; int i, ret= 0; diff --git a/sim/ucsim/cmd.src/newcmdcl.h b/sim/ucsim/cmd.src/newcmdcl.h index 49ae8cf4..6bff5b10 100644 --- a/sim/ucsim/cmd.src/newcmdcl.h +++ b/sim/ucsim/cmd.src/newcmdcl.h @@ -113,7 +113,7 @@ public: virtual void redirect(char *fname, char *mode) = 0; virtual void un_redirect(void) = 0; - virtual int cmd_do_print(char *format, va_list ap) = 0; + virtual int cmd_do_print(const char *format, va_list ap) = 0; virtual bool is_tty(void) const = 0; virtual bool is_eof(void) const = 0; virtual int input_avail(void) = 0; @@ -124,8 +124,8 @@ public: virtual int proc_input(class cl_cmdset *cmdset); void print_prompt(void); - int dd_printf(char *format, ...); - int debug(char *format, ...); + int dd_printf(const char *format, ...); + int debug(const char *format, ...); void print_bin(long data, int bits); void print_char_octal(char c); @@ -168,12 +168,12 @@ public: void deactivate_console(class cl_console_base *console); void prompt(void); - int all_printf(char *format, ...); // print to all consoles - int dd_printf(char *format, va_list ap); // print to actual_console - int dd_printf(char *format, ...); // print to actual_console - int debug(char *format, ...); // print consoles with debug flag set - int debug(char *format, va_list ap); // print consoles with debug flag set - int flag_printf(int iflags, char *format, ...); + int all_printf(const char *format, ...); // print to all consoles + int dd_printf(const char *format, va_list ap); // print to actual_console + int dd_printf(const char *format, ...); // print to actual_console + int debug(const char *format, ...); // print consoles with debug flag set + int debug(const char *format, va_list ap); // print consoles with debug flag set + int flag_printf(int iflags, const char *format, ...); int input_avail_on_frozen(void); void exec_on(class cl_console_base *cons, char *file_name); diff --git a/sim/ucsim/cmd.src/newcmdposix.cc b/sim/ucsim/cmd.src/newcmdposix.cc index 51c975e9..f74d6e3c 100644 --- a/sim/ucsim/cmd.src/newcmdposix.cc +++ b/sim/ucsim/cmd.src/newcmdposix.cc @@ -72,7 +72,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA *____________________________________________________________________________ */ -cl_console::cl_console(char *fin, char *fout, class cl_app *the_app) +cl_console::cl_console(const char *fin, const char *fout, class cl_app *the_app) { FILE *f; @@ -181,7 +181,7 @@ cl_console::un_redirect(void) } int -cl_console::cmd_do_print(char *format, va_list ap) +cl_console::cmd_do_print(const char *format, va_list ap) { int ret; FILE *f = get_out(); diff --git a/sim/ucsim/cmd.src/newcmdposixcl.h b/sim/ucsim/cmd.src/newcmdposixcl.h index 08501674..5050d2f4 100644 --- a/sim/ucsim/cmd.src/newcmdposixcl.h +++ b/sim/ucsim/cmd.src/newcmdposixcl.h @@ -44,9 +44,9 @@ protected: public: cl_console(void) { in = out = rout = 0; } - cl_console(char *fin, char *fout, class cl_app *the_app); + cl_console(const char *fin, const char *fout, class cl_app *the_app); cl_console(FILE *fin, FILE *fout, class cl_app *the_app); - int cmd_do_print(char *format, va_list ap); + int cmd_do_print(const char *format, va_list ap); virtual ~cl_console(void); virtual class cl_console *clone_for_exec(char *fin); diff --git a/sim/ucsim/cmd.src/newcmdwin32.cc b/sim/ucsim/cmd.src/newcmdwin32.cc index 460b04d0..a4973aa7 100644 --- a/sim/ucsim/cmd.src/newcmdwin32.cc +++ b/sim/ucsim/cmd.src/newcmdwin32.cc @@ -114,7 +114,7 @@ cl_channel::close(void) *____________________________________________________________________________ */ -cl_console::cl_console(char *fin, char *fout, class cl_app *the_app) +cl_console::cl_console(const char *fin, const char *fout, class cl_app *the_app) { FILE *f; @@ -231,7 +231,7 @@ cl_console::un_redirect(void) } int -cl_console::cmd_do_print(char *format, va_list ap) +cl_console::cmd_do_print(const char *format, va_list ap) { FILE *f = get_out()->get_fp(); diff --git a/sim/ucsim/cmd.src/newcmdwin32cl.h b/sim/ucsim/cmd.src/newcmdwin32cl.h index 522a89c8..bdb85609 100644 --- a/sim/ucsim/cmd.src/newcmdwin32cl.h +++ b/sim/ucsim/cmd.src/newcmdwin32cl.h @@ -74,11 +74,11 @@ protected: public: cl_console(void) { in = cl_channel(); out = cl_channel(); rout = cl_channel(); } - cl_console(char *fin, char *fout, class cl_app *the_app); + cl_console(const char *fin, const char *fout, class cl_app *the_app); cl_console(FILE *fin, FILE *fout, class cl_app *the_app); cl_console(cl_channel _in, cl_channel _out, class cl_app *the_app); - int cmd_do_print(char *format, va_list ap); + int cmd_do_print(const char *format, va_list ap); virtual ~cl_console(void); virtual class cl_console *clone_for_exec(char *fin); diff --git a/sim/ucsim/cmd.src/show.cc b/sim/ucsim/cmd.src/show.cc index 9ef2c66e..28763745 100644 --- a/sim/ucsim/cmd.src/show.cc +++ b/sim/ucsim/cmd.src/show.cc @@ -140,7 +140,7 @@ show_error_cmd_print_node(class cl_console_base *con, int i; for (i= 0; i < indent; i++) con->dd_printf(" "); - char *name= node->get_name("unknown"); + const char *name= node->get_name("unknown"); class cl_error_class *ec= dynamic_cast(node); char *str; con->dd_printf("%s: %s [%s/%s]\n", diff --git a/sim/ucsim/configure b/sim/ucsim/configure index 6ee865f4..fbda1e0c 100755 --- a/sim/ucsim/configure +++ b/sim/ucsim/configure @@ -12503,10 +12503,6 @@ if test "$ucsim_cv_CXXpipe" = "yes"; then CXXFLAGS="$CXXFLAGS -pipe" fi -# temporary solution to supress GCC 4.2.0 c++ warning: -# deprecated conversion from string constant to `char *' -CXXFLAGS="$CXXFLAGS -Wno-write-strings" - PICOPT="" SHAREDLIB="no" diff --git a/sim/ucsim/configure.in b/sim/ucsim/configure.in index 7a86a697..339cdc0a 100644 --- a/sim/ucsim/configure.in +++ b/sim/ucsim/configure.in @@ -477,10 +477,6 @@ if test "$ucsim_cv_CXXpipe" = "yes"; then CXXFLAGS="$CXXFLAGS -pipe" fi -# temporary solution to supress GCC 4.2.0 c++ warning: -# deprecated conversion from string constant to `char *' -CXXFLAGS="$CXXFLAGS -Wno-write-strings" - PICOPT="" SHAREDLIB="no" DD_COPT_NO_IGNORE(CXX, fPIC) diff --git a/sim/ucsim/error.cc b/sim/ucsim/error.cc index 8494cdd2..eea66391 100644 --- a/sim/ucsim/error.cc +++ b/sim/ucsim/error.cc @@ -52,7 +52,7 @@ class cl_list *cl_error_registry::registered_errors= NIL; /* */ -cl_error_class::cl_error_class(enum error_type typ, char *aname, +cl_error_class::cl_error_class(enum error_type typ, const char *aname, enum error_on_off be_on/* = ERROR_PARENT*/): cl_base() { @@ -61,7 +61,7 @@ cl_error_class::cl_error_class(enum error_type typ, char *aname, set_name(aname, "not-known"); } -cl_error_class::cl_error_class(enum error_type typ, char *aname, +cl_error_class::cl_error_class(enum error_type typ, const char *aname, class cl_error_class *parent, enum error_on_off be_on/* = ERROR_PARENT*/): cl_base() @@ -109,7 +109,7 @@ cl_error_class::get_name(void) return(name); }*/ -char * +const char * cl_error_class::get_type_name() { return(get_id_string(error_type_names, type, "untyped")); @@ -172,7 +172,7 @@ cl_error::print(class cl_commander_base *c) c->dd_printf("%s\n", get_type_name()); } -char * +const char * cl_error::get_type_name() { enum error_type type= get_type(); diff --git a/sim/ucsim/errorcl.h b/sim/ucsim/errorcl.h index 91d821f3..ae3e284e 100644 --- a/sim/ucsim/errorcl.h +++ b/sim/ucsim/errorcl.h @@ -53,9 +53,9 @@ protected: //char *name; enum error_on_off on; public: - cl_error_class(enum error_type typ, char *aname, + cl_error_class(enum error_type typ, const char *aname, enum error_on_off be_on= ERROR_PARENT); - cl_error_class(enum error_type typ, char *aname, + cl_error_class(enum error_type typ, const char *aname, class cl_error_class *parent, enum error_on_off be_on= ERROR_PARENT); @@ -63,7 +63,7 @@ public: void set_on(enum error_on_off val); bool is_on(void); enum error_type get_type(void); - char *get_type_name(void); + const char *get_type_name(void); //char *get_name(void); }; @@ -71,11 +71,11 @@ class cl_error_registry { public: cl_error_registry(void); - class cl_error_class *find(char *type_name) + class cl_error_class *find(const char *type_name) { if (NIL == registered_errors) return NIL; - return static_cast(registered_errors->first_that(compare, static_cast(type_name))); + return static_cast(registered_errors->first_that(compare, type_name)); } static class cl_list *get_list(void) { @@ -93,9 +93,9 @@ protected: private: static class cl_list *registered_errors; - static int compare(void *obj1, void *obj2) + static int compare(void *obj1, const void *obj2) { - return (static_cast(obj1))->is_named(static_cast(obj2)); + return (static_cast(obj1))->is_named(static_cast(obj2)); } }; @@ -120,7 +120,7 @@ public: virtual class cl_error_class *get_class(void) { return(classification); } virtual void print(class cl_commander_base *c); - virtual char *get_type_name(); + virtual const char *get_type_name(); }; #endif diff --git a/sim/ucsim/globals.cc b/sim/ucsim/globals.cc index d6d93583..56a934c7 100644 --- a/sim/ucsim/globals.cc +++ b/sim/ucsim/globals.cc @@ -73,7 +73,7 @@ struct id_element error_type_names[]= { }; -char *warranty= +const char *warranty= " NO WARRANTY\n" "\n" " 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n" @@ -98,7 +98,7 @@ char *warranty= ; -char *copying= +const char *copying= " GNU GENERAL PUBLIC LICENSE\n" " Version 2, June 1991\n" "\n" diff --git a/sim/ucsim/hc08.src/hc08.cc b/sim/ucsim/hc08.src/hc08.cc index 40dd7e2f..ed318ea1 100644 --- a/sim/ucsim/hc08.src/hc08.cc +++ b/sim/ucsim/hc08.src/hc08.cc @@ -98,7 +98,7 @@ cl_hc08::reset(void) } -char * +const char * cl_hc08::id_string(void) { return("unspecified HC08"); @@ -177,9 +177,8 @@ int cl_hc08::inst_length(t_addr addr) { int len = 0; - char *s; - s = get_disasm_info(addr, &len, NULL, NULL); + get_disasm_info(addr, &len, NULL, NULL); return len; } @@ -188,9 +187,8 @@ int cl_hc08::inst_branch(t_addr addr) { int b; - char *s; - s = get_disasm_info(addr, NULL, &b, NULL); + get_disasm_info(addr, NULL, &b, NULL); return b; } @@ -202,13 +200,13 @@ cl_hc08::longest_inst(void) } -char * +const char * cl_hc08::get_disasm_info(t_addr addr, int *ret_len, int *ret_branch, int *immed_offset) { - char *b = NULL; + const char *b = NULL; uint code; int len = 0; int immed_n = 0; @@ -263,11 +261,12 @@ cl_hc08::get_disasm_info(t_addr addr, return b; } -char * +const char * cl_hc08::disass(t_addr addr, char *sep) { char work[256], temp[20]; - char *buf, *p, *b, *t; + const char *b; + char *buf, *p, *t; int len = 0; int immed_offset = 0; @@ -354,10 +353,10 @@ cl_hc08::disass(t_addr addr, char *sep) buf= (char *)malloc(6+strlen(p)+1); else buf= (char *)malloc((p-work)+strlen(sep)+strlen(p)+1); - for (p= work, b= buf; *p != ' '; p++, b++) - *b= *p; + for (p= work, t= buf; *p != ' '; p++, t++) + *t= *p; p++; - *b= '\0'; + *t= '\0'; if (sep == NULL) { while (strlen(buf) < 6) diff --git a/sim/ucsim/hc08.src/hc08cl.h b/sim/ucsim/hc08.src/hc08cl.h index 20bf4c31..1cc69719 100644 --- a/sim/ucsim/hc08.src/hc08cl.h +++ b/sim/ucsim/hc08.src/hc08cl.h @@ -46,7 +46,7 @@ public: public: cl_hc08(class cl_sim *asim); virtual int init(void); - virtual char *id_string(void); + virtual const char *id_string(void); //virtual t_addr get_mem_size(enum mem_class type); virtual void mk_hw_elements(void); @@ -56,12 +56,12 @@ public: virtual int inst_length(t_addr addr); virtual int inst_branch(t_addr addr); virtual int longest_inst(void); - virtual char *disass(t_addr addr, char *sep); + virtual const char *disass(t_addr addr, char *sep); virtual void print_regs(class cl_console_base *con); virtual int exec_inst(void); - virtual char * get_disasm_info(t_addr addr, + virtual const char *get_disasm_info(t_addr addr, int *ret_len, int *ret_branch, int *immed_offset); diff --git a/sim/ucsim/option.cc b/sim/ucsim/option.cc index 01b7db0c..83bccf75 100644 --- a/sim/ucsim/option.cc +++ b/sim/ucsim/option.cc @@ -60,7 +60,7 @@ * */ -cl_option::cl_option(class cl_base *the_creator, char *aname, char *Ihelp): +cl_option::cl_option(class cl_base *the_creator, const char *aname, const char *Ihelp): cl_base() { creator= the_creator; @@ -218,24 +218,16 @@ cl_option::set_value(double opt) * List of options */ -void * +const void * cl_options::key_of(void *item) { return(((class cl_base *)item)->get_name()); } int -cl_options::compare(void *key1, void *key2) +cl_options::compare(const void *key1, const void *key2) { - //class cl_option *k1, *k2; - int i; - char *k1, *k2; - - k1= /*(class cl_option *)*/(char *)key1; - k2= /*(class cl_option *)*/(char *)key2; - if ((i= strcmp(k1, k2)) != 0) - return(i); - return(i); + return(strcmp(static_cast(key1), static_cast(key2))); } void @@ -253,7 +245,7 @@ cl_options::del_option(class cl_option *opt) } class cl_option * -cl_options::get_option(char *the_name) +cl_options::get_option(const char *the_name) { t_index idx; @@ -263,7 +255,7 @@ cl_options::get_option(char *the_name) } class cl_option * -cl_options::get_option(char *the_name, class cl_base *creator) +cl_options::get_option(const char *the_name, class cl_base *creator) { t_index idx; class cl_option *o; @@ -301,7 +293,7 @@ cl_options::get_option(char *the_name, class cl_base *creator) } class cl_option * -cl_options::get_option(char *the_name, char *creator) +cl_options::get_option(const char *the_name, char *creator) { t_index idx; class cl_option *o; @@ -376,7 +368,7 @@ cl_options::nuof_options(char *the_name, char *creator) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, bool value) +cl_options::set_value(const char *the_name, cl_base *creator, bool value) { class cl_option *o= get_option(the_name, creator); @@ -386,7 +378,7 @@ cl_options::set_value(char *the_name, cl_base *creator, bool value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, char *value) +cl_options::set_value(const char *the_name, cl_base *creator, char *value) { class cl_option *o= get_option(the_name, creator); @@ -396,7 +388,7 @@ cl_options::set_value(char *the_name, cl_base *creator, char *value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, void *value) +cl_options::set_value(const char *the_name, cl_base *creator, void *value) { class cl_option *o= get_option(the_name, creator); @@ -406,7 +398,7 @@ cl_options::set_value(char *the_name, cl_base *creator, void *value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, long value) +cl_options::set_value(const char *the_name, cl_base *creator, long value) { class cl_option *o= get_option(the_name, creator); @@ -416,7 +408,7 @@ cl_options::set_value(char *the_name, cl_base *creator, long value) } class cl_option * -cl_options::set_value(char *the_name, cl_base *creator, double value) +cl_options::set_value(const char *the_name, cl_base *creator, double value) { class cl_option *o= get_option(the_name, creator); @@ -461,7 +453,7 @@ cl_optref::~cl_optref(void) class cl_option * cl_optref::create(class cl_base *creator, enum option_type type, - char *the_name, char *help) + const char *the_name, const char *help) { if (option) option->del_reference(this); @@ -500,7 +492,7 @@ cl_optref::create(class cl_base *creator, } void -cl_optref::default_option(char *the_name) +cl_optref::default_option(const char *the_name) { class cl_option *o= application->options->get_option(the_name, application); @@ -527,7 +519,7 @@ cl_optref::use(void) } class cl_option * -cl_optref::use(char *the_name) +cl_optref::use(const char *the_name) { if (option) option->del_reference(this); @@ -564,7 +556,7 @@ cl_optref::get_value(bool) } char * -cl_optref::get_value(char *) +cl_optref::get_value(const char *) { if (!option) { @@ -639,7 +631,7 @@ cl_optref::get_value(double) */ cl_bool_option::cl_bool_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -678,7 +670,7 @@ cl_bool_option::set_value(char *s) */ cl_string_option::cl_string_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -708,7 +700,7 @@ cl_string_option::print(class cl_console_base *con) */ cl_pointer_option::cl_pointer_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -797,7 +789,7 @@ cl_cons_debug_opt::set_value(char *s) */ cl_number_option::cl_number_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} @@ -823,7 +815,7 @@ cl_number_option::set_value(char *s) */ cl_float_option::cl_float_option(class cl_base *the_creator, - char *aname, char *Ihelp): + const char *aname, const char *Ihelp): cl_option(the_creator, aname, Ihelp) {} diff --git a/sim/ucsim/optioncl.h b/sim/ucsim/optioncl.h index b8b298ca..2e8ad8a1 100644 --- a/sim/ucsim/optioncl.h +++ b/sim/ucsim/optioncl.h @@ -70,7 +70,7 @@ public: bool hidden; public: - cl_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual class cl_option &operator=(class cl_option &o); virtual ~cl_option(void); virtual void pre_remove(void); @@ -80,7 +80,7 @@ public: virtual void show(void) { hidden= DD_FALSE; } virtual void print(class cl_console_base *con) {} - virtual char *get_type_name(void) { return("non"); } + virtual const char *get_type_name(void) { return("non"); } virtual union option_value *get_value(void) { return(&value); } virtual void get_value(bool *val); @@ -104,26 +104,26 @@ class cl_options: public cl_sorted_list { public: cl_options(void): cl_sorted_list(2, 2, "options") { Duplicates= DD_TRUE; } - virtual void *key_of(void *item); - virtual int compare(void *key1, void *key2); + virtual const void *key_of(void *item); + virtual int compare(const void *key1, const void *key2); virtual void new_option(class cl_option *opt); virtual void del_option(class cl_option *opt); - virtual class cl_option *get_option(char *the_name); - virtual class cl_option *get_option(char *the_name, class cl_base *creator); - virtual class cl_option *get_option(char *the_name, char *creator); + virtual class cl_option *get_option(const char *the_name); + virtual class cl_option *get_option(const char *the_name, class cl_base *creator); + virtual class cl_option *get_option(const char *the_name, char *creator); virtual class cl_option *get_option(int idx); virtual int nuof_options(char *the_name); virtual int nuof_options(char *the_name, char *creator); - virtual class cl_option *set_value(char *the_name, cl_base *creator, + virtual class cl_option *set_value(const char *the_name, cl_base *creator, bool value); - virtual class cl_option *set_value(char *the_name, cl_base *creator, + virtual class cl_option *set_value(const char *the_name, cl_base *creator, char *value); - virtual class cl_option *set_value(char *the_name, cl_base *creator, + virtual class cl_option *set_value(const char *the_name, cl_base *creator, void *value); - virtual class cl_option *set_value(char *the_name, cl_base *creator, + virtual class cl_option *set_value(const char *the_name, cl_base *creator, long value); - virtual class cl_option *set_value(char *the_name, cl_base *creator, + virtual class cl_option *set_value(const char *the_name, cl_base *creator, double value); }; @@ -140,16 +140,16 @@ public: virtual class cl_option *create(class cl_base *creator, enum option_type type, - char *the_name, char *help); - virtual void default_option(char *the_name); + const char *the_name, const char *help); + virtual void default_option(const char *the_name); virtual class cl_option *use(void); - virtual class cl_option *use(char *the_name); + virtual class cl_option *use(const char *the_name); virtual void option_changed(void) {} virtual void option_removing(void); virtual class cl_base *get_owner(void) { return(owner); } virtual bool get_value(bool); - virtual char *get_value(char *); + virtual char *get_value(const char *); virtual void *get_value(void *); virtual long get_value(long); virtual double get_value(double); @@ -159,9 +159,9 @@ public: class cl_bool_option: public cl_option { public: - cl_bool_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_bool_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual void print(class cl_console_base *con); - virtual char *get_type_name(void) { return("boolean"); } + virtual const char *get_type_name(void) { return("boolean"); } virtual void set_value(char *s); }; @@ -169,29 +169,29 @@ public: class cl_string_option: public cl_option { public: - cl_string_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_string_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual class cl_option &operator=(class cl_option &o); virtual void print(class cl_console_base *con); - virtual char *get_type_name(void) { return("string"); } + virtual const char *get_type_name(void) { return("string"); } }; class cl_pointer_option: public cl_option { public: - cl_pointer_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_pointer_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual class cl_option &operator=(class cl_option &o); virtual void print(class cl_console_base *con); - virtual char *get_type_name(void) { return("pointer"); } + virtual const char *get_type_name(void) { return("pointer"); } }; class cl_number_option: public cl_option { public: - cl_number_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_number_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual void print(class cl_console_base *con); - virtual char *get_type_name(void) { return("integer"); } + virtual const char *get_type_name(void) { return("integer"); } virtual void set_value(char *s); }; @@ -199,9 +199,9 @@ public: class cl_float_option: public cl_option { public: - cl_float_option(class cl_base *the_creator, char *aname, char *Ihelp); + cl_float_option(class cl_base *the_creator, const char *aname, const char *Ihelp); virtual void print(class cl_console_base *con); - virtual char *get_type_name(void) { return("float"); } + virtual const char *get_type_name(void) { return("float"); } virtual void set_value(char *s); }; diff --git a/sim/ucsim/pobj.cc b/sim/ucsim/pobj.cc index 126e14db..e32deed6 100644 --- a/sim/ucsim/pobj.cc +++ b/sim/ucsim/pobj.cc @@ -76,16 +76,16 @@ cl_base::~cl_base(void) int cl_base::init(void) {return(0);} -char * -cl_base::get_name(char *def) +const char * +cl_base::get_name(const char *def) { if (!name) return(def); return(name); } -char * -cl_base::set_name(char *new_name) +const char * +cl_base::set_name(const char *new_name) { if (name) free(name); @@ -98,8 +98,8 @@ cl_base::set_name(char *new_name) return(name); } -char * -cl_base::set_name(char *new_name, char *def_name) +const char * +cl_base::set_name(const char *new_name, const char *def_name) { char *def; @@ -120,7 +120,7 @@ cl_base::set_name(char *new_name, char *def_name) } bool -cl_base::is_named(char *the_name) +cl_base::is_named(const char *the_name) { if (!name || !*name || @@ -131,7 +131,7 @@ cl_base::is_named(char *the_name) } bool -cl_base::is_inamed(char *the_name) +cl_base::is_inamed(const char *the_name) { if (!name || !*name || @@ -265,7 +265,7 @@ cl_event::~cl_event(void) * Initializing a collection */ -cl_list::cl_list(t_index alimit, t_index adelta, char *aname): +cl_list::cl_list(t_index alimit, t_index adelta, const char *aname): cl_base() { count= 0; @@ -460,7 +460,7 @@ cl_list::error(t_index code, t_index info) */ void * -cl_list::first_that(match_func test, void *arg) +cl_list::first_that(match_func test, const void *arg) { for (t_index i= 0; i < count; i++) { @@ -677,7 +677,7 @@ cl_list::set_limit(t_index alimit) * Initilizing the sorted collection */ -cl_sorted_list::cl_sorted_list(t_index alimit, t_index adelta, char *aname): +cl_sorted_list::cl_sorted_list(t_index alimit, t_index adelta, const char *aname): cl_list(alimit, adelta, aname) { Duplicates= DD_FALSE; @@ -691,7 +691,7 @@ cl_sorted_list::~cl_sorted_list(void) {} * Get the address of the key field in an item. */ -void * +const void * cl_sorted_list::key_of(void *item) { return(item); @@ -746,7 +746,7 @@ cl_sorted_list::add(void *item) */ bool -cl_sorted_list::search(void *key, t_index &index) +cl_sorted_list::search(const void *key, t_index &index) { t_index l = 0; t_index h = count - 1; @@ -784,7 +784,7 @@ cl_sorted_list::search(void *key, t_index &index) * Initilizing the string collection */ -cl_strings::cl_strings(t_index alimit, t_index adelta, char *aname): +cl_strings::cl_strings(t_index alimit, t_index adelta, const char *aname): cl_sorted_list(alimit, adelta, aname) { Duplicates= DD_TRUE; @@ -799,9 +799,9 @@ cl_strings::~cl_strings(void) {} */ int -cl_strings::compare(void *key1, void *key2) +cl_strings::compare(const void *key1, const void *key2) { - return(strcmp((char *)key1, (char *)key2)); + return(strcmp(static_cast(key1), static_cast(key2))); } @@ -827,7 +827,7 @@ cl_strings::free_item(void* item) * Initilizing the unsorted string collection */ -cl_ustrings::cl_ustrings(t_index alimit, t_index adelta, char *aname): +cl_ustrings::cl_ustrings(t_index alimit, t_index adelta, const char *aname): cl_strings(alimit, adelta, aname) {} @@ -840,7 +840,7 @@ cl_ustrings::~cl_ustrings(void) {} */ int -cl_ustrings::compare(void *key1, void *key2) +cl_ustrings::compare(const void *key1, const void *key2) { return(-1); } @@ -851,11 +851,11 @@ cl_ustrings::compare(void *key1, void *key2) */ bool -cl_ustrings::search(void *key, t_index& index) +cl_ustrings::search(const void *key, t_index& index) { t_index i = 0; bool found= DD_FALSE; - void *Actual; + const void *Actual; if ((count) && key) { diff --git a/sim/ucsim/pobjcl.h b/sim/ucsim/pobjcl.h index 317d1ce8..692eb73d 100644 --- a/sim/ucsim/pobjcl.h +++ b/sim/ucsim/pobjcl.h @@ -58,14 +58,14 @@ public: virtual ~cl_base(void); virtual int init(void); - virtual char *get_name(void) { return(name); } - virtual char *get_name(char *def); + virtual const char *get_name(void) { return(name); } + virtual const char *get_name(const char *def); virtual bool have_name(void) { return(name != 0); } virtual bool have_real_name(void) { return(name != 0 && *name != '\0'); } - char *set_name(char *new_name); - char *set_name(char *new_name, char *def_name); - bool is_named(char *the_name); - bool is_inamed(char *the_name); + const char *set_name(const char *new_name); + const char *set_name(const char *new_name, const char *def_name); + bool is_named(const char *the_name); + bool is_inamed(const char *the_name); class cl_base *get_parent(void) { return(parent); } int nuof_children(void); @@ -118,7 +118,7 @@ protected: t_index Delta; public: - cl_list(t_index alimit, t_index adelta, char *aname); + cl_list(t_index alimit, t_index adelta, const char *aname); virtual ~cl_list(void); void *at(t_index index); @@ -145,7 +145,7 @@ public: virtual t_index add(class cl_base *item, class cl_base *parent); virtual void push(void *item); - void *first_that(match_func test, void *arg); + void *first_that(match_func test, const void *arg); void *last_that(match_func test, void *arg); void for_each(iterator_func action, void *arg); @@ -167,15 +167,15 @@ class cl_sorted_list: public cl_list public: bool Duplicates; public: - cl_sorted_list(t_index alimit, t_index adelta, char *aname); + cl_sorted_list(t_index alimit, t_index adelta, const char *aname); virtual ~cl_sorted_list(void); - virtual bool search(void *key, t_index& index); + virtual bool search(const void *key, t_index& index); virtual t_index index_of(void *item); virtual t_index add(void *item); - virtual void *key_of(void *item); + virtual const void *key_of(void *item); private: - virtual int compare(void *key1, void *key2)= 0; + virtual int compare(const void *key1, const void *key2)= 0; }; @@ -189,11 +189,11 @@ private: class cl_strings: public cl_sorted_list { public: - cl_strings(t_index alimit, t_index adelta, char *aname); + cl_strings(t_index alimit, t_index adelta, const char *aname); virtual ~cl_strings(void); private: - virtual int compare(void *key1, void *key2); + virtual int compare(const void *key1, const void *key2); virtual void free_item(void *item); }; @@ -208,12 +208,12 @@ private: class cl_ustrings: public cl_strings { public: - cl_ustrings(t_index alimit, t_index adelta, char *aname); + cl_ustrings(t_index alimit, t_index adelta, const char *aname); virtual ~cl_ustrings(void); private: - virtual int compare(void *key1, void *key2); - virtual bool search(void *key, t_index &index); + virtual int compare(const void *key1, const void *key2); + virtual bool search(const void *key, t_index &index); }; diff --git a/sim/ucsim/pobjt.h b/sim/ucsim/pobjt.h index 3b879889..45e7e611 100644 --- a/sim/ucsim/pobjt.h +++ b/sim/ucsim/pobjt.h @@ -37,7 +37,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #endif typedef int t_index; -typedef int (*match_func)(void *, void *); +typedef int (*match_func)(void *, const void *); typedef void (*iterator_func)(void *, void *); #define max_list_size (0x10000/sizeof(void *)) diff --git a/sim/ucsim/s51.src/serial.cc b/sim/ucsim/s51.src/serial.cc index dde27150..e36fb422 100644 --- a/sim/ucsim/s51.src/serial.cc +++ b/sim/ucsim/s51.src/serial.cc @@ -449,7 +449,7 @@ cl_serial::happen(class cl_hw *where, enum hw_event he, void *params) void cl_serial::print_info(class cl_console_base *con) { - char *modes[]= { "Shift, fixed clock", + const char *modes[]= { "Shift, fixed clock", "8 bit UART timer clocked", "9 bit UART fixed clock", "9 bit UART timer clocked" }; diff --git a/sim/ucsim/s51.src/sim51.cc b/sim/ucsim/s51.src/sim51.cc index e4c281df..f929aecb 100644 --- a/sim/ucsim/s51.src/sim51.cc +++ b/sim/ucsim/s51.src/sim51.cc @@ -57,7 +57,7 @@ class cl_uc * cl_sim51::mk_controller(void) { int i; - char *typ= NIL; + const char *typ= NIL; class cl_optref type_option(this); type_option.init(); diff --git a/sim/ucsim/s51.src/timer0.cc b/sim/ucsim/s51.src/timer0.cc index 6eea6fac..5024c9e3 100644 --- a/sim/ucsim/s51.src/timer0.cc +++ b/sim/ucsim/s51.src/timer0.cc @@ -30,7 +30,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "types51.h" -cl_timer0::cl_timer0(class cl_uc *auc, int aid, char *aid_string): +cl_timer0::cl_timer0(class cl_uc *auc, int aid, const char *aid_string): cl_hw(auc, HW_TIMER, aid, aid_string) { cell_tmod= cell_tcon= 0; @@ -372,7 +372,7 @@ cl_timer0::happen(class cl_hw *where, enum hw_event he, void *params) void cl_timer0::print_info(class cl_console_base *con) { - char *modes[]= { "13 bit", "16 bit", "8 bit autoreload", "2x8 bit" }; + const char *modes[]= { "13 bit", "16 bit", "8 bit autoreload", "2x8 bit" }; //t_mem tmod= cell_tmod->get(); int on; class cl_address_space *sfr= uc->address_space(MEM_SFR_ID); diff --git a/sim/ucsim/s51.src/timer0cl.h b/sim/ucsim/s51.src/timer0cl.h index f0628fb4..a34846ec 100644 --- a/sim/ucsim/s51.src/timer0cl.h +++ b/sim/ucsim/s51.src/timer0cl.h @@ -46,7 +46,7 @@ protected: t_addr addr_tl, addr_th; int mode, GATE, C_T, TR, INT, T_edge; public: - cl_timer0(class cl_uc *auc, int aid, char *aid_string); + cl_timer0(class cl_uc *auc, int aid, const char *aid_string); virtual int init(void); virtual void added_to_uc(void); diff --git a/sim/ucsim/s51.src/timer1.cc b/sim/ucsim/s51.src/timer1.cc index ec639869..54739aa3 100644 --- a/sim/ucsim/s51.src/timer1.cc +++ b/sim/ucsim/s51.src/timer1.cc @@ -29,7 +29,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "regs51.h" -cl_timer1::cl_timer1(class cl_uc *auc, int aid, char *aid_string): +cl_timer1::cl_timer1(class cl_uc *auc, int aid, const char *aid_string): cl_timer0(auc, aid, aid_string) { make_partner(HW_UART, 0); @@ -63,7 +63,7 @@ cl_timer1::overflow(void) void cl_timer1::print_info(class cl_console_base *con) { - char *modes[]= { "13 bit", "16 bit", "8 bit autoreload", "stop" }; + const char *modes[]= { "13 bit", "16 bit", "8 bit autoreload", "stop" }; //int tmod= cell_tmod->get(); int on; class cl_address_space *sfr= uc->address_space(MEM_SFR_ID); diff --git a/sim/ucsim/s51.src/timer1cl.h b/sim/ucsim/s51.src/timer1cl.h index cd182327..33c6e09c 100644 --- a/sim/ucsim/s51.src/timer1cl.h +++ b/sim/ucsim/s51.src/timer1cl.h @@ -39,7 +39,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA class cl_timer1: public cl_timer0 { public: - cl_timer1(class cl_uc *auc, int aid, char *aid_string); + cl_timer1(class cl_uc *auc, int aid, const char *aid_string); //virtual int init(void); //virtual void new_hw_added(class cl_hw *new_hw); diff --git a/sim/ucsim/s51.src/timer2.cc b/sim/ucsim/s51.src/timer2.cc index a238179f..93738acf 100644 --- a/sim/ucsim/s51.src/timer2.cc +++ b/sim/ucsim/s51.src/timer2.cc @@ -30,7 +30,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA #include "types51.h" -cl_timer2::cl_timer2(class cl_uc *auc, int aid, char *aid_string, +cl_timer2::cl_timer2(class cl_uc *auc, int aid, const char *aid_string, int afeatures): cl_timer0(auc, /*2*/aid, /*"timer2"*/aid_string) { diff --git a/sim/ucsim/s51.src/timer2cl.h b/sim/ucsim/s51.src/timer2cl.h index 15d2d264..b0cd339e 100644 --- a/sim/ucsim/s51.src/timer2cl.h +++ b/sim/ucsim/s51.src/timer2cl.h @@ -63,7 +63,7 @@ protected: class cl_memory_cell *cell_rcap2l, *cell_rcap2h, *cell_t2mod; bool bit_dcen, bit_t2oe, bit_t2ex; public: - cl_timer2(class cl_uc *auc, int aid, char *aid_string, int afeautres); + cl_timer2(class cl_uc *auc, int aid, const char *aid_string, int afeautres); virtual int init(void); virtual void added_to_uc(void); diff --git a/sim/ucsim/s51.src/uc390.cc b/sim/ucsim/s51.src/uc390.cc index 3d2ad4f5..c2587874 100644 --- a/sim/ucsim/s51.src/uc390.cc +++ b/sim/ucsim/s51.src/uc390.cc @@ -445,7 +445,7 @@ cl_uc390::clear_sfr(void) t_mem -cl_uc390::read_mem(char *id/*enum mem_class type*/, t_addr addr) +cl_uc390::read_mem(const char *id/*enum mem_class type*/, t_addr addr) { if (strcmp(/*type*/id,/* == */MEM_XRAM_ID)==0 && @@ -459,7 +459,7 @@ cl_uc390::read_mem(char *id/*enum mem_class type*/, t_addr addr) } t_mem -cl_uc390::get_mem (char *id/*enum mem_class type*/, t_addr addr) +cl_uc390::get_mem (const char *id/*enum mem_class type*/, t_addr addr) { if (strcmp(/*type*/id/* == */,MEM_XRAM_ID)==0 && addr >= 0x400000 && @@ -472,7 +472,7 @@ cl_uc390::get_mem (char *id/*enum mem_class type*/, t_addr addr) } void -cl_uc390::write_mem (char *id/*enum mem_class type*/, t_addr addr, t_mem val) +cl_uc390::write_mem (const char *id/*enum mem_class type*/, t_addr addr, t_mem val) { if (strcmp(/*type ==*/id, MEM_XRAM_ID)==0 && addr >= 0x400000 && @@ -485,7 +485,7 @@ cl_uc390::write_mem (char *id/*enum mem_class type*/, t_addr addr, t_mem val) } void -cl_uc390::set_mem (/*enum mem_class type*/char *id, t_addr addr, t_mem val) +cl_uc390::set_mem (/*enum mem_class type*/const char *id, t_addr addr, t_mem val) { if (/*type == */strcmp(id,MEM_XRAM_ID)==0 && addr >= 0x400000 && @@ -1084,7 +1084,8 @@ char * cl_uc390::disass (t_addr addr, char *sep) { char work[256], temp[20], c[2]; - char *buf, *p, *b, *t; + const char *b; + char *buf, *p, *t; t_mem code; if (! (sfr->get (ACON) & 0x02)) /* AM1 set: 24-bit flat? */ @@ -1181,10 +1182,10 @@ cl_uc390::disass (t_addr addr, char *sep) buf = (char *) malloc (6 + strlen (p) + 1); else buf = (char *) malloc ((p - work) + strlen (sep) + strlen (p) + 1); - for (p = work, b = buf; *p != ' '; p++, b++) - *b = *p; + for (p = work, t = buf; *p != ' '; p++, t++) + *t = *p; p++; - *b = '\0'; + *t = '\0'; if (sep == NULL) while (strlen (buf) < 6) strcat (buf, " "); diff --git a/sim/ucsim/s51.src/uc390cl.h b/sim/ucsim/s51.src/uc390cl.h index 399a937f..009487f0 100644 --- a/sim/ucsim/s51.src/uc390cl.h +++ b/sim/ucsim/s51.src/uc390cl.h @@ -46,10 +46,10 @@ public: //virtual t_addr get_mem_size (enum mem_class type); // manipulating memories - virtual t_mem read_mem (char *id/*enum mem_class type*/, t_addr addr); - virtual t_mem get_mem (char *id/*enum mem_class type*/, t_addr addr); - virtual void write_mem (char *id/*enum mem_class type*/, t_addr addr, t_mem val); - virtual void set_mem (char *id/*enum mem_class type*/, t_addr addr, t_mem val); + virtual t_mem read_mem (const char *id/*enum mem_class type*/, t_addr addr); + virtual t_mem get_mem (const char *id/*enum mem_class type*/, t_addr addr); + virtual void write_mem (const char *id/*enum mem_class type*/, t_addr addr, t_mem val); + virtual void set_mem (const char *id/*enum mem_class type*/, t_addr addr, t_mem val); /* mods for dual-dptr */ virtual int inst_inc_dptr(uchar code); diff --git a/sim/ucsim/s51.src/uc51.cc b/sim/ucsim/s51.src/uc51.cc index aec033ac..29012a27 100644 --- a/sim/ucsim/s51.src/uc51.cc +++ b/sim/ucsim/s51.src/uc51.cc @@ -123,11 +123,10 @@ cl_51core::init(void) return(0); } -static char id_string_51[100]; - -char * +const char * cl_51core::id_string(void) { + static char id_string_51[100]; int i; for (i= 0; cpus_51[i].type_str != NULL && cpus_51[i].type != type; i++) ; @@ -319,7 +318,8 @@ char * cl_51core::disass(t_addr addr, char *sep) { char work[256], temp[20], c[2]; - char *buf, *p, *b, *t; + const char *b; + char *buf, *p, *t; t_mem code= rom->get(addr); p= work; @@ -409,10 +409,10 @@ cl_51core::disass(t_addr addr, char *sep) buf= (char *)malloc(6+strlen(p)+1); else buf= (char *)malloc((p-work)+strlen(sep)+strlen(p)+1); - for (p= work, b= buf; *p != ' '; p++, b++) - *b= *p; + for (p= work, t= buf; *p != ' '; p++, t++) + *t= *p; p++; - *b= '\0'; + *t= '\0'; if (sep == NULL) { while (strlen(buf) < 6) diff --git a/sim/ucsim/s51.src/uc51cl.h b/sim/ucsim/s51.src/uc51cl.h index 58950df2..e961385e 100644 --- a/sim/ucsim/s51.src/uc51cl.h +++ b/sim/ucsim/s51.src/uc51cl.h @@ -88,7 +88,7 @@ public: cl_51core(int Itype, int Itech, class cl_sim *asim); virtual ~cl_51core(void); virtual int init(void); - virtual char *id_string(void); + virtual const char *id_string(void); virtual void mk_hw_elements(void); virtual void build_cmdset(class cl_cmdset *cmdset); //virtual class cl_m *mk_mem(enum mem_class type, char *class_name); diff --git a/sim/ucsim/sim.src/arg.cc b/sim/ucsim/sim.src/arg.cc index e38ae65d..816d54d3 100644 --- a/sim/ucsim/sim.src/arg.cc +++ b/sim/ucsim/sim.src/arg.cc @@ -55,7 +55,7 @@ cl_arg::cl_arg(long lv): s_value= 0; } -cl_arg::cl_arg(char *sv): +cl_arg::cl_arg(const char *sv): cl_base() { s_value= sv?strdup(sv):0; @@ -243,7 +243,7 @@ cl_cmd_int_arg::as_string(void) /* Symbol */ -cl_cmd_sym_arg::cl_cmd_sym_arg(/*class cl_uc *iuc,*/ char *sym): +cl_cmd_sym_arg::cl_cmd_sym_arg(/*class cl_uc *iuc,*/ const char *sym): cl_cmd_arg(/*iuc,*/ sym) {} @@ -323,7 +323,7 @@ cl_cmd_sym_arg::as_hw(class cl_uc *uc) /* String */ -cl_cmd_str_arg::cl_cmd_str_arg(/*class cl_uc *iuc,*/ char *str): +cl_cmd_str_arg::cl_cmd_str_arg(/*class cl_uc *iuc,*/ const char *str): cl_cmd_arg(/*iuc,*/ str) { } diff --git a/sim/ucsim/sim.src/argcl.h b/sim/ucsim/sim.src/argcl.h index c829d92e..4b7d1363 100644 --- a/sim/ucsim/sim.src/argcl.h +++ b/sim/ucsim/sim.src/argcl.h @@ -49,7 +49,7 @@ public: public: cl_arg(long lv); - cl_arg(char *lv); + cl_arg(const char *lv); cl_arg(double fv); cl_arg(void *pv); virtual ~cl_arg(void); @@ -102,7 +102,7 @@ public: public: cl_cmd_arg(/*class cl_uc *iuc,*/ long i): cl_arg(i) { /*uc= iuc;*/ interpreted_as_string= DD_FALSE; } - cl_cmd_arg(/*class cl_uc *iuc,*/ char *s): cl_arg(s) + cl_cmd_arg(/*class cl_uc *iuc,*/ const char *s): cl_arg(s) { /*uc= iuc;*/ interpreted_as_string= DD_FALSE; } virtual ~cl_cmd_arg(void); @@ -133,7 +133,7 @@ public: class cl_cmd_sym_arg: public cl_cmd_arg { public: - cl_cmd_sym_arg(/*class cl_uc *iuc,*/ char *sym); + cl_cmd_sym_arg(/*class cl_uc *iuc,*/ const char *sym); virtual bool get_address(class cl_uc *uc, t_addr *addr); virtual bool get_bit_address(class cl_uc *uc, // input @@ -149,7 +149,7 @@ public: class cl_cmd_str_arg: public cl_cmd_arg { public: - cl_cmd_str_arg(/*class cl_uc *iuc,*/ char *str); + cl_cmd_str_arg(/*class cl_uc *iuc,*/ const char *str); virtual int is_string(void) { return(1); } virtual bool as_number(void) { return(DD_FALSE); } diff --git a/sim/ucsim/sim.src/brk.cc b/sim/ucsim/sim.src/brk.cc index f28ccc62..12b87d6c 100644 --- a/sim/ucsim/sim.src/brk.cc +++ b/sim/ucsim/sim.src/brk.cc @@ -160,7 +160,7 @@ brk_coll::brk_coll(t_index alimit, t_index adelta, rom= arom; } -void * +const void * brk_coll::key_of(void *item) { return((void *)&(((class cl_brk *)(item))->nr)); @@ -168,7 +168,7 @@ brk_coll::key_of(void *item) int -brk_coll::compare(void *key1, void *key2) +brk_coll::compare(const void *key1, const void *key2) { int k1, k2; diff --git a/sim/ucsim/sim.src/brkcl.h b/sim/ucsim/sim.src/brkcl.h index 0b93c725..aa773884 100644 --- a/sim/ucsim/sim.src/brkcl.h +++ b/sim/ucsim/sim.src/brkcl.h @@ -116,8 +116,8 @@ public: class cl_address_space/*rom*/ *rom; public: brk_coll(t_index alimit, t_index adelta, class cl_address_space/*rom*/*arom); - virtual void *key_of(void *item); - virtual int compare(void *key1, void *key2); + virtual const void *key_of(void *item); + virtual int compare(const void *key1, const void *key2); virtual bool there_is_event(enum brk_event ev); //virtual int make_new_nr(void); diff --git a/sim/ucsim/sim.src/hw.cc b/sim/ucsim/sim.src/hw.cc index ea4c5f4e..143e9b94 100644 --- a/sim/ucsim/sim.src/hw.cc +++ b/sim/ucsim/sim.src/hw.cc @@ -111,7 +111,7 @@ cl_used_cell::address_space_added(class cl_address_space *amem, *____________________________________________________________________________ */ -cl_hw::cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, char *aid_string): +cl_hw::cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, const char *aid_string): cl_guiobj() { flags= HWF_INSIDE; diff --git a/sim/ucsim/sim.src/hwcl.h b/sim/ucsim/sim.src/hwcl.h index d573010b..39f3b68e 100644 --- a/sim/ucsim/sim.src/hwcl.h +++ b/sim/ucsim/sim.src/hwcl.h @@ -100,7 +100,7 @@ protected: class cl_list *partners; class cl_list *watched_cells; public: - cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, char *aid_string); + cl_hw(class cl_uc *auc, enum hw_cath cath, int aid, const char *aid_string); virtual ~cl_hw(void); virtual void new_hw_adding(class cl_hw *new_hw); diff --git a/sim/ucsim/sim.src/itsrc.cc b/sim/ucsim/sim.src/itsrc.cc index ad17146d..32fc6959 100644 --- a/sim/ucsim/sim.src/itsrc.cc +++ b/sim/ucsim/sim.src/itsrc.cc @@ -46,7 +46,7 @@ cl_it_src::cl_it_src(uchar Iie_mask, uchar Isrc_mask, uint Iaddr, bool Iclr_bit, - char *Iname, + const char *Iname, int apoll_priority): cl_base() { @@ -99,7 +99,7 @@ cl_irqs::cl_irqs(t_index alimit, t_index adelta): Duplicates= DD_TRUE; } -void * +const void * cl_irqs::key_of(void *item) { class cl_it_src *itsrc= (class cl_it_src *)item; @@ -107,13 +107,13 @@ cl_irqs::key_of(void *item) } int -cl_irqs::compare(void *key1, void *key2) +cl_irqs::compare(const void *key1, const void *key2) { - int *k1= (int*)key1, *k2= (int*)key2; + const int k1= *static_cast(key1), k2= *static_cast(key2); - if (*k1 == *k2) + if (k1 == k2) return(0); - else if (*k1 < *k2) + else if (k1 < k2) return(-1); return(1); } diff --git a/sim/ucsim/sim.src/itsrccl.h b/sim/ucsim/sim.src/itsrccl.h index 7f9bd7ef..673a96e8 100644 --- a/sim/ucsim/sim.src/itsrccl.h +++ b/sim/ucsim/sim.src/itsrccl.h @@ -53,7 +53,7 @@ public: uchar Isrc_mask, uint Iaddr, bool Iclr_bit, - char *Iname, + const char *Iname, int apoll_priority); virtual ~cl_it_src(void); @@ -68,8 +68,8 @@ class cl_irqs: public cl_sorted_list { public: cl_irqs(t_index alimit, t_index adelta); - virtual void *key_of(void *item); - virtual int compare(void *key1, void *key2); + virtual const void *key_of(void *item); + virtual int compare(const void *key1, const void *key2); }; diff --git a/sim/ucsim/sim.src/mem.cc b/sim/ucsim/sim.src/mem.cc index 9d27714d..b0bc0d41 100644 --- a/sim/ucsim/sim.src/mem.cc +++ b/sim/ucsim/sim.src/mem.cc @@ -54,7 +54,7 @@ static class cl_mem_error_registry mem_error_registry; * 3rd version of memory system */ -cl_memory::cl_memory(char *id, t_addr asize, int awidth): +cl_memory::cl_memory(const char *id, t_addr asize, int awidth): cl_base() { size= asize; @@ -696,7 +696,7 @@ cl_dummy_cell::set(t_mem val) * Address space */ -cl_address_space::cl_address_space(char *id, +cl_address_space::cl_address_space(const char *id, t_addr astart, t_addr asize, int awidth): cl_memory(id, asize, awidth) { @@ -1056,7 +1056,7 @@ cl_address_space_list::add(class cl_address_space *mem) * Memory chip */ -cl_memory_chip::cl_memory_chip(char *id, int asize, int awidth, int initial): +cl_memory_chip::cl_memory_chip(const char *id, int asize, int awidth, int initial): cl_memory(id, asize, awidth) { array= (t_mem *)malloc(size * sizeof(t_mem)); @@ -1313,7 +1313,7 @@ cl_decoder_list::cl_decoder_list(t_index alimit, t_index adelta, bool bychip): by_chip= bychip; } -void * +const void * cl_decoder_list::key_of(void *item) { class cl_address_decoder *d= (class cl_address_decoder *)item; @@ -1324,9 +1324,9 @@ cl_decoder_list::key_of(void *item) } int -cl_decoder_list::compare(void *key1, void *key2) +cl_decoder_list::compare(const void *key1, const void *key2) { - t_addr k1= *((t_addr*)key1), k2= *((t_addr*)key2); + const t_addr k1= *(static_cast(key1)), k2= *(static_cast(key2)); if (k1 == k2) return(0); else if (k1 > k2) diff --git a/sim/ucsim/sim.src/memcl.h b/sim/ucsim/sim.src/memcl.h index e647f5ea..9ebf3c14 100644 --- a/sim/ucsim/sim.src/memcl.h +++ b/sim/ucsim/sim.src/memcl.h @@ -81,7 +81,7 @@ public: protected: t_addr dump_finished; public: - cl_memory(char *id, t_addr asize, int awidth); + cl_memory(const char *id, t_addr asize, int awidth); virtual ~cl_memory(void); virtual int init(void); @@ -278,7 +278,7 @@ protected: public: class cl_decoder_list *decoders; public: - cl_address_space(char *id, t_addr astart, t_addr asize, int awidth); + cl_address_space(const char *id, t_addr astart, t_addr asize, int awidth); virtual ~cl_address_space(void); virtual bool is_address_space(void) { return(DD_TRUE); } @@ -340,7 +340,7 @@ protected: t_mem *array; int init_value; public: - cl_memory_chip(char *id, int asize, int awidth, int initial= -1); + cl_memory_chip(const char *id, int asize, int awidth, int initial= -1); virtual ~cl_memory_chip(void); virtual int init(void); @@ -395,8 +395,8 @@ protected: public: cl_decoder_list(t_index alimit, t_index adelta, bool bychip); - virtual void *key_of(void *item); - virtual int compare(void *key1, void *key2); + virtual const void *key_of(void *item); + virtual int compare(const void *key1, const void *key2); }; diff --git a/sim/ucsim/sim.src/stack.cc b/sim/ucsim/sim.src/stack.cc index e40fb4a4..60e13ad1 100644 --- a/sim/ucsim/sim.src/stack.cc +++ b/sim/ucsim/sim.src/stack.cc @@ -78,7 +78,7 @@ cl_stack_op::info(class cl_console_base *con, class cl_uc *uc) //con->dd_printf("\n"); } -char * +const char * cl_stack_op::get_op_name(void) { return("op"); @@ -157,7 +157,7 @@ cl_stack_call::mk_copy(void) return(so); } -char * +const char * cl_stack_call::get_op_name(void) { return("call"); @@ -169,7 +169,7 @@ cl_stack_call::print_info(class cl_console_base *con) con->dd_printf("0x%06"_A_"x", called_addr); } -char * +const char * cl_stack_call::get_matching_name(void) { return("ret"); @@ -208,7 +208,7 @@ cl_stack_intr::mk_copy(void) return(so); } -char * +const char * cl_stack_intr::get_op_name(void) { return("intr"); @@ -220,7 +220,7 @@ cl_stack_intr::print_info(class cl_console_base *con) con->dd_printf("0x%06"_A_"x", called_addr); } -char * +const char * cl_stack_intr::get_matching_name(void) { return("iret"); @@ -257,13 +257,13 @@ cl_stack_push::mk_copy(void) return(so); } -char * +const char * cl_stack_push::get_op_name(void) { return("push"); } -char * +const char * cl_stack_push::get_matching_name(void) { return("pop"); @@ -307,13 +307,13 @@ cl_stack_ret::mk_copy(void) return(so); } -char * +const char * cl_stack_ret::get_op_name(void) { return("ret"); } -char * +const char * cl_stack_ret::get_matching_name(void) { return("call"); @@ -350,13 +350,13 @@ cl_stack_iret::mk_copy(void) return(so); } -char * +const char * cl_stack_iret::get_op_name(void) { return("iret"); } -char * +const char * cl_stack_iret::get_matching_name(void) { return("intr"); @@ -393,13 +393,13 @@ cl_stack_pop::mk_copy(void) return(so); } -char * +const char * cl_stack_pop::get_op_name(void) { return("pop"); } -char * +const char * cl_stack_pop::get_matching_name(void) { return("push"); diff --git a/sim/ucsim/sim.src/stackcl.h b/sim/ucsim/sim.src/stackcl.h index 9b25d61e..bd2f357c 100644 --- a/sim/ucsim/sim.src/stackcl.h +++ b/sim/ucsim/sim.src/stackcl.h @@ -62,8 +62,8 @@ public: protected: virtual void print_info(class cl_console_base *con); public: - virtual char *get_op_name(void); - virtual char *get_matching_name(void) { return("unknown"); } + virtual const char *get_op_name(void); + virtual const char *get_matching_name(void) { return("unknown"); } virtual bool sp_increased(void); virtual int data_size(void); virtual bool match(class cl_stack_op *op); @@ -86,10 +86,10 @@ public: t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); virtual void print_info(class cl_console_base *con); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; @@ -102,10 +102,10 @@ public: t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); virtual void print_info(class cl_console_base *con); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; @@ -119,10 +119,10 @@ public: cl_stack_push(t_addr iPC, t_mem idata, t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); virtual void print_info(class cl_console_base *con); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; @@ -134,9 +134,9 @@ public: cl_stack_ret(t_addr iPC, t_addr iaddr, t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; @@ -148,9 +148,9 @@ public: cl_stack_iret(t_addr iPC, t_addr iaddr, t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; @@ -162,9 +162,9 @@ public: cl_stack_pop(t_addr iPC, t_mem idata, t_addr iSP_before, t_addr iSP_after); virtual class cl_stack_op *mk_copy(void); protected: - virtual char *get_op_name(void); + virtual const char *get_op_name(void); public: - virtual char *get_matching_name(void); + virtual const char *get_matching_name(void); virtual enum stack_op get_matching_op(void); virtual bool match(class cl_stack_op *op); }; diff --git a/sim/ucsim/sim.src/uc.cc b/sim/ucsim/sim.src/uc.cc index 4d57c0c7..4550bb09 100644 --- a/sim/ucsim/sim.src/uc.cc +++ b/sim/ucsim/sim.src/uc.cc @@ -62,7 +62,7 @@ static class cl_uc_error_registry uc_error_registry; * Clock counter */ -cl_ticker::cl_ticker(int adir, int in_isr, char *aname) +cl_ticker::cl_ticker(int adir, int in_isr, const char *aname) { options= TICK_RUN; if (in_isr) @@ -221,7 +221,7 @@ cl_uc::init(void) return(0); } -char * +const char * cl_uc::id_string(void) { return("unknown microcontroller"); @@ -593,7 +593,7 @@ cmd->init();*/ */ t_mem -cl_uc::read_mem(char *id, t_addr addr) +cl_uc::read_mem(const char *id, t_addr addr) { class cl_address_space *m= address_space(id); @@ -601,7 +601,7 @@ cl_uc::read_mem(char *id, t_addr addr) } t_mem -cl_uc::get_mem(char *id, t_addr addr) +cl_uc::get_mem(const char *id, t_addr addr) { class cl_address_space *m= address_space(id); @@ -609,7 +609,7 @@ cl_uc::get_mem(char *id, t_addr addr) } void -cl_uc::write_mem(char *id, t_addr addr, t_mem val) +cl_uc::write_mem(const char *id, t_addr addr, t_mem val) { class cl_address_space *m= address_space(id); @@ -618,7 +618,7 @@ cl_uc::write_mem(char *id, t_addr addr, t_mem val) } void -cl_uc::set_mem(char *id, t_addr addr, t_mem val) +cl_uc::set_mem(const char *id, t_addr addr, t_mem val) { class cl_address_space *m= address_space(id); @@ -642,7 +642,7 @@ cl_uc::mem(enum mem_class type) */ class cl_address_space * -cl_uc::address_space(char *id) +cl_uc::address_space(const char *id) { int i; @@ -662,7 +662,7 @@ cl_uc::address_space(char *id) } class cl_memory * -cl_uc::memory(char *id) +cl_uc::memory(const char *id) { int i; @@ -1029,7 +1029,7 @@ cl_uc::bit_tbl(void) } char * -cl_uc::disass(t_addr addr, char *sep) +cl_uc::disass(t_addr addr, const char *sep) { char *buf; diff --git a/sim/ucsim/sim.src/uccl.h b/sim/ucsim/sim.src/uccl.h index 332092cb..54f4f605 100644 --- a/sim/ucsim/sim.src/uccl.h +++ b/sim/ucsim/sim.src/uccl.h @@ -53,7 +53,7 @@ public: int dir; //char *name; - cl_ticker(int adir, int in_isr, char *aname); + cl_ticker(int adir, int in_isr, const char *aname); virtual ~cl_ticker(void); virtual int tick(int nr); @@ -119,7 +119,7 @@ public: cl_uc(class cl_sim *asim); virtual ~cl_uc(void); virtual int init(void); - virtual char *id_string(void); + virtual const char *id_string(void); virtual void reset(void); // making objects @@ -131,12 +131,12 @@ public: virtual void build_cmdset(class cl_cmdset *cmdset); // manipulating memories - virtual t_mem read_mem(char *id, t_addr addr); - virtual t_mem get_mem(char *id, t_addr addr); - virtual void write_mem(char *id, t_addr addr, t_mem val); - virtual void set_mem(char *id, t_addr addr, t_mem val); - virtual class cl_address_space *address_space(char *id); - virtual class cl_memory *memory(char *id); + virtual t_mem read_mem(const char *id, t_addr addr); + virtual t_mem get_mem(const char *id, t_addr addr); + virtual void write_mem(const char *id, t_addr addr, t_mem val); + virtual void set_mem(const char *id, t_addr addr, t_mem val); + virtual class cl_address_space *address_space(const char *id); + virtual class cl_memory *memory(const char *id); // file handling virtual long read_hex_file(const char *nam); @@ -197,7 +197,7 @@ public: virtual void check_events(void); // disassembling and symbol recognition - virtual char *disass(t_addr addr, char *sep); + virtual char *disass(t_addr addr, const char *sep); virtual struct dis_entry *dis_tbl(void); virtual struct name_entry *sfr_tbl(void); virtual struct name_entry *bit_tbl(void); diff --git a/sim/ucsim/stypes.h b/sim/ucsim/stypes.h index a80b241f..f7380609 100644 --- a/sim/ucsim/stypes.h +++ b/sim/ucsim/stypes.h @@ -41,7 +41,7 @@ typedef TYPE_WORD t_smem; /* signed 16 bit memory */ struct id_element { int id; - char *id_string; + const char *id_string; }; enum error_type { @@ -56,21 +56,21 @@ struct dis_entry uint code, mask; char branch; uchar length; - char *mnemonic; + const char *mnemonic; }; // table entry of SFR and BIT names struct name_entry { - int cpu_type; - t_addr addr; - char *name; + int cpu_type; + t_addr addr; + const char *name; }; struct cpu_entry { - char *type_str; + const char *type_str; int type; int technology; }; diff --git a/sim/ucsim/utils.cc b/sim/ucsim/utils.cc index a46aebc4..eb648e7f 100644 --- a/sim/ucsim/utils.cc +++ b/sim/ucsim/utils.cc @@ -67,7 +67,7 @@ get_sub_opt(char **option, const char * const *tokens, char **valuep) } -char * +const char * get_id_string(struct id_element *ids, int id) { int i= 0; @@ -77,16 +77,16 @@ get_id_string(struct id_element *ids, int id) return(ids[i].id_string); } -char * -get_id_string(struct id_element *ids, int id, char *def) +const char * +get_id_string(struct id_element *ids, int id, const char *def) { - char *s= get_id_string(ids, id); + const char *s= get_id_string(ids, id); return(s?s:def); } int -get_string_id(struct id_element *ids, char *str) +get_string_id(struct id_element *ids, const char *str) { int i= 0; @@ -96,7 +96,7 @@ get_string_id(struct id_element *ids, char *str) } int -get_string_id(struct id_element *ids, char *str, int def) +get_string_id(struct id_element *ids, const char *str, int def) { int i= 0; @@ -110,7 +110,7 @@ extern "C" int vasprintf(char **strp, const char *format, va_list ap); extern "C" int vsnprintf(char *str, size_t size,const char *format,va_list ap); char * -format_string(char *format, ...) +format_string(const char *format, ...) { va_list ap; @@ -135,10 +135,10 @@ format_string(char *format, ...) } -char * +const char * object_name(class cl_base *o) { - char *name= 0; + const char *name= 0; if (o) name= o->get_name(); @@ -149,7 +149,7 @@ object_name(class cl_base *o) char * -case_string(enum letter_case lcase, char *str) +case_string(enum letter_case lcase, const char *str) { char *p= strdup(str); char *s= p; @@ -182,7 +182,7 @@ case_string(enum letter_case lcase, char *str) return(s); } -/*char * +/*const char * case_string(enum letter_case lcase, const char *str) { char *p= NIL; diff --git a/sim/ucsim/utils.h b/sim/ucsim/utils.h index f0cecff1..796654d7 100644 --- a/sim/ucsim/utils.h +++ b/sim/ucsim/utils.h @@ -39,13 +39,13 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA extern int get_sub_opt(char **option, const char * const *tokens, char **valuep); -extern char *get_id_string(struct id_element *ids, int id); -extern char *get_id_string(struct id_element *ids, int id, char *def); -extern int get_string_id(struct id_element *ids, char *str); -extern int get_string_id(struct id_element *ids, char *str, int def); -extern char *format_string(char *format, ...); -extern char *object_name(class cl_base *o); -extern char *case_string(enum letter_case lcase, char *str); +extern const char *get_id_string(struct id_element *ids, int id); +extern const char *get_id_string(struct id_element *ids, int id, const char *def); +extern int get_string_id(struct id_element *ids, const char *str); +extern int get_string_id(struct id_element *ids, const char *str, int def); +extern char *format_string(const char *format, ...); +extern const char *object_name(class cl_base *o); +extern char *case_string(enum letter_case lcase, const char *str); #endif diff --git a/sim/ucsim/z80.src/z80.cc b/sim/ucsim/z80.src/z80.cc index 46c5654d..0c1af70c 100644 --- a/sim/ucsim/z80.src/z80.cc +++ b/sim/ucsim/z80.src/z80.cc @@ -79,7 +79,7 @@ cl_z80::init(void) return(0); } -char * +const char * cl_z80::id_string(void) { return("unspecified Z80"); @@ -159,9 +159,8 @@ int cl_z80::inst_length(t_addr addr) { int len = 0; - char *s; - s = get_disasm_info(addr, &len, NULL, NULL); + get_disasm_info(addr, &len, NULL, NULL); return len; } @@ -170,9 +169,8 @@ int cl_z80::inst_branch(t_addr addr) { int b; - char *s; - s = get_disasm_info(addr, NULL, &b, NULL); + get_disasm_info(addr, NULL, &b, NULL); return b; } @@ -184,13 +182,13 @@ cl_z80::longest_inst(void) } -char * +const char * cl_z80::get_disasm_info(t_addr addr, int *ret_len, int *ret_branch, int *immed_offset) { - char *b = NULL; + const char *b = NULL; uint code; int len = 0; int immed_n = 0; @@ -310,11 +308,12 @@ cl_z80::get_disasm_info(t_addr addr, return b; } -char * +const char * cl_z80::disass(t_addr addr, char *sep) { char work[256], temp[20]; - char *buf, *p, *b, *t; + const char *b; + char *buf, *p, *t; int len = 0; int immed_offset = 0; @@ -373,10 +372,10 @@ cl_z80::disass(t_addr addr, char *sep) buf= (char *)malloc(6+strlen(p)+1); else buf= (char *)malloc((p-work)+strlen(sep)+strlen(p)+1); - for (p= work, b= buf; *p != ' '; p++, b++) - *b= *p; + for (p= work, t= buf; *p != ' '; p++, t++) + *t= *p; p++; - *b= '\0'; + *t= '\0'; if (sep == NULL) { while (strlen(buf) < 6) diff --git a/sim/ucsim/z80.src/z80cl.h b/sim/ucsim/z80.src/z80cl.h index 4d66aef9..2010d48c 100644 --- a/sim/ucsim/z80.src/z80cl.h +++ b/sim/ucsim/z80.src/z80cl.h @@ -46,7 +46,7 @@ public: public: cl_z80(class cl_sim *asim); virtual int init(void); - virtual char *id_string(void); + virtual const char *id_string(void); //virtual t_addr get_mem_size(enum mem_class type); virtual void mk_hw_elements(void); @@ -56,12 +56,12 @@ public: virtual int inst_length(t_addr addr); virtual int inst_branch(t_addr addr); virtual int longest_inst(void); - virtual char *disass(t_addr addr, char *sep); + virtual const char *disass(t_addr addr, char *sep); virtual void print_regs(class cl_console_base *con); virtual int exec_inst(void); - virtual char * get_disasm_info(t_addr addr, + virtual const char *get_disasm_info(t_addr addr, int *ret_len, int *ret_branch, int *immed_offset); -- 2.30.2