1
0
mirror of https://github.com/simh/simh.git synced 2026-01-25 19:56:25 +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

@@ -148,7 +148,7 @@ static pascal OSStatus doKbdEvent ( EventHandlerCallRef handlerRef,
return (noErr);
}
int ws_init ( char *crtname, /* crt type name */
int ws_init ( const char *crtname, /* crt type name */
int xp, /* screen size in pixels */
int yp,
int colors, /* colors to support (not used) */

View File

@@ -98,7 +98,7 @@ struct color {
struct display {
enum display_type type;
char *name;
const char *name;
struct color *color0, *color1;
short xpoints, ypoints;
};

View File

@@ -57,7 +57,7 @@ int ws_lp_y = -1;
static int xpixels, ypixels;
static int pix_size = PIX_SIZE;
static char *window_name;
static const char *window_name;
static uint32 *colors = NULL;
static uint32 ncolors = 0, size_colors = 0;
static uint32 *surface = NULL;
@@ -281,7 +281,7 @@ for (row=0; row<height; ++row) {
}
}
}
result = calloc (1, sizeof(*result));
result = (CURSOR *)calloc (1, sizeof(*result));
if (result) {
result->data = data;
result->mask = mask;
@@ -308,7 +308,7 @@ free (cursor);
/* called from display layer on first display op */
int
ws_init(char *name, int xp, int yp, int colors, void *dptr)
ws_init(const char *name, int xp, int yp, int colors, void *dptr)
{
int i;
int ret;
@@ -318,10 +318,10 @@ ws_init(char *name, int xp, int yp, int colors, void *dptr)
xpixels = xp;
ypixels = yp;
window_name = name;
surface = realloc (surface, xpixels*ypixels*sizeof(*surface));
surface = (uint32 *)realloc (surface, xpixels*ypixels*sizeof(*surface));
for (i=0; i<xpixels*ypixels; i++)
surface[i] = vid_mono_palette[0];
ret = (0 == vid_open (dptr, name, xp*pix_size, yp*pix_size, 0));
ret = (0 == vid_open ((DEVICE *)dptr, name, xp*pix_size, yp*pix_size, 0));
if (ret)
vid_set_cursor (1, arrow_cursor->width, arrow_cursor->height, arrow_cursor->data, arrow_cursor->mask, arrow_cursor->hot_x, arrow_cursor->hot_y);
return ret;
@@ -346,7 +346,7 @@ ws_color_rgb(int r, int g, int b)
return &colors[i];
}
if (ncolors == size_colors) {
colors = realloc (colors, (ncolors + 1000) * sizeof (*colors));
colors = (uint32 *)realloc (colors, (ncolors + 1000) * sizeof (*colors));
size_colors += 1000;
if (size_colors == 1000) {
colors[0] = vid_mono_palette[0];
@@ -382,7 +382,7 @@ ws_display_point(int x, int y, void *color)
y = ypixels - 1 - y; /* invert y, top left origin */
if (brush == NULL)
brush = ws_color_black ();
brush = (uint32 *)ws_color_black ();
if (pix_size > 1) {
int i, j;
@@ -408,15 +408,15 @@ vid_beep ();
unsigned long
os_elapsed(void)
{
static int new;
static int tnew;
unsigned long ret;
static uint32 t[2];
t[new] = sim_os_msec();
if (t[!new] == 0)
t[tnew] = sim_os_msec();
if (t[!tnew] == 0)
ret = ~0L; /* +INF */
else
ret = (t[new] - t[!new]) * 1000;/* usecs */
new = !new; /* Ecclesiastes III */
ret = (t[tnew] - t[!tnew]) * 1000;/* usecs */
tnew = !tnew; /* Ecclesiastes III */
return ret;
}

View File

@@ -135,18 +135,24 @@ static int vt11_dbit;
#include <stdio.h>
#if defined(__cplusplus)
extern "C" {
#endif
#define DEVICE void
#define DBG_CALL 1
int vt11_debug;
#if defined(VM_PDP11)
extern void _sim_debug (int dbits, DEVICE* dptr, const char* fmt, ...);
extern void _sim_debug (unsigned int dbits, DEVICE* dptr, const char* fmt, ...);
#define DEBUGF(...) _sim_debug (vt11_dbit, vt11_dptr, ## __VA_ARGS__)
#else /* DEBUG_VT11 */
#define DEBUGF(...) do {if (vt11_debug & DBG_CALL) { printf(## __VA_ARGS__); fflush(stdout); };} while (0)
#endif /* defined(DEBUG_VT11) || defined(VM_PDP11) */
#if defined(__cplusplus)
}
#endif
#else
#define DEBUGF(...)
@@ -249,7 +255,7 @@ static uint16 bdb = 0; /* Buffered Data Bits register;
static unsigned char internal_stop = 0; /* 1 bit: stop display */
static unsigned char mode_field = 0; /* copy of control instr. bits 14-11 */
#define graphic_mode stack[8]._mode /* 4 bits: sets type for graphic data */
enum mode { CHAR=0, SVECTOR, LVECTOR, POINT, GRAPHX, GRAPHY, RELPOINT, /* all */
enum gmode { CHAR=0, SVECTOR, LVECTOR, POINT, GRAPHX, GRAPHY, RELPOINT, /* all */
BSVECT, CIRCLE, ABSVECTOR /* VS60 only */
};
@@ -424,7 +430,7 @@ static struct frame
{
vt11word _dpc; /* Display Program Counter (even) */
unsigned _name; /* (11-bit) name from display file */
enum mode _mode; /* 4 bits: sets type for graphic data */
enum gmode _mode; /* 4 bits: sets type for graphic data */
unsigned char _vscale; /* non-character scale factor * 4 */
unsigned char _csi; /* character scale index 0..3 */
unsigned char _cscale; /* character scale factor * 4 */
@@ -448,24 +454,24 @@ static struct frame
enum scolor _color; /* scope display color (option) */
unsigned char _zdata; /* flag: display file has Z coords */
unsigned char _depth; /* flag: display Z using depth cue */
} stack[9] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 1, 0, GREEN, 0, 0 },
};
#define char_scale stack[8]._cscale /* character scale factor * 4 */
@@ -3158,7 +3164,7 @@ vt11_cycle(int us, int slowdown)
case 5: /* Set Graphic Mode 0101 */
case 6: /* Set Graphic Mode 0110 */
DEBUGF("Set Graphic Mode %u", (unsigned)mode_field);
graphic_mode = mode_field;
graphic_mode = (enum gmode)mode_field;
offset = 0;
shift_out = 0; /* seems to be right */
if (TESTBIT(inst,10)) {
@@ -3174,7 +3180,7 @@ vt11_cycle(int us, int slowdown)
DEBUGF(" blink=%d", (int)blink_ena);
}
if (TESTBIT(inst,2)) {
line_type = GETFIELD(inst,1,0);
line_type = (enum linetype)GETFIELD(inst,1,0);
DEBUGF(" line_type=%d", (int)line_type);
}
DEBUGF("\r\n");
@@ -3412,7 +3418,7 @@ vt11_cycle(int us, int slowdown)
} else { /* 11110: Load Status B */
DEBUGF("Load Status B");
if (VS60 && TESTBIT(inst,9)) {
color = GETFIELD(inst,8,7);
color = (enum scolor)GETFIELD(inst,8,7);
DEBUGF(" color=%d", (int)color);
}
if (TESTBIT(inst,6)) {

View File

@@ -34,10 +34,13 @@
* from the authors.
*/
#if defined(__cplusplus)
extern "C" {
#endif
#ifndef SIM_DEFS_H_
typedef unsigned short uint16;
typedef long int32;
typedef unsigned long uint32;
typedef int int32;
typedef unsigned int uint32;
#endif /* SIM_DEFS_H_ */
/*
@@ -135,3 +138,7 @@ extern void vt_stop_intr(void); /* post a display-stop interrupt */
extern void vt_lpen_intr(void); /* post a surface-related interrupt */
extern void vt_char_intr(void); /* post a bad-char./timeout interrupt */
extern void vt_name_intr(void); /* post a name-match interrupt */
#if defined(__cplusplus)
}
#endif

View File

@@ -66,7 +66,7 @@ int ws_lp_y = -1;
static HWND static_wh;
static HINSTANCE static_inst;
static int xpixels, ypixels;
static char *window_name;
static const char *window_name;
static HBRUSH white_brush;
static HBRUSH black_brush;
#ifdef SWITCH_CURSORS
@@ -317,7 +317,7 @@ ws_thread_init(void)
/* called from display layer on first display op */
int
ws_init(char *name, int xp, int yp, int colors, void *dptr)
ws_init(const char *name, int xp, int yp, int colors, void *dptr)
{
xpixels = xp;
ypixels = yp;

View File

@@ -31,7 +31,7 @@
/* unless you're writing a new driver, you shouldn't be looking here! */
extern int ws_init(char *, int, int, int, void *);
extern int ws_init(const char *, int, int, int, void *);
void ws_shutdown(void);
extern void *ws_color_rgb(int, int, int);
extern void *ws_color_black(void);

View File

@@ -205,7 +205,7 @@ handle_exposure(w, d, e, b)
}
int
ws_init(char *crtname, /* crt type name */
ws_init(const char *crtname, /* crt type name */
int xp, int yp, /* screen size in pixels */
int colors, /* colors to support (not used) */
void *dptr)