mirror of
https://github.com/simh/simh.git
synced 2026-01-25 11:46:37 +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:
@@ -199,10 +199,10 @@ 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_bool cpu_is_pc_a_subroutine_call (t_addr **ret_addrs);
|
||||
t_stat cpu_set_size (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
t_stat cpu_set_type (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_size (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat cpu_set_type (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 Ea (uint32 wd, uint32 *va);
|
||||
t_stat EaSh (uint32 wd, uint32 *va);
|
||||
t_stat Read (uint32 va, uint32 *dat);
|
||||
@@ -221,8 +221,8 @@ void inst_hist (uint32 inst, uint32 pc, uint32 typ);
|
||||
t_stat rtc_inst (uint32 inst);
|
||||
t_stat rtc_svc (UNIT *uptr);
|
||||
t_stat rtc_reset (DEVICE *dptr);
|
||||
t_stat rtc_set_freq (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
t_stat rtc_show_freq (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat rtc_set_freq (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat rtc_show_freq (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||||
|
||||
extern t_bool io_init (void);
|
||||
extern t_stat op_wyim (uint32 inst, uint32 *dat);
|
||||
@@ -1682,7 +1682,7 @@ return SCPE_OK;
|
||||
|
||||
/* Set memory size */
|
||||
|
||||
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;
|
||||
@@ -1701,7 +1701,7 @@ return SCPE_OK;
|
||||
|
||||
/* Set system type (1 = Genie, 0 = standard) */
|
||||
|
||||
t_stat cpu_set_type (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||||
t_stat cpu_set_type (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
extern t_stat drm_reset (DEVICE *dptr);
|
||||
extern DEVICE drm_dev, mux_dev, muxl_dev;
|
||||
@@ -1779,7 +1779,7 @@ return SCPE_OK;
|
||||
|
||||
/* Set frequency */
|
||||
|
||||
t_stat rtc_set_freq (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||||
t_stat rtc_set_freq (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
if (cptr)
|
||||
return SCPE_ARG;
|
||||
@@ -1791,7 +1791,7 @@ return SCPE_OK;
|
||||
|
||||
/* Show frequency */
|
||||
|
||||
t_stat rtc_show_freq (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
t_stat rtc_show_freq (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
|
||||
{
|
||||
fprintf (st, (rtc_tps == 50)? "50Hz": "60Hz");
|
||||
return SCPE_OK;
|
||||
@@ -1818,7 +1818,7 @@ return;
|
||||
|
||||
/* 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;
|
||||
@@ -1857,15 +1857,15 @@ 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 ov, k, di, lnt;
|
||||
char *cptr = (char *) desc;
|
||||
const char *cptr = (const char *) desc;
|
||||
t_stat r;
|
||||
t_value sim_eval;
|
||||
InstHistory *h;
|
||||
static char *cyc[] = { " ", " ", "INT", "TRP" };
|
||||
static char *modes = "NMU?";
|
||||
static const char *cyc[] = { " ", " ", "INT", "TRP" };
|
||||
static const char *modes = "NMU?";
|
||||
|
||||
if (hst_lnt == 0) /* enabled? */
|
||||
return SCPE_NOFNC;
|
||||
|
||||
@@ -418,9 +418,13 @@ void chan_set_flag (int32 ch, uint32 fl);
|
||||
void chan_set_ordy (int32 ch);
|
||||
void chan_disc (int32 ch);
|
||||
void chan_set_uar (int32 ch, uint32 dev);
|
||||
t_stat set_chan (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
t_stat show_chan (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat set_chan (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
t_stat show_chan (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||||
t_stat chan_process (void);
|
||||
t_bool chan_testact (void);
|
||||
|
||||
/* Translation tables */
|
||||
extern const int8 odd_par[64];
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -105,7 +105,6 @@ int32 drm_ftime = 3; /* time to fetch */
|
||||
int32 drm_xtime = 1; /* time to xfr */
|
||||
int32 drm_stopioe = 1; /* stop on error */
|
||||
|
||||
DEVICE drm_dev;
|
||||
t_stat drm (uint32 fnc, uint32 inst, uint32 *dat);
|
||||
t_stat drm_svc (UNIT *uptr);
|
||||
t_stat drm_reset (DEVICE *dptr);
|
||||
|
||||
@@ -87,7 +87,6 @@ DSPT dsk_tplt[] = { /* template */
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
DEVICE dsk_dev;
|
||||
t_stat dsk_svc (UNIT *uptr);
|
||||
t_stat dsk_reset (DEVICE *dptr);
|
||||
t_stat dsk_fill (uint32 dev);
|
||||
|
||||
12
SDS/sds_io.c
12
SDS/sds_io.c
@@ -149,7 +149,7 @@ extern void set_dyn_map (void);
|
||||
support all widths.
|
||||
*/
|
||||
|
||||
t_stat chan_show_reg (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat chan_show_reg (FILE *st, UNIT *uptr, int32 val, CONST void *desc);
|
||||
|
||||
struct aldisp {
|
||||
t_stat (*pin) (uint32 num, uint32 *dat); /* altnum, *dat */
|
||||
@@ -222,11 +222,11 @@ uint32 dev_map[64][NUM_CHAN];
|
||||
|
||||
/* dev_dsp maps device and channel numbers to dispatch routines */
|
||||
|
||||
t_stat (*dev_dsp[64][NUM_CHAN])() = { {NULL} };
|
||||
t_stat (*dev_dsp[64][NUM_CHAN])(uint32 fnc, uint32 dev, uint32 *dat) = { {NULL} };
|
||||
|
||||
/* dev3_dsp maps system device numbers to dispatch routines */
|
||||
|
||||
t_stat (*dev3_dsp[64])() = { NULL };
|
||||
t_stat (*dev3_dsp[64])(uint32 fnc, uint32 dev, uint32 *dat) = { NULL };
|
||||
|
||||
/* dev_alt maps alert numbers to dispatch routines */
|
||||
|
||||
@@ -902,7 +902,7 @@ return SCPE_OK;
|
||||
|
||||
/* Channel assignment routines */
|
||||
|
||||
t_stat set_chan (UNIT *uptr, int32 val, char *sptr, void *desc)
|
||||
t_stat set_chan (UNIT *uptr, int32 val, CONST char *sptr, void *desc)
|
||||
{
|
||||
DEVICE *dptr;
|
||||
DIB *dibp;
|
||||
@@ -929,7 +929,7 @@ for (i = 0; i < NUM_CHAN; i++) { /* match input */
|
||||
return SCPE_ARG;
|
||||
}
|
||||
|
||||
t_stat show_chan (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
t_stat show_chan (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
|
||||
{
|
||||
DEVICE *dptr;
|
||||
DIB *dibp;
|
||||
@@ -997,7 +997,7 @@ return FALSE;
|
||||
|
||||
/* Display channel state */
|
||||
|
||||
t_stat chan_show_reg (FILE *st, UNIT *uptr, int32 val, void *desc)
|
||||
t_stat chan_show_reg (FILE *st, UNIT *uptr, int32 val, CONST void *desc)
|
||||
{
|
||||
if ((val < 0) || (val >= NUM_CHAN)) return SCPE_IERR;
|
||||
fprintf (st, "UAR: %02o\n", chan_uar[val]);
|
||||
|
||||
@@ -58,10 +58,9 @@ DSPT lpt_tplt[] = { /* template */
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
DEVICE lpt_dev;
|
||||
t_stat lpt_svc (UNIT *uptr);
|
||||
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 lpt_crctl (UNIT *uptr, int32 ch);
|
||||
t_stat lpt_space (UNIT *uptr, int32 cnt);
|
||||
t_stat lpt_status (UNIT *uptr);
|
||||
@@ -324,7 +323,7 @@ return SCPE_OK;
|
||||
|
||||
/* Attach routine */
|
||||
|
||||
t_stat lpt_attach (UNIT *uptr, char *cptr)
|
||||
t_stat lpt_attach (UNIT *uptr, CONST char *cptr)
|
||||
{
|
||||
lpt_ccp = 0; /* top of form */
|
||||
return attach_unit (uptr, cptr);
|
||||
|
||||
@@ -77,11 +77,10 @@ DSPT mt_tplt[] = { /* template */
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
DEVICE mt_dev;
|
||||
t_stat mt_svc (UNIT *uptr);
|
||||
t_stat mt_reset (DEVICE *dptr);
|
||||
t_stat mt_boot (int32 unitno, DEVICE *dptr);
|
||||
t_stat mt_attach (UNIT *uptr, char *cptr);
|
||||
t_stat mt_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat mt_detach (UNIT *uptr);
|
||||
t_stat mt_readrec (UNIT *uptr);
|
||||
t_mtrlnt mt_readbc (UNIT *uptr);
|
||||
@@ -468,7 +467,7 @@ return SCPE_OK;
|
||||
|
||||
/* Attach and detach routines */
|
||||
|
||||
t_stat mt_attach (UNIT *uptr, char *cptr)
|
||||
t_stat mt_attach (UNIT *uptr, CONST char *cptr)
|
||||
{
|
||||
t_stat r;
|
||||
|
||||
|
||||
@@ -120,11 +120,11 @@ t_stat mux (uint32 fnc, uint32 inst, uint32 *dat);
|
||||
t_stat muxi_svc (UNIT *uptr);
|
||||
t_stat muxo_svc (UNIT *uptr);
|
||||
t_stat mux_reset (DEVICE *dptr);
|
||||
t_stat mux_attach (UNIT *uptr, char *cptr);
|
||||
t_stat mux_attach (UNIT *uptr, CONST char *cptr);
|
||||
t_stat mux_detach (UNIT *uptr);
|
||||
t_stat mux_summ (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat mux_show (FILE *st, UNIT *uptr, int32 val, void *desc);
|
||||
t_stat mux_vlines (UNIT *uptr, int32 val, char *cptr, void *desc);
|
||||
t_stat mux_summ (FILE *st, UNIT *uptr, int32 val, const void *desc);
|
||||
t_stat mux_show (FILE *st, UNIT *uptr, int32 val, const void *desc);
|
||||
t_stat mux_vlines (UNIT *uptr, int32 val, CONST char *cptr, void *desc);
|
||||
void mux_reset_ln (int32 ln);
|
||||
void mux_scan_next (void);
|
||||
|
||||
@@ -479,7 +479,7 @@ return SCPE_OK;
|
||||
|
||||
/* Attach master unit */
|
||||
|
||||
t_stat mux_attach (UNIT *uptr, char *cptr)
|
||||
t_stat mux_attach (UNIT *uptr, CONST char *cptr)
|
||||
{
|
||||
t_stat r;
|
||||
int32 t;
|
||||
@@ -508,7 +508,7 @@ return r;
|
||||
|
||||
/* Change number of lines */
|
||||
|
||||
t_stat mux_vlines (UNIT *uptr, int32 val, char *cptr, void *desc)
|
||||
t_stat mux_vlines (UNIT *uptr, int32 val, CONST char *cptr, void *desc)
|
||||
{
|
||||
int32 newln, i, t;
|
||||
t_stat r;
|
||||
|
||||
@@ -67,7 +67,6 @@ DSPT rad_tplt[] = { /* template */
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
DEVICE rad_dev;
|
||||
t_stat rad_svc (UNIT *uptr);
|
||||
t_stat rad_reset (DEVICE *dptr);
|
||||
t_stat rad_boot (int32 unitno, DEVICE *dptr);
|
||||
@@ -133,7 +132,7 @@ t_stat rad (uint32 fnc, uint32 inst, uint32 *dat)
|
||||
{
|
||||
int32 t, lun, new_ch;
|
||||
uint32 p;
|
||||
uint32 *fbuf = rad_unit.filebuf;
|
||||
uint32 *fbuf = (uint32 *)rad_unit.filebuf;
|
||||
|
||||
switch (fnc) { /* case function */
|
||||
|
||||
@@ -267,7 +266,7 @@ return SCPE_OK;
|
||||
t_stat rad_fill (int32 sba)
|
||||
{
|
||||
uint32 p = rad_da * RAD_NUMWD;
|
||||
uint32 *fbuf = rad_unit.filebuf;
|
||||
uint32 *fbuf = (uint32 *)rad_unit.filebuf;
|
||||
int32 wa = (sba + 1) >> 1; /* whole words */
|
||||
|
||||
if (sba && (p < rad_unit.capac)) { /* fill needed? */
|
||||
|
||||
@@ -47,7 +47,6 @@ int32 ptp_ldr = 0; /* no leader */
|
||||
int32 ptp_stopioe = 1;
|
||||
DSPT std_tplt[] = { { 1, 0 }, { 0, 0 } }; /* template */
|
||||
|
||||
DEVICE ptr_dev, ptp_dev;
|
||||
t_stat ptr (uint32 fnc, uint32 inst, uint32 *dat);
|
||||
t_stat ptr_svc (UNIT *uptr);
|
||||
t_stat ptr_reset (DEVICE *dptr);
|
||||
@@ -66,7 +65,6 @@ t_stat tto_svc (UNIT *uptr);
|
||||
t_stat tto_reset (DEVICE *dptr);
|
||||
int8 ascii_to_sds(int8 ch);
|
||||
int8 sds_to_ascii(int8 ch);
|
||||
extern const int8 odd_par[64];
|
||||
|
||||
/* PTR data structures
|
||||
|
||||
|
||||
@@ -196,7 +196,8 @@ int32 col, rpt, ptr, mask, cctbuf[CCT_LNT];
|
||||
t_stat r;
|
||||
extern int32 lpt_ccl, lpt_ccp;
|
||||
extern uint8 lpt_cct[CCT_LNT];
|
||||
char *cptr, cbuf[CBUFSIZE], gbuf[CBUFSIZE];
|
||||
const char *cptr;
|
||||
char cbuf[CBUFSIZE], gbuf[CBUFSIZE];
|
||||
|
||||
ptr = 0;
|
||||
for ( ; (cptr = fgets (cbuf, CBUFSIZE, fileref)) != NULL; ) { /* until eof */
|
||||
@@ -251,7 +252,7 @@ for (i = wd = 0; i < 4; ) {
|
||||
return wd;
|
||||
}
|
||||
|
||||
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 i, wd, buf[8];
|
||||
int32 ldr = 1;
|
||||
@@ -634,9 +635,10 @@ return SCPE_ARG;
|
||||
cptr = updated pointer to input string
|
||||
*/
|
||||
|
||||
char *get_tag (char *cptr, t_value *tag)
|
||||
CONST char *get_tag (CONST char *cptr, t_value *tag)
|
||||
{
|
||||
char *tptr, gbuf[CBUFSIZE];
|
||||
CONST char *tptr;
|
||||
char gbuf[CBUFSIZE];
|
||||
t_stat r;
|
||||
|
||||
tptr = get_glyph (cptr, gbuf, 0); /* get next field */
|
||||
@@ -659,20 +661,17 @@ return cptr; /* no change */
|
||||
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, j, k, ch;
|
||||
t_value d, tag;
|
||||
t_stat r;
|
||||
char gbuf[CBUFSIZE];
|
||||
char gbuf[CBUFSIZE], cbuf[2*CBUFSIZE];
|
||||
|
||||
while (isspace (*cptr)) cptr++;
|
||||
for (i = 1; (i < 4) && (cptr[i] != 0); i++) {
|
||||
if (cptr[i] == 0) {
|
||||
for (j = i + 1; j <= 4; j++)
|
||||
cptr[j] = 0;
|
||||
}
|
||||
}
|
||||
memset (cbuf, '\0', sizeof(cbuf));
|
||||
strncpy (cbuf, cptr, sizeof(cbuf)-5);
|
||||
cptr = cbuf;
|
||||
if ((sw & SWMASK ('A')) || ((*cptr == '\'') && cptr++)) { /* ASCII char? */
|
||||
if (cptr[0] == 0) /* must have 1 char */
|
||||
return SCPE_ARG;
|
||||
|
||||
Reference in New Issue
Block a user