mirror of
https://github.com/simh/simh.git
synced 2026-02-12 02:48:38 +00:00
ALL: Massive 'const' cleanup
These changes facilitate more robust parameter type checking and helps to identify unexpected coding errors. Most simulators can now also be compiled with a C++ compiler without warnings. Additionally, these changes have also been configured to facilitate easier backporting of simulator and device simulation modules to run under the simh v3.9+ SCP framework.
This commit is contained in:
@@ -91,9 +91,9 @@ jmp_buf cpu_halt;
|
||||
t_stat cpu_examine (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw);
|
||||
t_stat cpu_deposit (t_value val, t_addr addr, UNIT *uptr, int32 sw);
|
||||
t_stat cpu_reset (DEVICE *dptr);
|
||||
t_stat cpu_req (UNIT *u, int32 val, char *cptr, void *desc);
|
||||
t_stat cpu_set_pult (UNIT *u, int32 val, char *cptr, void *desc);
|
||||
t_stat cpu_show_pult (FILE *st, UNIT *up, int32 v, void *dp);
|
||||
t_stat cpu_req (UNIT *u, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat cpu_set_pult (UNIT *u, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat cpu_show_pult (FILE *st, UNIT *up, int32 v, CONST void *dp);
|
||||
|
||||
|
||||
/*
|
||||
@@ -392,7 +392,7 @@ t_stat cpu_reset (DEVICE *dptr)
|
||||
/*
|
||||
* Request routine
|
||||
*/
|
||||
t_stat cpu_req (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat cpu_req (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
GRP |= GRP_PANEL_REQ;
|
||||
return SCPE_OK;
|
||||
@@ -401,7 +401,7 @@ t_stat cpu_req (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
/*
|
||||
* Hardwired program selector validation
|
||||
*/
|
||||
t_stat cpu_set_pult (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat cpu_set_pult (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
int sw;
|
||||
if (cptr) sw = atoi(cptr); else sw = 0;
|
||||
@@ -417,7 +417,7 @@ t_stat cpu_set_pult (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
return SCPE_ARG;
|
||||
}
|
||||
|
||||
t_stat cpu_show_pult (FILE *st, UNIT *up, int32 v, void *dp)
|
||||
t_stat cpu_show_pult (FILE *st, UNIT *up, int32 v, CONST void *dp)
|
||||
{
|
||||
fprintf(st, "Pult packet switch position is %d", pult_packet_switch);
|
||||
return SCPE_OK;
|
||||
|
||||
@@ -358,9 +358,9 @@ void besm6_debug (const char *fmt, ...);
|
||||
t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
|
||||
UNIT *uptr, int32 sw);
|
||||
void besm6_draw_panel (int force);
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, char *cptr, void *desc);
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, char *cptr, void *desc);
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, void *dp);
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, CONST void *dp);
|
||||
|
||||
/*
|
||||
* Арифметика.
|
||||
|
||||
@@ -123,7 +123,7 @@ MTAB disk_mod[] = {
|
||||
};
|
||||
|
||||
t_stat disk_reset (DEVICE *dptr);
|
||||
t_stat disk_attach (UNIT *uptr, char *cptr);
|
||||
t_stat disk_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat disk_detach (UNIT *uptr);
|
||||
|
||||
DEVICE disk_dev = {
|
||||
@@ -163,7 +163,7 @@ t_stat disk_reset (DEVICE *dptr)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_stat disk_attach (UNIT *u, char *cptr)
|
||||
t_stat disk_attach (UNIT *u, CONST char *cptr)
|
||||
{
|
||||
t_stat s;
|
||||
int32 saved_switches = sim_switches;
|
||||
@@ -174,7 +174,7 @@ t_stat disk_attach (UNIT *u, char *cptr)
|
||||
if ((s == SCPE_OK) && (sim_switches & SWMASK ('N'))) {
|
||||
t_value control[4]; /* block (zone) number, key, userid, checksum */
|
||||
int diskno, blkno, word;
|
||||
char *pos;
|
||||
const char *pos;
|
||||
/* Using the rightmost sequence of digits within the filename
|
||||
* as a volume number, e.g. "/var/tmp/besm6/2052.bin" -> 2052
|
||||
*/
|
||||
|
||||
@@ -82,7 +82,7 @@ MTAB drum_mod[] = {
|
||||
};
|
||||
|
||||
t_stat drum_reset (DEVICE *dptr);
|
||||
t_stat drum_attach (UNIT *uptr, char *cptr);
|
||||
t_stat drum_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat drum_detach (UNIT *uptr);
|
||||
|
||||
DEVICE drum_dev = {
|
||||
@@ -107,7 +107,7 @@ t_stat drum_reset (DEVICE *dptr)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_stat drum_attach (UNIT *u, char *cptr)
|
||||
t_stat drum_attach (UNIT *u, CONST char *cptr)
|
||||
{
|
||||
t_stat s;
|
||||
|
||||
|
||||
@@ -429,7 +429,7 @@ static void draw_brz_static (int left, int top)
|
||||
/*
|
||||
* Closing the graphical window.
|
||||
*/
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
if (! screen)
|
||||
return SCPE_NOTATT;
|
||||
@@ -441,7 +441,7 @@ t_stat besm6_close_panel (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, void *dp)
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, CONST void *dp)
|
||||
{
|
||||
if (screen)
|
||||
fprintf(st, "Panel displayed");
|
||||
@@ -459,7 +459,7 @@ static SDL_Texture *sdlTexture;
|
||||
/*
|
||||
* Initializing of the graphical window and the fonts.
|
||||
*/
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
if (screen)
|
||||
return SCPE_ALATT;
|
||||
@@ -678,17 +678,17 @@ void besm6_draw_panel (int force)
|
||||
#endif /* SDL_MAJOR_VERSION */
|
||||
|
||||
#else /* HAVE_LIBSDL */
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat besm6_init_panel (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
return sim_messagef(SCPE_OPENERR, "Need SDL and SDLttf libraries");
|
||||
}
|
||||
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat besm6_close_panel (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
return SCPE_NOTATT;
|
||||
}
|
||||
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, void *dp)
|
||||
t_stat besm6_show_panel (FILE *st, UNIT *up, int32 v, CONST void *dp)
|
||||
{
|
||||
return SCPE_NOTATT;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ MTAB printer_mod[] = {
|
||||
};
|
||||
|
||||
t_stat printer_reset (DEVICE *dptr);
|
||||
t_stat printer_attach (UNIT *uptr, char *cptr);
|
||||
t_stat printer_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat printer_detach (UNIT *uptr);
|
||||
|
||||
DEVICE printer_dev = {
|
||||
@@ -101,7 +101,7 @@ t_stat printer_reset (DEVICE *dptr)
|
||||
return SCPE_OK;
|
||||
}
|
||||
|
||||
t_stat printer_attach (UNIT *u, char *cptr)
|
||||
t_stat printer_attach (UNIT *u, CONST char *cptr)
|
||||
{
|
||||
t_stat s;
|
||||
int num = u - printer_unit;
|
||||
|
||||
@@ -75,7 +75,7 @@ MTAB fs_mod[] = {
|
||||
};
|
||||
|
||||
t_stat fs_reset (DEVICE *dptr);
|
||||
t_stat fs_attach (UNIT *uptr, char *cptr);
|
||||
t_stat fs_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat fs_detach (UNIT *uptr);
|
||||
|
||||
DEVICE fs_dev = {
|
||||
@@ -123,7 +123,7 @@ t_stat fs_reset (DEVICE *dptr)
|
||||
* Attaches a raw binary file by default,
|
||||
* with a -t switch attaches a prepared text file in UTF-8.
|
||||
*/
|
||||
t_stat fs_attach (UNIT *u, char *cptr)
|
||||
t_stat fs_attach (UNIT *u, CONST char *cptr)
|
||||
{
|
||||
t_stat s;
|
||||
int num = u - fs_unit;
|
||||
|
||||
@@ -239,7 +239,7 @@ double besm6_to_ieee (t_value word)
|
||||
/*
|
||||
* Пропуск пробелов.
|
||||
*/
|
||||
char *skip_spaces (char *p)
|
||||
CONST char *skip_spaces (CONST char *p)
|
||||
{
|
||||
for (;;) {
|
||||
if (*p == (char) 0xEF && p[1] == (char) 0xBB && p[2] == (char) 0xBF) {
|
||||
@@ -259,7 +259,7 @@ char *skip_spaces (char *p)
|
||||
* Fetch Unicode symbol from UTF-8 string.
|
||||
* Advance string pointer.
|
||||
*/
|
||||
int utf8_to_unicode (char **p)
|
||||
int utf8_to_unicode (CONST char **p)
|
||||
{
|
||||
int c1, c2, c3;
|
||||
|
||||
@@ -273,7 +273,7 @@ int utf8_to_unicode (char **p)
|
||||
return (c1 & 0x0f) << 12 | (c2 & 0x3f) << 6 | (c3 & 0x3f);
|
||||
}
|
||||
|
||||
char *besm6_parse_octal (char *cptr, int *offset)
|
||||
char *besm6_parse_octal (const char *cptr, int *offset)
|
||||
{
|
||||
char *eptr;
|
||||
|
||||
@@ -283,7 +283,7 @@ char *besm6_parse_octal (char *cptr, int *offset)
|
||||
return eptr;
|
||||
}
|
||||
|
||||
static char *get_alnum (char *iptr, char *optr)
|
||||
static CONST char *get_alnum (CONST char *iptr, char *optr)
|
||||
{
|
||||
while ((*iptr >= 'a' && *iptr<='z') ||
|
||||
(*iptr >= 'A' && *iptr<='Z') ||
|
||||
@@ -298,7 +298,7 @@ static char *get_alnum (char *iptr, char *optr)
|
||||
* Parse single instruction (half word).
|
||||
* Allow mnemonics or octal code.
|
||||
*/
|
||||
char *parse_instruction (char *cptr, uint32 *val)
|
||||
CONST char *parse_instruction (CONST char *cptr, uint32 *val)
|
||||
{
|
||||
int opcode, reg, addr, negate;
|
||||
char gbuf[CBUFSIZE];
|
||||
@@ -391,7 +391,7 @@ char *parse_instruction (char *cptr, uint32 *val)
|
||||
/*
|
||||
* Instruction parse: two commands per word.
|
||||
*/
|
||||
t_stat parse_instruction_word (char *cptr, t_value *val)
|
||||
t_stat parse_instruction_word (CONST char *cptr, t_value *val)
|
||||
{
|
||||
uint32 left, right;
|
||||
|
||||
@@ -535,7 +535,7 @@ t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
|
||||
* Outputs:
|
||||
* status = error status
|
||||
*/
|
||||
t_stat parse_sym (char *cptr, t_addr addr, UNIT *uptr, t_value *val, int32 sw)
|
||||
t_stat parse_sym (CONST char *cptr, t_addr addr, UNIT *uptr, t_value *val, int32 sw)
|
||||
{
|
||||
int32 i;
|
||||
|
||||
@@ -569,7 +569,8 @@ t_stat parse_sym (char *cptr, t_addr addr, UNIT *uptr, t_value *val, int32 sw)
|
||||
*/
|
||||
t_stat besm6_read_line (FILE *input, int *type, t_value *val)
|
||||
{
|
||||
char buf [512], *p;
|
||||
char buf [512];
|
||||
CONST char *p;
|
||||
int i, c;
|
||||
again:
|
||||
if (! fgets (buf, sizeof (buf), input)) {
|
||||
@@ -685,7 +686,7 @@ t_stat besm6_load (FILE *input)
|
||||
/*
|
||||
* Dump memory to file.
|
||||
*/
|
||||
t_stat besm6_dump (FILE *of, char *fnam)
|
||||
t_stat besm6_dump (FILE *of, const char *fnam)
|
||||
{
|
||||
int addr, last_addr = -1;
|
||||
t_value word;
|
||||
@@ -728,7 +729,7 @@ t_stat besm6_dump (FILE *of, char *fnam)
|
||||
/*
|
||||
* Loader/dumper
|
||||
*/
|
||||
t_stat sim_load (FILE *fi, char *cptr, char *fnam, int dump_flag)
|
||||
t_stat sim_load (FILE *fi, CONST char *cptr, CONST char *fnam, int dump_flag)
|
||||
{
|
||||
if (dump_flag)
|
||||
return besm6_dump (fi, fnam);
|
||||
|
||||
@@ -94,7 +94,7 @@ char *vt_cptr [LINES_MAX+1];
|
||||
void tt_print();
|
||||
void consul_receive();
|
||||
t_stat vt_clk(UNIT *);
|
||||
extern char *get_sim_sw (char *cptr);
|
||||
extern const char *get_sim_sw (const char *cptr);
|
||||
extern int32 tmr_poll; /* calibrated clock timer poll */
|
||||
|
||||
int attached_console;
|
||||
@@ -260,7 +260,7 @@ t_stat vt_clk (UNIT * this)
|
||||
return sim_activate(this, 1000*MSEC/300);
|
||||
}
|
||||
|
||||
t_stat tty_setmode (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
t_stat tty_setmode (UNIT *u, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
int num = u - tty_unit;
|
||||
TMLN *t = &tty_line [num];
|
||||
@@ -315,7 +315,7 @@ t_stat tty_setmode (UNIT *u, int32 val, char *cptr, void *desc)
|
||||
* attach tty <port>
|
||||
* Where <port> is the port number for telnet, e.g. 4199.
|
||||
*/
|
||||
t_stat tty_attach (UNIT *u, char *cptr)
|
||||
t_stat tty_attach (UNIT *u, CONST char *cptr)
|
||||
{
|
||||
int num = u - tty_unit;
|
||||
char gbuf[CBUFSIZE];
|
||||
@@ -462,7 +462,7 @@ void vt_puts (int num, const char *s)
|
||||
return;
|
||||
if (t->rcve) {
|
||||
/* A telnet connection. */
|
||||
tmxr_linemsg (t, (char*) s);
|
||||
tmxr_linemsg (t, s);
|
||||
} else {
|
||||
/* Console output. */
|
||||
while (*s) sim_putchar(*s++);
|
||||
@@ -686,12 +686,12 @@ static int unicode_to_koi7 (unsigned val)
|
||||
/*
|
||||
* Set command
|
||||
*/
|
||||
static t_stat cmd_set (int32 num, char *cptr)
|
||||
static t_stat cmd_set (int32 num, CONST char *cptr)
|
||||
{
|
||||
char gbuf [CBUFSIZE];
|
||||
int len;
|
||||
|
||||
cptr = get_sim_sw (cptr);
|
||||
cptr = (CONST char *)get_sim_sw (cptr);
|
||||
if (! cptr)
|
||||
return SCPE_INVSW;
|
||||
if (! *cptr)
|
||||
@@ -734,14 +734,14 @@ static t_stat cmd_set (int32 num, char *cptr)
|
||||
/*
|
||||
* Show command
|
||||
*/
|
||||
static t_stat cmd_show (int32 num, char *cptr)
|
||||
static t_stat cmd_show (int32 num, CONST char *cptr)
|
||||
{
|
||||
TMLN *t = &tty_line [num];
|
||||
char gbuf [CBUFSIZE];
|
||||
MTAB *m;
|
||||
int len;
|
||||
|
||||
cptr = get_sim_sw (cptr);
|
||||
cptr = (CONST char *)get_sim_sw (cptr);
|
||||
if (! cptr)
|
||||
return SCPE_INVSW;
|
||||
if (! *cptr) {
|
||||
@@ -779,12 +779,12 @@ static t_stat cmd_show (int32 num, char *cptr)
|
||||
/*
|
||||
* Exit command
|
||||
*/
|
||||
static t_stat cmd_exit (int32 num, char *cptr)
|
||||
static t_stat cmd_exit (int32 num, CONST char *cptr)
|
||||
{
|
||||
return SCPE_EXIT;
|
||||
}
|
||||
|
||||
static t_stat cmd_help (int32 num, char *cptr);
|
||||
static t_stat cmd_help (int32 num, CONST char *cptr);
|
||||
|
||||
static CTAB cmd_table[] = {
|
||||
{ "SET", &cmd_set, 0,
|
||||
@@ -834,13 +834,13 @@ static CTAB *lookup_cmd (char *command)
|
||||
/*
|
||||
* Help command
|
||||
*/
|
||||
static t_stat cmd_help (int32 num, char *cptr)
|
||||
static t_stat cmd_help (int32 num, CONST char *cptr)
|
||||
{
|
||||
TMLN *t = &tty_line [num];
|
||||
char gbuf [CBUFSIZE];
|
||||
CTAB *c;
|
||||
|
||||
cptr = get_sim_sw (cptr);
|
||||
cptr = (CONST char *)get_sim_sw (cptr);
|
||||
if (! cptr)
|
||||
return SCPE_INVSW;
|
||||
if (! *cptr) {
|
||||
@@ -868,7 +868,8 @@ static t_stat cmd_help (int32 num, char *cptr)
|
||||
void vt_cmd_exec (int num)
|
||||
{
|
||||
TMLN *t = &tty_line [num];
|
||||
char *cptr, gbuf [CBUFSIZE];
|
||||
char gbuf [CBUFSIZE];
|
||||
CONST char *cptr;
|
||||
CTAB *cmdp;
|
||||
t_stat err;
|
||||
extern char *scp_errors[];
|
||||
|
||||
Reference in New Issue
Block a user