1
0
mirror of https://github.com/simh/simh.git synced 2026-04-15 16:11:13 +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:
Mark Pizzolato
2016-05-15 15:25:33 -07:00
parent 60a8a2d43d
commit 5531ccb175
444 changed files with 4119 additions and 3798 deletions

View File

@@ -105,19 +105,19 @@ int32 cdp_buf_full = 0; /* punch buf full? */
t_stat cdr_svc (UNIT *uptr);
t_stat cdr_boot (int32 unitno, DEVICE *dptr);
t_stat cdr_attach (UNIT *uptr, char *cptr);
t_stat cdr_attach (UNIT *uptr, CONST char *cptr);
t_stat cdr_detach (UNIT *uptr);
t_stat cdp_attach (UNIT *uptr, char *cptr);
t_stat cdp_attach (UNIT *uptr, CONST char *cptr);
t_stat cdp_detach (UNIT *uptr);
t_stat cdp_npr (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat cdp_npr (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat cd_reset (DEVICE *dptr);
t_stat cdr_read_file (char *buf, int32 sz);
t_stat cdr_read_cons (char *buf, int32 sz);
t_stat cdr_chg_cons (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat cdr_chg_cons (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
int32 bcd2asc (int32 c, UNIT *uptr);
char colbin_to_bcd (uint32 cb);
extern void inq_puts (char *cptr);
extern void inq_puts (const char *cptr);
/* Card reader data structures
@@ -358,7 +358,7 @@ return SCPE_OK;
/* Punch buffered card (also handles non-process runout button) */
t_stat cdp_npr (UNIT *notused, int32 val, char *cptr, void *desc)
t_stat cdp_npr (UNIT *notused, int32 val, CONST char *cptr, void *desc)
{
UNIT *uptr;
@@ -477,7 +477,7 @@ return SCPE_OK;
Caller will do actual bit field update on successful return */
t_stat cdr_chg_cons (UNIT *uptr, int32 val, char *cptr, void *desc)
t_stat cdr_chg_cons (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
if (val == 0) /* clear? */
cdr_unit.flags |= UNIT_ATTABLE; /* attachable on */
@@ -488,7 +488,7 @@ return SCPE_OK;
/* Card reader attach */
t_stat cdr_attach (UNIT *uptr, char *cptr)
t_stat cdr_attach (UNIT *uptr, CONST char *cptr)
{
t_stat r;
@@ -538,7 +538,7 @@ return SCPE_OK;
/* Card punch attach */
t_stat cdp_attach (UNIT *uptr, char *cptr)
t_stat cdp_attach (UNIT *uptr, CONST char *cptr)
{
cdp_buf_full = 0;
return attach_unit (uptr, cptr);

View File

@@ -211,11 +211,11 @@ extern int32 sim_emax;
t_stat cpu_ex (t_value *vptr, t_addr addr, UNIT *uptr, int32 sw);
t_stat cpu_dep (t_value val, t_addr addr, UNIT *uptr, int32 sw);
t_stat cpu_reset (DEVICE *dptr);
t_stat cpu_set_size (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat cpu_set_hist (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat cpu_show_hist (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat cpu_set_conv (UNIT *uptr, int32 val, char *cptr, void *desc);
t_stat cpu_show_conv (FILE *st, UNIT *uptr, int32 val, void *desc);
t_stat cpu_set_size (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat cpu_set_hist (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat cpu_show_hist (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
t_stat cpu_set_conv (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
t_stat cpu_show_conv (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
int32 store_addr_h (int32 addr);
int32 store_addr_t (int32 addr);
int32 store_addr_u (int32 addr);
@@ -1852,7 +1852,7 @@ return SCPE_OK;
/* Memory size change */
t_stat cpu_set_size (UNIT *uptr, int32 val, char *cptr, void *desc)
t_stat cpu_set_size (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
int32 mc = 0;
uint32 i;
@@ -1874,7 +1874,7 @@ return SCPE_OK;
/* Set history */
t_stat cpu_set_hist (UNIT *uptr, int32 val, char *cptr, void *desc)
t_stat cpu_set_hist (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
int32 i, lnt;
t_stat r;
@@ -1905,10 +1905,10 @@ return SCPE_OK;
/* Show history */
t_stat cpu_show_hist (FILE *st, UNIT *uptr, int32 val, void *desc)
t_stat cpu_show_hist (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
{
int32 i, k, di, lnt;
char *cptr = (char *) desc;
const char *cptr = (const char *) desc;
t_value sim_eval[MAX_L + 1];
t_stat r;
InstHistory *h;
@@ -1945,7 +1945,7 @@ return SCPE_OK;
/* Set conversions */
t_stat cpu_set_conv (UNIT *uptr, int32 val, char *cptr, void *desc)
t_stat cpu_set_conv (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
{
conv_old = val;
return SCPE_OK;
@@ -1953,7 +1953,7 @@ return SCPE_OK;
/* Show conversions */
t_stat cpu_show_conv (FILE *st, UNIT *uptr, int32 val, void *desc)
t_stat cpu_show_conv (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
{
if (conv_old)
fputs ("Old (pre-3.5-1) conversions\n", st);

View File

@@ -300,5 +300,23 @@
int32 bcd2ascii (int32 c, t_bool use_h);
int32 ascii2bcd (int32 c);
/* Translation Tables */
extern const char ascii_to_bcd_old[128];
extern char bcd_to_ascii_old[64];
extern const char ascii_to_bcd[128];
extern const char bcd_to_ascii_a[64];
extern const char bcd_to_ascii_h[64];
extern const char bcd_to_pca[64];
extern const char bcd_to_pch[64];
extern const uint32 bcd_to_colbin[64];
extern const int32 bcd_to_bin[16];
extern const int32 bin_to_bcd[16];
extern const int32 one_table[64];
extern const int32 ten_table[64];
extern const int32 hun_table[64];
extern const int32 len_table[9];
extern const int32 op_table[64];
#endif

View File

@@ -94,8 +94,8 @@
extern uint8 M[]; /* memory */
extern int32 ind[64];
extern int32 AS, BS, iochk;
extern int32 bcd_to_bin[16];
extern int32 bin_to_bcd[16];
extern const int32 bcd_to_bin[16];
extern const int32 bin_to_bcd[16];
extern UNIT cpu_unit;
int32 dp_lastf = 0; /* prior function */

View File

@@ -48,7 +48,7 @@ int32 inq_char = 033; /* request inq */
t_stat inq_svc (UNIT *uptr);
t_stat inq_reset (DEVICE *dptr);
void inq_puts (char *cptr);
void inq_puts (const char *cptr);
/* INQ data structures
@@ -180,7 +180,7 @@ return SCPE_OK;
/* Output multiple characters */
void inq_puts (char *cptr)
void inq_puts (const char *cptr)
{
if (cptr == NULL)
return;

View File

@@ -37,9 +37,6 @@
#include "i1401_defs.h"
extern uint8 M[];
extern char bcd_to_ascii_old[64];
extern char bcd_to_ascii_a[64], bcd_to_ascii_h[64];
extern char bcd_to_pca[64], bcd_to_pch[64];
extern int32 iochk, ind[64];
extern t_bool conv_old;
@@ -47,16 +44,16 @@ int32 cct[CCT_LNT] = { 03 };
int32 cctlnt = 66, cctptr = 0, lines = 0, lflag = 0;
t_stat lpt_reset (DEVICE *dptr);
t_stat lpt_attach (UNIT *uptr, char *cptr);
t_stat lpt_attach (UNIT *uptr, CONST char *cptr);
t_stat space (int32 lines, int32 lflag);
t_stat lpt_puts (char *buf);
t_stat lpt_puts (const char *buf);
extern void inq_puts (char *buf);
extern void inq_puts (const char *buf);
char *pch_table_old[4] = {
const char *pch_table_old[4] = {
bcd_to_ascii_old, bcd_to_ascii_old, bcd_to_pca, bcd_to_pch
};
char *pch_table[4] = {
const char *pch_table[4] = {
bcd_to_ascii_a, bcd_to_ascii_h, bcd_to_pca, bcd_to_pch
};
@@ -120,7 +117,7 @@ DEVICE lpt_dev = {
t_stat write_line (int32 ilnt, int32 mod)
{
int32 i, t, wm, sup;
char *bcd2asc;
const char *bcd2asc;
t_stat r;
static char lbuf[LPT_WIDTH + 1]; /* + null */
@@ -240,7 +237,7 @@ return r;
Note that if printing to the console, newline must be converted to crlf */
t_stat lpt_puts (char *buf)
t_stat lpt_puts (const char *buf)
{
if ((lpt_unit.flags & UNIT_ATT) != 0) { /* attached? */
fputs (buf, lpt_unit.fileref); /* print string */
@@ -278,7 +275,7 @@ return SCPE_OK;
/* Attach routine */
t_stat lpt_attach (UNIT *uptr, char *cptr)
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
{
cctptr = 0; /* clear cct ptr */
lines = 0; /* no cc action */

View File

@@ -50,8 +50,6 @@ extern DEVICE dp_dev, mt_dev;
extern UNIT cpu_unit;
extern REG cpu_reg[];
extern uint8 M[];
extern char ascii_to_bcd_old[128], ascii_to_bcd[128];
extern char bcd_to_ascii_old[64], bcd_to_ascii_a[64], bcd_to_ascii_h[64];
extern int32 store_addr_h (int32 addr);
extern int32 store_addr_t (int32 addr);
extern int32 store_addr_u (int32 addr);
@@ -126,7 +124,7 @@ const char *sim_stop_messages[] = {
number of entries
*/
t_stat sim_load (FILE *fileref, char *cptr, char *fnam, int flag)
t_stat sim_load (FILE *fileref, CONST char *cptr, CONST char *fnam, int flag)
{
int32 col, rpt, ptr, mask, cctbuf[CCT_LNT];
t_stat r;
@@ -190,7 +188,6 @@ const char *opcode[64] = {
void fprint_addr (FILE *of, t_value *dig)
{
int32 addr, xa;
extern int32 hun_table[64], ten_table[64], one_table[64];
addr = hun_table[dig[0] & CHAR] + ten_table[dig[1]] + one_table[dig[2]];
xa = (addr >> V_INDEX) & M_INDEX;
@@ -240,7 +237,6 @@ t_stat fprint_sym (FILE *of, t_addr addr, t_value *val,
int32 op, flags, ilnt, i, t;
int32 wmch = conv_old? '~': '`';
t_bool use_h = sw & SWMASK ('F');
extern int32 op_table[64], len_table[9];
if (sw & SWMASK ('C')) { /* character? */
t = val[0];
@@ -314,7 +310,7 @@ return -(ilnt - 1); /* return # chars */
/* get_addr - get address + index pair */
t_stat get_addr (char *cptr, t_value *val)
t_stat get_addr (const char *cptr, t_value *val)
{
int32 addr, index;
t_stat r;
@@ -365,11 +361,10 @@ return SCPE_OK;
<= 0 -number of extra words
*/
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, op, ilnt, t, cflag, wm_seen;
int32 wmch = conv_old? '~': '`';
extern int32 op_table[64], len_table[9];
char gbuf[CBUFSIZE];
cflag = (uptr == NULL) || (uptr == &cpu_unit);