SCP: Reduce compiler warnings on LP64 platforms
(Note: Reducing compiler warnings across all, but primarily LP64 platforms, is a long term objective.) Reduce compiler warnings on LP64 platforms (macOS, Windows) and 32-bit builds (Win32). Prefer 'size_t' for pointer arithmetic, array indexing and extents; 'int' hasn't been used for these purposes for many years and across many ANSI standards. N.B. that conversions from int or int32 to size_t cause the compiler to zero-extend the value, which is inefficient. Refactor printf() format modifiers into sim_printf_fmts.h. Add the SIZE_T_FMT modifier for better portability, especially on LP64 platforms where size_t is unsigned long and sizeof(size_t) > sizeof(int). 3B2: Fix known size_t printf() format.
This commit is contained in:
parent
d9d0e8bd74
commit
a275c71170
11 changed files with 324 additions and 174 deletions
|
@ -185,7 +185,7 @@ uint32 dmac_read(uint32 pa, size_t size)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sim_debug(READ_MSG, &dmac_dev,
|
sim_debug(READ_MSG, &dmac_dev,
|
||||||
"DMAC READ %lu B @ %08x\n",
|
"DMAC READ %" SIZE_T_FMT "u B @ %08x\n",
|
||||||
size, pa);
|
size, pa);
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ uint32 dmac_read(uint32 pa, size_t size)
|
||||||
return data;
|
return data;
|
||||||
default:
|
default:
|
||||||
sim_debug(READ_MSG, &dmac_dev,
|
sim_debug(READ_MSG, &dmac_dev,
|
||||||
"[BASE: %08x] DMAC READ %lu B @ %08x\n",
|
"[BASE: %08x] DMAC READ %" SIZE_T_FMT "u B @ %08x\n",
|
||||||
base, size, pa);
|
base, size, pa);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,8 @@ if (WIN32)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
list(APPEND EXTRA_TARGET_CFLAGS
|
list(APPEND EXTRA_TARGET_CFLAGS
|
||||||
"$<$<AND:$<CONFIG:Debug>,$<BOOL:${DEBUG_WALL}>>:/W3>"
|
"$<$<CONFIG:Debug>:$<$<BOOL:${DEBUG_WALL}>:/W4>>"
|
||||||
|
"$<$<CONFIG:Release>:/W3>"
|
||||||
)
|
)
|
||||||
|
|
||||||
## Uncomment this line if you end up with /NODEFAULTLIB warninigs. You will also
|
## Uncomment this line if you end up with /NODEFAULTLIB warninigs. You will also
|
||||||
|
@ -135,7 +136,9 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
|
||||||
## LIST(APPEND EXTRA_TARGET_CFLAGS "-Wall" "-fno-inline" "-fstrict-overflow" "-Wstrict-overflow=3")
|
## LIST(APPEND EXTRA_TARGET_CFLAGS "-Wall" "-fno-inline" "-fstrict-overflow" "-Wstrict-overflow=3")
|
||||||
LIST(APPEND EXTRA_TARGET_CFLAGS
|
LIST(APPEND EXTRA_TARGET_CFLAGS
|
||||||
"-U__STRICT_ANSI__"
|
"-U__STRICT_ANSI__"
|
||||||
"$<$<AND:$<CONFIG:Debug>,$<BOOL:${DEBUG_WALL}>>:-Wall>"
|
"$<$<CONFIG:Debug>:$<$<BOOL:${DEBUG_WALL}>:-Wall>>"
|
||||||
|
## Only add if WARNINGS_FATAL set; has undesirable consequences with LTO.
|
||||||
|
"$<$<CONFIG:Release>:-Wall>"
|
||||||
)
|
)
|
||||||
|
|
||||||
# 07 NOV 2022: Apparently, -O3 is kosher now.
|
# 07 NOV 2022: Apparently, -O3 is kosher now.
|
||||||
|
@ -170,13 +173,16 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
|
||||||
string(REGEX REPLACE "-O3" "-O2" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
|
string(REGEX REPLACE "-O3" "-O2" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (WARNINGS_FATAL OR RELEASE_LTO)
|
if (WARNINGS_FATAL` OR RELEASE_LTO)
|
||||||
check_c_compiler_flag("-Werror" GCC_W_ERROR_FLAG)
|
check_c_compiler_flag("-Werror" GCC_W_ERROR_FLAG)
|
||||||
if (GCC_W_ERROR_FLAG)
|
if (GCC_W_ERROR_FLAG)
|
||||||
message(STATUS "WARNINGS_FATAL: Compiler warnings are errors!! (-Werror)")
|
if (WARNINGS_FATAL)
|
||||||
list(APPEND EXTRA_TARGET_CFLAGS "-Werror")
|
message(STATUS "WARNINGS_FATAL: Compiler warnings are errors!! (-Werror)")
|
||||||
|
list(APPEND EXTRA_TARGET_CFLAGS "-Werror")
|
||||||
|
endif ()
|
||||||
if (RELEASE_LTO)
|
if (RELEASE_LTO)
|
||||||
list(APPEND EXTRA_TARGET_LFLAGS "-Werror")
|
message(STATUS "WARNINGS_FATAL: Link-time optimization warnings are errors!! (-Werror)")
|
||||||
|
list(APPEND EXTRA_TARGET_LFLAGS "-Werror")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
207
scp.c
207
scp.c
|
@ -3090,7 +3090,7 @@ t_stat set_prompt (int32 flag, CONST char *cptr)
|
||||||
{
|
{
|
||||||
char gbuf[CBUFSIZE], *gptr;
|
char gbuf[CBUFSIZE], *gptr;
|
||||||
|
|
||||||
if ((!cptr) || (*cptr == '\0'))
|
if ((NULL == cptr) || (*cptr == '\0'))
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
|
|
||||||
cptr = get_glyph_nc (cptr, gbuf, '"'); /* get quote delimited token */
|
cptr = get_glyph_nc (cptr, gbuf, '"'); /* get quote delimited token */
|
||||||
|
@ -3148,10 +3148,10 @@ void fprint_help (FILE *st)
|
||||||
{
|
{
|
||||||
CTAB *cmdp;
|
CTAB *cmdp;
|
||||||
CTAB **hlp_cmdp = NULL;
|
CTAB **hlp_cmdp = NULL;
|
||||||
int cmd_cnt = 0;
|
size_t cmd_cnt = 0;
|
||||||
int cmd_size = 0;
|
size_t cmd_size = 0;
|
||||||
size_t max_cmdname_size = 0;
|
size_t max_cmdname_size = 0;
|
||||||
int i, line_offset;
|
size_t i, line_offset;
|
||||||
|
|
||||||
for (cmdp = sim_vm_cmd; cmdp && (cmdp->name != NULL); cmdp++) {
|
for (cmdp = sim_vm_cmd; cmdp && (cmdp->name != NULL); cmdp++) {
|
||||||
if (cmdp->help) {
|
if (cmdp->help) {
|
||||||
|
@ -3166,7 +3166,7 @@ for (cmdp = sim_vm_cmd; cmdp && (cmdp->name != NULL); cmdp++) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (cmdp = cmd_table; cmdp && (cmdp->name != NULL); cmdp++) {
|
for (cmdp = cmd_table; cmdp && (cmdp->name != NULL); cmdp++) {
|
||||||
if (cmdp->help && (!sim_vm_cmd || !find_ctab (sim_vm_cmd, cmdp->name))) {
|
if (cmdp->help && (NULL == sim_vm_cmd || NULL == find_ctab (sim_vm_cmd, cmdp->name))) {
|
||||||
if (cmd_cnt >= cmd_size) {
|
if (cmd_cnt >= cmd_size) {
|
||||||
cmd_size += 20;
|
cmd_size += 20;
|
||||||
hlp_cmdp = (CTAB **)realloc (hlp_cmdp, sizeof(*hlp_cmdp)*cmd_size);
|
hlp_cmdp = (CTAB **)realloc (hlp_cmdp, sizeof(*hlp_cmdp)*cmd_size);
|
||||||
|
@ -3215,7 +3215,7 @@ const char *end;
|
||||||
if ((strlen (buf) >= max_width) &&
|
if ((strlen (buf) >= max_width) &&
|
||||||
(NULL != strchr (buf, '=')) &&
|
(NULL != strchr (buf, '=')) &&
|
||||||
(NULL != strchr (strchr (buf, '='), ';')) ) {
|
(NULL != strchr (strchr (buf, '='), ';')) ) {
|
||||||
int chunk_size;
|
size_t chunk_size;
|
||||||
const char *front_gap = strchr (buf, '=');
|
const char *front_gap = strchr (buf, '=');
|
||||||
size_t front_gap_size = front_gap - buf + 1;
|
size_t front_gap_size = front_gap - buf + 1;
|
||||||
|
|
||||||
|
@ -3232,18 +3232,18 @@ if ((strlen (buf) >= max_width) &&
|
||||||
--chunk_size;
|
--chunk_size;
|
||||||
if (chunk_size == 0)
|
if (chunk_size == 0)
|
||||||
chunk_size = strlen (buf);
|
chunk_size = strlen (buf);
|
||||||
fprintf (st, "%*s%*.*s\n", (int)(line_pos), "", chunk_size, chunk_size, buf);
|
fprintf (st, "%*s%*.*s\n", (int) line_pos, "", (int) chunk_size, (int) chunk_size, buf);
|
||||||
buf += chunk_size;
|
buf += chunk_size;
|
||||||
while (isspace (buf[0]))
|
while (isspace (buf[0]))
|
||||||
++buf;
|
++buf;
|
||||||
if (buf < end)
|
if (buf < end)
|
||||||
line_pos = front_gap_size;
|
line_pos = front_gap_size;
|
||||||
}
|
}
|
||||||
fprintf (st, "%*s%*.*s", (int)(line_pos), "", chunk_size, chunk_size, buf);
|
fprintf (st, "%*s%*.*s", (int) line_pos, "", (int) chunk_size, (int) chunk_size, buf);
|
||||||
line_pos = width + 1;
|
line_pos = width + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf (st, "%*s", -((int)width), buf);
|
fprintf (st, "%*s", -((int) width), buf);
|
||||||
if (line_pos > width) {
|
if (line_pos > width) {
|
||||||
fprintf (st, "\n");
|
fprintf (st, "\n");
|
||||||
if (extra == NULL)
|
if (extra == NULL)
|
||||||
|
@ -3255,7 +3255,7 @@ if (line_pos > width) {
|
||||||
end = extra + (extra ? strlen (extra) : 0);
|
end = extra + (extra ? strlen (extra) : 0);
|
||||||
line_pos += (gap ? strlen (gap) : 0);
|
line_pos += (gap ? strlen (gap) : 0);
|
||||||
if (line_pos + (end - extra) >= max_width) {
|
if (line_pos + (end - extra) >= max_width) {
|
||||||
int chunk_size;
|
size_t chunk_size;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
chunk_size = (end - extra);
|
chunk_size = (end - extra);
|
||||||
|
@ -3268,13 +3268,13 @@ if (line_pos + (end - extra) >= max_width) {
|
||||||
--chunk_size;
|
--chunk_size;
|
||||||
if (chunk_size == 0)
|
if (chunk_size == 0)
|
||||||
chunk_size = strlen (extra);
|
chunk_size = strlen (extra);
|
||||||
fprintf (st, "%s%*.*s\n", gap ? gap : "", chunk_size, chunk_size, extra);
|
fprintf (st, "%s%*.*s\n", gap ? gap : "", (int) chunk_size, (int) chunk_size, extra);
|
||||||
extra += chunk_size;
|
extra += chunk_size;
|
||||||
while (isspace (extra[0]))
|
while (isspace (extra[0]))
|
||||||
++extra;
|
++extra;
|
||||||
if (extra < end) {
|
if (extra < end) {
|
||||||
line_pos = width;
|
line_pos = width;
|
||||||
fprintf (st, "%*s", -((int)width), "");
|
fprintf (st, "%*s", -((int) width), "");
|
||||||
line_pos += (gap ? strlen (gap) : 0);
|
line_pos += (gap ? strlen (gap) : 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3537,7 +3537,7 @@ if ((dptr->modifiers) && (dptr->units)) { /* handle unit specific modifiers */
|
||||||
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
|
for (mptr = dptr->modifiers; mptr->mask != 0; mptr++) {
|
||||||
if ((!MODMASK(mptr,MTAB_VUN)) && MODMASK(mptr,MTAB_XTD))
|
if ((!MODMASK(mptr,MTAB_VUN)) && MODMASK(mptr,MTAB_XTD))
|
||||||
continue; /* skip device only modifiers */
|
continue; /* skip device only modifiers */
|
||||||
if ((!mptr->valid) && MODMASK(mptr,MTAB_XTD))
|
if ((NULL == mptr->valid) && MODMASK(mptr,MTAB_XTD))
|
||||||
continue; /* skip show only modifiers */
|
continue; /* skip show only modifiers */
|
||||||
if ((enabled_units == 1) && (found_unit == 0))
|
if ((enabled_units == 1) && (found_unit == 0))
|
||||||
continue;
|
continue;
|
||||||
|
@ -5315,22 +5315,27 @@ return SCPE_OK;
|
||||||
static uint32 get_default_env_parameter (const char *dev_name, const char *param_name, uint32 default_value)
|
static uint32 get_default_env_parameter (const char *dev_name, const char *param_name, uint32 default_value)
|
||||||
{
|
{
|
||||||
char varname[CBUFSIZE];
|
char varname[CBUFSIZE];
|
||||||
uint32 val;
|
unsigned long val;
|
||||||
char *endptr;
|
char *endptr;
|
||||||
const char *colon = strchr (dev_name, ':');
|
const char *colon = strchr (dev_name, ':');
|
||||||
|
char *env_val;
|
||||||
|
|
||||||
if (colon)
|
if (colon)
|
||||||
snprintf (varname, sizeof(varname), "%s_%*.*s_%s", param_name, (int)(colon-dev_name), (int)(colon-dev_name), dev_name, colon + 1);
|
snprintf (varname, sizeof(varname), "%s_%*.*s_%s", param_name, (int)(colon-dev_name), (int)(colon-dev_name), dev_name, colon + 1);
|
||||||
else
|
else
|
||||||
snprintf (varname, sizeof(varname), "%s_%s", param_name, dev_name);
|
snprintf (varname, sizeof(varname), "%s_%s", param_name, dev_name);
|
||||||
if (!getenv (varname))
|
|
||||||
|
env_val = getenv(varname);
|
||||||
|
|
||||||
|
if (NULL == env_val)
|
||||||
val = default_value;
|
val = default_value;
|
||||||
else {
|
else {
|
||||||
val = strtoul (getenv (varname), &endptr, 0);
|
val = strtoul (env_val, &endptr, 0);
|
||||||
if (*endptr)
|
if (*endptr)
|
||||||
val = default_value;
|
val = default_value;
|
||||||
}
|
}
|
||||||
return val;
|
/* Should really ensure val fits into uint32 when sizeof(uint32) < sizeof(unsigned long). */
|
||||||
|
return ((uint32) val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_default_env_parameter (const char *dev_name, const char *param_name, uint32 value)
|
static void set_default_env_parameter (const char *dev_name, const char *param_name, uint32 value)
|
||||||
|
@ -6925,11 +6930,11 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_stat show_config (FILE *st, DEVICE *dnotused, UNIT *unotused, int32 flag, CONST char *cptr)
|
t_stat show_config (FILE *st, DEVICE *dnotused, UNIT *unotused, int32 flag, CONST char *cptr)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
DEVICE *dptr;
|
DEVICE *dptr;
|
||||||
t_bool only_enabled = (sim_switches & SWMASK ('E'));
|
t_bool only_enabled = (sim_switches & SWMASK ('E'));
|
||||||
|
|
||||||
if (cptr && (*cptr != 0))
|
if (NULL != cptr && (*cptr != 0))
|
||||||
return SCPE_2MARG;
|
return SCPE_2MARG;
|
||||||
fprintf (st, "%s simulator configuration%s\n\n", sim_name, only_enabled ? " (enabled devices)" : "");
|
fprintf (st, "%s simulator configuration%s\n\n", sim_name, only_enabled ? " (enabled devices)" : "");
|
||||||
for (i = dev_name_len = unit_name_len = 0; (dptr = sim_devices[i]) != NULL; i++)
|
for (i = dev_name_len = unit_name_len = 0; (dptr = sim_devices[i]) != NULL; i++)
|
||||||
|
@ -7463,15 +7468,15 @@ char lbuf[4*CBUFSIZE];
|
||||||
|
|
||||||
sim_type_file_offset = 0; /* beginning of file */
|
sim_type_file_offset = 0; /* beginning of file */
|
||||||
sim_type_line_count = 0X7FFFFFFF; /* output many lines */
|
sim_type_line_count = 0X7FFFFFFF; /* output many lines */
|
||||||
GET_SWITCHES (cptr); /* get switches */
|
GET_SWITCHES (cptr); /* get switches */
|
||||||
if ((!cptr) || (*cptr == 0))
|
if ((NULL == cptr) || (*cptr == 0))
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
if (sim_switches & SWMASK ('O')) { /* Specify Offset in file */
|
if (sim_switches & SWMASK ('O')) { /* Specify Offset in file */
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
char *eptr;
|
char *eptr;
|
||||||
|
|
||||||
cptr = get_glyph (cptr, gbuf, 0);
|
cptr = get_glyph (cptr, gbuf, 0);
|
||||||
if ((!cptr) || (*cptr == 0))
|
if ((NULL == cptr) || (*cptr == 0))
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
sim_type_file_offset = strtol (gbuf, &eptr, 0);
|
sim_type_file_offset = strtol (gbuf, &eptr, 0);
|
||||||
if ((*eptr) || (sim_type_file_offset < 0))
|
if ((*eptr) || (sim_type_file_offset < 0))
|
||||||
|
@ -7482,7 +7487,7 @@ if (sim_switches & SWMASK ('N')) { /* Specify Line Count to display */
|
||||||
char *eptr;
|
char *eptr;
|
||||||
|
|
||||||
cptr = get_glyph (cptr, gbuf, 0);
|
cptr = get_glyph (cptr, gbuf, 0);
|
||||||
if ((!cptr) || (*cptr == 0))
|
if ((NULL == cptr) || (*cptr == 0))
|
||||||
return SCPE_2FARG;
|
return SCPE_2FARG;
|
||||||
sim_type_line_count = strtol (gbuf, &eptr, 0);
|
sim_type_line_count = strtol (gbuf, &eptr, 0);
|
||||||
if ((*eptr) || (sim_type_line_count < 0))
|
if ((*eptr) || (sim_type_line_count < 0))
|
||||||
|
@ -10726,9 +10731,9 @@ return SCPE_OK;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char *sim_encode_quoted_string (const uint8 *iptr, uint32 size)
|
char *sim_encode_quoted_string (const uint8 *iptr, size_t size)
|
||||||
{
|
{
|
||||||
uint32 i;
|
size_t i;
|
||||||
t_bool double_quote_found = FALSE;
|
t_bool double_quote_found = FALSE;
|
||||||
t_bool single_quote_found = FALSE;
|
t_bool single_quote_found = FALSE;
|
||||||
char quote = '"';
|
char quote = '"';
|
||||||
|
@ -10787,7 +10792,7 @@ while (size--) {
|
||||||
return optr;
|
return optr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size)
|
void fprint_buffer_string (FILE *st, const uint8 *buf, size_t size)
|
||||||
{
|
{
|
||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
|
@ -11277,25 +11282,28 @@ return pptr;
|
||||||
|
|
||||||
SCHTAB *get_rsearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
|
SCHTAB *get_rsearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
|
||||||
{
|
{
|
||||||
int32 c, logop, cmpop;
|
int32 c;
|
||||||
|
size_t logop, cmpop;
|
||||||
t_value logval, cmpval;
|
t_value logval, cmpval;
|
||||||
const char *sptr;
|
const char *sptr;
|
||||||
CONST char *tptr;
|
CONST char *tptr;
|
||||||
const char logstr[] = "|&^", cmpstr[] = "=!><";
|
const char logstr[] = "|&^", cmpstr[] = "=!><";
|
||||||
|
/* Using a const instead of a #define. */
|
||||||
|
const size_t invalid_op = (size_t) -1;
|
||||||
|
|
||||||
logval = cmpval = 0;
|
logval = cmpval = 0;
|
||||||
if (*cptr == 0) /* check for clause */
|
if (*cptr == 0) /* check for clause */
|
||||||
return NULL;
|
return NULL;
|
||||||
for (logop = cmpop = -1; (c = *cptr++); ) { /* loop thru clauses */
|
for (logop = cmpop = invalid_op; (c = *cptr++); ) { /* loop thru clauses */
|
||||||
if ((sptr = strchr (logstr, c))) { /* check for mask */
|
if ((sptr = strchr (logstr, c))) { /* check for mask */
|
||||||
logop = (int32)(sptr - logstr);
|
logop = sptr - logstr;
|
||||||
logval = strtotv (cptr, &tptr, radix);
|
logval = strtotv (cptr, &tptr, radix);
|
||||||
if (cptr == tptr)
|
if (cptr == tptr)
|
||||||
return NULL;
|
return NULL;
|
||||||
cptr = tptr;
|
cptr = tptr;
|
||||||
}
|
}
|
||||||
else if ((sptr = strchr (cmpstr, c))) { /* check for boolop */
|
else if ((sptr = strchr (cmpstr, c))) { /* check for boolop */
|
||||||
cmpop = (int32)(sptr - cmpstr);
|
cmpop = sptr - cmpstr;
|
||||||
if (*cptr == '=') {
|
if (*cptr == '=') {
|
||||||
cmpop = cmpop + strlen (cmpstr);
|
cmpop = cmpop + strlen (cmpstr);
|
||||||
cptr++;
|
cptr++;
|
||||||
|
@ -11313,11 +11321,11 @@ if (schptr->count != 1) {
|
||||||
free (schptr->comp);
|
free (schptr->comp);
|
||||||
schptr->comp = (t_value *)calloc (sim_emax, sizeof(*schptr->comp));
|
schptr->comp = (t_value *)calloc (sim_emax, sizeof(*schptr->comp));
|
||||||
}
|
}
|
||||||
if (logop >= 0) {
|
if (logop != invalid_op) {
|
||||||
schptr->logic = logop;
|
schptr->logic = logop;
|
||||||
schptr->mask[0] = logval;
|
schptr->mask[0] = logval;
|
||||||
}
|
}
|
||||||
if (cmpop >= 0) {
|
if (cmpop != invalid_op) {
|
||||||
schptr->boolop = cmpop;
|
schptr->boolop = cmpop;
|
||||||
schptr->comp[0] = cmpval;
|
schptr->comp[0] = cmpval;
|
||||||
}
|
}
|
||||||
|
@ -11338,21 +11346,24 @@ return schptr;
|
||||||
|
|
||||||
SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
|
SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr)
|
||||||
{
|
{
|
||||||
int32 c, logop, cmpop;
|
int32 c;
|
||||||
|
size_t logop, cmpop;
|
||||||
t_value *logval, *cmpval;
|
t_value *logval, *cmpval;
|
||||||
t_stat reason = SCPE_OK;
|
t_stat reason = SCPE_OK;
|
||||||
CONST char *ocptr = cptr;
|
CONST char *ocptr = cptr;
|
||||||
const char *sptr;
|
const char *sptr;
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
const char logstr[] = "|&^", cmpstr[] = "=!><";
|
const char logstr[] = "|&^", cmpstr[] = "=!><";
|
||||||
|
/* Using a const instead of a #define. */
|
||||||
|
const size_t invalid_op = (size_t) -1;
|
||||||
|
|
||||||
if (*cptr == 0) /* check for clause */
|
if (*cptr == 0) /* check for clause */
|
||||||
return NULL;
|
return NULL;
|
||||||
logval = (t_value *)calloc (sim_emax, sizeof(*logval));
|
logval = (t_value *)calloc (sim_emax, sizeof(*logval));
|
||||||
cmpval = (t_value *)calloc (sim_emax, sizeof(*cmpval));
|
cmpval = (t_value *)calloc (sim_emax, sizeof(*cmpval));
|
||||||
for (logop = cmpop = -1; (c = *cptr++); ) { /* loop thru clauses */
|
for (logop = cmpop = invalid_op; (c = *cptr++); ) { /* loop thru clauses */
|
||||||
if ((sptr = strchr (logstr, c))) { /* check for mask */
|
if (NULL != (sptr = strchr (logstr, c))) { /* check for mask */
|
||||||
logop = (int32)(sptr - logstr);
|
logop = sptr - logstr;
|
||||||
cptr = get_glyph (cptr, gbuf, 0);
|
cptr = get_glyph (cptr, gbuf, 0);
|
||||||
reason = parse_sym (gbuf, 0, sim_dfunit, logval, sim_switches);
|
reason = parse_sym (gbuf, 0, sim_dfunit, logval, sim_switches);
|
||||||
if (reason > 0) {
|
if (reason > 0) {
|
||||||
|
@ -11361,8 +11372,8 @@ for (logop = cmpop = -1; (c = *cptr++); ) { /* loop thru clauses */
|
||||||
return get_rsearch (ocptr, radix, schptr);
|
return get_rsearch (ocptr, radix, schptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((sptr = strchr (cmpstr, c))) { /* check for boolop */
|
else if (NULL != (sptr = strchr (cmpstr, c))) { /* check for boolop */
|
||||||
cmpop = (int32)(sptr - cmpstr);
|
cmpop = sptr - cmpstr;
|
||||||
if (*cptr == '=') {
|
if (*cptr == '=') {
|
||||||
cmpop = cmpop + strlen (cmpstr);
|
cmpop = cmpop + strlen (cmpstr);
|
||||||
cptr++;
|
cptr++;
|
||||||
|
@ -11388,7 +11399,7 @@ if (schptr->count != (uint32)(1 - reason)) {
|
||||||
free (schptr->comp);
|
free (schptr->comp);
|
||||||
schptr->comp = (t_value *)calloc (sim_emax, sizeof(*schptr->comp));
|
schptr->comp = (t_value *)calloc (sim_emax, sizeof(*schptr->comp));
|
||||||
}
|
}
|
||||||
if (logop >= 0) {
|
if (logop != invalid_op) {
|
||||||
schptr->logic = logop;
|
schptr->logic = logop;
|
||||||
free (schptr->mask);
|
free (schptr->mask);
|
||||||
schptr->mask = logval;
|
schptr->mask = logval;
|
||||||
|
@ -11396,7 +11407,7 @@ if (logop >= 0) {
|
||||||
else {
|
else {
|
||||||
free (logval);
|
free (logval);
|
||||||
}
|
}
|
||||||
if (cmpop >= 0) {
|
if (cmpop != invalid_op) {
|
||||||
schptr->boolop = cmpop;
|
schptr->boolop = cmpop;
|
||||||
free (schptr->comp);
|
free (schptr->comp);
|
||||||
schptr->comp = cmpval;
|
schptr->comp = cmpval;
|
||||||
|
@ -11650,11 +11661,11 @@ return val * negate;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t_stat sprint_val (char *buffer, t_value val, uint32 radix,
|
t_stat sprint_val (char *buffer, t_value val, uint32 radix,
|
||||||
uint32 width, uint32 format)
|
size_t width, uint32 format)
|
||||||
{
|
{
|
||||||
t_value owtest, wtest;
|
t_value owtest, wtest;
|
||||||
t_bool negative = FALSE;
|
t_bool negative = FALSE;
|
||||||
int32 d, digit, ndigits, commas = 0;
|
size_t d, digit, ndigits, commas = 0;
|
||||||
char dbuf[MAX_WIDTH + 1];
|
char dbuf[MAX_WIDTH + 1];
|
||||||
|
|
||||||
if (((format == PV_LEFTSIGN) || (format == PV_RCOMMASIGN)) &&
|
if (((format == PV_LEFTSIGN) || (format == PV_RCOMMASIGN)) &&
|
||||||
|
@ -11694,7 +11705,8 @@ switch (format) {
|
||||||
dbuf[--d] = '-';
|
dbuf[--d] = '-';
|
||||||
if (width > MAX_WIDTH) {
|
if (width > MAX_WIDTH) {
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return width;
|
/* Note: Potentially unsafe wraparound if sizeof(t_stat) < sizeof(size_t) */
|
||||||
|
return ((t_stat) width);
|
||||||
sprintf (buffer, "%*s", -((int)width), dbuf);
|
sprintf (buffer, "%*s", -((int)width), dbuf);
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
}
|
}
|
||||||
|
@ -11715,8 +11727,9 @@ switch (format) {
|
||||||
d = MAX_WIDTH - (ndigits + commas);
|
d = MAX_WIDTH - (ndigits + commas);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!buffer)
|
if (NULL == buffer)
|
||||||
return strlen(dbuf+d);
|
/* Note: Potentially unsafe wraparound if sizeof(t_stat) < sizeof(size_t) */
|
||||||
|
return ((t_stat) strlen(dbuf+d));
|
||||||
*buffer = '\0';
|
*buffer = '\0';
|
||||||
if (width < strlen(dbuf+d))
|
if (width < strlen(dbuf+d))
|
||||||
return SCPE_IOERR;
|
return SCPE_IOERR;
|
||||||
|
@ -12963,11 +12976,11 @@ return sim_exp_clr (exp, gbuf); /* clear one rule */
|
||||||
|
|
||||||
/* Search for an expect rule in an expect context */
|
/* Search for an expect rule in an expect context */
|
||||||
|
|
||||||
CONST EXPTAB *sim_exp_fnd (CONST EXPECT *exp, const char *match, int32 start_rule)
|
CONST EXPTAB *sim_exp_fnd (CONST EXPECT *exp, const char *match, size_t start_rule)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
|
|
||||||
if (!exp->rules)
|
if (NULL == exp->rules)
|
||||||
return NULL;
|
return NULL;
|
||||||
for (i=start_rule; i<exp->size; i++)
|
for (i=start_rule; i<exp->size; i++)
|
||||||
if (!strcmp (exp->rules[i].match_pattern, match))
|
if (!strcmp (exp->rules[i].match_pattern, match))
|
||||||
|
@ -12979,9 +12992,9 @@ return NULL;
|
||||||
|
|
||||||
t_stat sim_exp_clr_tab (EXPECT *exp, EXPTAB *ep)
|
t_stat sim_exp_clr_tab (EXPECT *exp, EXPTAB *ep)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
|
|
||||||
if (!ep) /* not there? ok */
|
if (NULL == ep) /* not there? ok */
|
||||||
return SCPE_OK;
|
return SCPE_OK;
|
||||||
free (ep->match); /* deallocate match string */
|
free (ep->match); /* deallocate match string */
|
||||||
free (ep->match_pattern); /* deallocate the display format match string */
|
free (ep->match_pattern); /* deallocate the display format match string */
|
||||||
|
@ -13004,7 +13017,7 @@ t_stat sim_exp_clr (EXPECT *exp, const char *match)
|
||||||
{
|
{
|
||||||
EXPTAB *ep = (EXPTAB *)sim_exp_fnd (exp, match, 0);
|
EXPTAB *ep = (EXPTAB *)sim_exp_fnd (exp, match, 0);
|
||||||
|
|
||||||
while (ep) {
|
while (NULL != ep) {
|
||||||
sim_exp_clr_tab (exp, ep);
|
sim_exp_clr_tab (exp, ep);
|
||||||
ep = (EXPTAB *)sim_exp_fnd (exp, match, ep - exp->rules);
|
ep = (EXPTAB *)sim_exp_fnd (exp, match, ep - exp->rules);
|
||||||
}
|
}
|
||||||
|
@ -13015,7 +13028,7 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_stat sim_exp_clrall (EXPECT *exp)
|
t_stat sim_exp_clrall (EXPECT *exp)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
|
|
||||||
for (i=0; i<exp->size; i++) {
|
for (i=0; i<exp->size; i++) {
|
||||||
free (exp->rules[i].match); /* deallocate match string */
|
free (exp->rules[i].match); /* deallocate match string */
|
||||||
|
@ -13043,7 +13056,7 @@ t_stat sim_exp_set (EXPECT *exp, const char *match, int32 cnt, uint32 after, int
|
||||||
EXPTAB *ep;
|
EXPTAB *ep;
|
||||||
uint8 *match_buf;
|
uint8 *match_buf;
|
||||||
uint32 match_size;
|
uint32 match_size;
|
||||||
int i;
|
size_t i;
|
||||||
|
|
||||||
/* Validate the match string */
|
/* Validate the match string */
|
||||||
match_buf = (uint8 *)calloc (strlen (match) + 1, 1);
|
match_buf = (uint8 *)calloc (strlen (match) + 1, 1);
|
||||||
|
@ -13146,7 +13159,7 @@ if ((act != NULL) && (*act != 0)) { /* new action? */
|
||||||
}
|
}
|
||||||
/* Make sure that the production buffer is large enough to detect a match for all rules including a NUL termination byte */
|
/* Make sure that the production buffer is large enough to detect a match for all rules including a NUL termination byte */
|
||||||
for (i=0; i<exp->size; i++) {
|
for (i=0; i<exp->size; i++) {
|
||||||
uint32 compare_size = (exp->rules[i].switches & EXP_TYP_REGEX) ? MAX(10 * strlen(ep->match_pattern), 1024) : exp->rules[i].size;
|
size_t compare_size = (exp->rules[i].switches & EXP_TYP_REGEX) ? MAX(10 * strlen(ep->match_pattern), 1024) : exp->rules[i].size;
|
||||||
if (compare_size >= exp->buf_size) {
|
if (compare_size >= exp->buf_size) {
|
||||||
exp->buf = (uint8 *)realloc (exp->buf, compare_size + 2); /* Extra byte to null terminate regex compares */
|
exp->buf = (uint8 *)realloc (exp->buf, compare_size + 2); /* Extra byte to null terminate regex compares */
|
||||||
exp->buf_size = compare_size + 1;
|
exp->buf_size = compare_size + 1;
|
||||||
|
@ -13193,11 +13206,11 @@ uint32 default_haltafter = get_default_env_parameter (dev_name, "SIM_EXPECT_HALT
|
||||||
if (exp->buf_size) {
|
if (exp->buf_size) {
|
||||||
char *bstr = sim_encode_quoted_string (exp->buf, exp->buf_ins);
|
char *bstr = sim_encode_quoted_string (exp->buf, exp->buf_ins);
|
||||||
|
|
||||||
fprintf (st, " Match Buffer Size: %d\n", exp->buf_size);
|
fprintf (st, " Match Buffer Size: %" SIZE_T_FMT "d\n", exp->buf_size);
|
||||||
fprintf (st, " Buffer Insert Offset: %d\n", exp->buf_ins);
|
fprintf (st, " Buffer Insert Offset: %" SIZE_T_FMT "d\n", exp->buf_ins);
|
||||||
fprintf (st, " Buffer Contents: %s\n", bstr);
|
fprintf (st, " Buffer Contents: %s\n", bstr);
|
||||||
if (default_haltafter)
|
if (default_haltafter)
|
||||||
fprintf (st, " Default HaltAfter: %u %s\n", (unsigned)default_haltafter, sim_vm_interval_units);
|
fprintf (st, " Default HaltAfter: %u %s\n", (unsigned) default_haltafter, sim_vm_interval_units);
|
||||||
free (bstr);
|
free (bstr);
|
||||||
}
|
}
|
||||||
if (exp->dptr && (exp->dbit & exp->dptr->dctrl))
|
if (exp->dptr && (exp->dbit & exp->dptr->dctrl))
|
||||||
|
@ -13220,7 +13233,7 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_stat sim_exp_showall (FILE *st, const EXPECT *exp)
|
t_stat sim_exp_showall (FILE *st, const EXPECT *exp)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
|
|
||||||
for (i=0; i < exp->size; i++)
|
for (i=0; i < exp->size; i++)
|
||||||
sim_exp_show_tab (st, exp, &exp->rules[i]);
|
sim_exp_show_tab (st, exp, &exp->rules[i]);
|
||||||
|
@ -13231,7 +13244,7 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_stat sim_exp_check (EXPECT *exp, uint8 data)
|
t_stat sim_exp_check (EXPECT *exp, uint8 data)
|
||||||
{
|
{
|
||||||
int32 i;
|
size_t i;
|
||||||
EXPTAB *ep = NULL;
|
EXPTAB *ep = NULL;
|
||||||
int regex_checks = 0;
|
int regex_checks = 0;
|
||||||
char *tstr = NULL;
|
char *tstr = NULL;
|
||||||
|
@ -13276,7 +13289,9 @@ for (i=0; i < exp->size; i++) {
|
||||||
sim_debug (exp->dbit, exp->dptr, "Against RegEx Match Rule: %s\n", ep->match_pattern);
|
sim_debug (exp->dbit, exp->dptr, "Against RegEx Match Rule: %s\n", ep->match_pattern);
|
||||||
free (estr);
|
free (estr);
|
||||||
}
|
}
|
||||||
rc = pcre_exec (ep->regex, NULL, cbuf, exp->buf_ins, 0, PCRE_NOTBOL, ovector, ovector_elts);
|
/* exp->buf_ins is never going to exceed 1024 (current limit), so this is safe to
|
||||||
|
downcast to int. */
|
||||||
|
rc = pcre_exec (ep->regex, NULL, cbuf, (int) exp->buf_ins, 0, PCRE_NOTBOL, ovector, ovector_elts);
|
||||||
if (rc >= 0) {
|
if (rc >= 0) {
|
||||||
size_t j;
|
size_t j;
|
||||||
char *buf = (char *)malloc (1 + exp->buf_ins);
|
char *buf = (char *)malloc (1 + exp->buf_ins);
|
||||||
|
@ -13323,12 +13338,12 @@ for (i=0; i < exp->size; i++) {
|
||||||
* First compare the newly deposited data at the beginning
|
* First compare the newly deposited data at the beginning
|
||||||
* of buffer with the end of the match string
|
* of buffer with the end of the match string
|
||||||
*/
|
*/
|
||||||
if (exp->buf_ins) {
|
if (exp->buf_ins > 0) {
|
||||||
if (sim_deb && exp->dptr && (exp->dptr->dctrl & exp->dbit)) {
|
if (sim_deb && exp->dptr && (exp->dptr->dctrl & exp->dbit)) {
|
||||||
char *estr = sim_encode_quoted_string (exp->buf, exp->buf_ins);
|
char *estr = sim_encode_quoted_string (exp->buf, exp->buf_ins);
|
||||||
char *mstr = sim_encode_quoted_string (&ep->match[ep->size-exp->buf_ins], exp->buf_ins);
|
char *mstr = sim_encode_quoted_string (&ep->match[ep->size-exp->buf_ins], exp->buf_ins);
|
||||||
|
|
||||||
sim_debug (exp->dbit, exp->dptr, "Checking String[0:%d]: %s\n", exp->buf_ins, estr);
|
sim_debug (exp->dbit, exp->dptr, "Checking String[0:%" SIZE_T_FMT "d]: %s\n", exp->buf_ins, estr);
|
||||||
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
||||||
free (estr);
|
free (estr);
|
||||||
free (mstr);
|
free (mstr);
|
||||||
|
@ -13340,7 +13355,8 @@ for (i=0; i < exp->size; i++) {
|
||||||
char *estr = sim_encode_quoted_string (&exp->buf[exp->buf_size-(ep->size-exp->buf_ins)], ep->size-exp->buf_ins);
|
char *estr = sim_encode_quoted_string (&exp->buf[exp->buf_size-(ep->size-exp->buf_ins)], ep->size-exp->buf_ins);
|
||||||
char *mstr = sim_encode_quoted_string (ep->match, ep->size-exp->buf_ins);
|
char *mstr = sim_encode_quoted_string (ep->match, ep->size-exp->buf_ins);
|
||||||
|
|
||||||
sim_debug (exp->dbit, exp->dptr, "Checking String[%d:%d]: %s\n", exp->buf_size-(ep->size-exp->buf_ins), ep->size-exp->buf_ins, estr);
|
sim_debug (exp->dbit, exp->dptr, "Checking String[%" SIZE_T_FMT "d:%" SIZE_T_FMT "d]: %s\n",
|
||||||
|
exp->buf_size - ep->size - exp->buf_ins, ep->size-exp->buf_ins, estr);
|
||||||
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
||||||
free (estr);
|
free (estr);
|
||||||
free (mstr);
|
free (mstr);
|
||||||
|
@ -13354,7 +13370,8 @@ for (i=0; i < exp->size; i++) {
|
||||||
char *estr = sim_encode_quoted_string (&exp->buf[exp->buf_ins-ep->size], ep->size);
|
char *estr = sim_encode_quoted_string (&exp->buf[exp->buf_ins-ep->size], ep->size);
|
||||||
char *mstr = sim_encode_quoted_string (ep->match, ep->size);
|
char *mstr = sim_encode_quoted_string (ep->match, ep->size);
|
||||||
|
|
||||||
sim_debug (exp->dbit, exp->dptr, "Checking String[%d:%d]: %s\n", exp->buf_ins-ep->size, ep->size, estr);
|
sim_debug (exp->dbit, exp->dptr, "Checking String[%" SIZE_T_FMT "u:%" SIZE_T_FMT "u]: %s\n",
|
||||||
|
exp->buf_ins - ep->size, ep->size, estr);
|
||||||
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
sim_debug (exp->dbit, exp->dptr, "Against Match Data: %s\n", mstr);
|
||||||
free (estr);
|
free (estr);
|
||||||
free (mstr);
|
free (mstr);
|
||||||
|
@ -13375,7 +13392,8 @@ if (exp->buf_ins == exp->buf_size) { /* At end of match buffe
|
||||||
memmove (exp->buf, &exp->buf[exp->buf_size/2], exp->buf_size-(exp->buf_size/2));
|
memmove (exp->buf, &exp->buf[exp->buf_size/2], exp->buf_size-(exp->buf_size/2));
|
||||||
exp->buf_ins -= exp->buf_size/2;
|
exp->buf_ins -= exp->buf_size/2;
|
||||||
exp->buf_data = exp->buf_ins;
|
exp->buf_data = exp->buf_ins;
|
||||||
sim_debug (exp->dbit, exp->dptr, "Buffer Full - sliding the last %d bytes to start of buffer new insert at: %d\n", (exp->buf_size/2), exp->buf_ins);
|
sim_debug (exp->dbit, exp->dptr, "Buffer Full - sliding the last %" SIZE_T_FMT "d bytes to start of buffer new insert at: %" SIZE_T_FMT "d\n",
|
||||||
|
exp->buf_size / 2, exp->buf_ins);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
exp->buf_ins = 0; /* wrap around to beginning */
|
exp->buf_ins = 0; /* wrap around to beginning */
|
||||||
|
@ -13424,10 +13442,10 @@ return SCPE_OK;
|
||||||
t_stat sim_send_input (SEND *snd, uint8 *data, size_t size, uint32 after, uint32 delay)
|
t_stat sim_send_input (SEND *snd, uint8 *data, size_t size, uint32 after, uint32 delay)
|
||||||
{
|
{
|
||||||
if (snd->extoff != 0) {
|
if (snd->extoff != 0) {
|
||||||
if (snd->insoff-snd->extoff > 0)
|
if (snd->insoff > snd->extoff)
|
||||||
memmove(snd->buffer, snd->buffer+snd->extoff, snd->insoff-snd->extoff);
|
memmove(snd->buffer, snd->buffer+snd->extoff, snd->insoff-snd->extoff);
|
||||||
snd->insoff -= snd->extoff;
|
snd->insoff -= snd->extoff;
|
||||||
snd->extoff -= snd->extoff;
|
snd->extoff = 0;
|
||||||
}
|
}
|
||||||
if (snd->insoff+size > snd->bufsize) {
|
if (snd->insoff+size > snd->bufsize) {
|
||||||
snd->bufsize = snd->insoff+size;
|
snd->bufsize = snd->insoff+size;
|
||||||
|
@ -13465,7 +13483,7 @@ uint32 after = get_default_env_parameter (dev_name, "SIM_SEND_AFTER", delay);
|
||||||
|
|
||||||
fprintf (st, "%s\n", tmxr_send_line_name (snd));
|
fprintf (st, "%s\n", tmxr_send_line_name (snd));
|
||||||
if (snd->extoff < snd->insoff) {
|
if (snd->extoff < snd->insoff) {
|
||||||
fprintf (st, " %d bytes of pending input Data:\n ", snd->insoff-snd->extoff);
|
fprintf (st, " %" SIZE_T_FMT "d bytes of pending input Data:\n ", snd->insoff-snd->extoff);
|
||||||
fprint_buffer_string (st, snd->buffer+snd->extoff, snd->insoff-snd->extoff);
|
fprint_buffer_string (st, snd->buffer+snd->extoff, snd->insoff-snd->extoff);
|
||||||
fprintf (st, "\n");
|
fprintf (st, "\n");
|
||||||
}
|
}
|
||||||
|
@ -13495,7 +13513,7 @@ return SCPE_OK;
|
||||||
|
|
||||||
t_bool sim_send_poll_data (SEND *snd, t_stat *stat)
|
t_bool sim_send_poll_data (SEND *snd, t_stat *stat)
|
||||||
{
|
{
|
||||||
if (snd && (snd->extoff < snd->insoff)) { /* pending input characters available? */
|
if ((NULL != snd) && (snd->extoff < snd->insoff)) { /* pending input characters available? */
|
||||||
if (sim_gtime() < snd->next_time) { /* too soon? */
|
if (sim_gtime() < snd->next_time) { /* too soon? */
|
||||||
*stat = SCPE_OK;
|
*stat = SCPE_OK;
|
||||||
sim_debug (snd->dbit, snd->dptr, "Too soon to inject next byte\n");
|
sim_debug (snd->dbit, snd->dptr, "Too soon to inject next byte\n");
|
||||||
|
@ -13533,7 +13551,7 @@ return msgbuf;
|
||||||
t_stat sim_string_to_stat (const char *cptr, t_stat *stat)
|
t_stat sim_string_to_stat (const char *cptr, t_stat *stat)
|
||||||
{
|
{
|
||||||
char gbuf[CBUFSIZE];
|
char gbuf[CBUFSIZE];
|
||||||
int32 cond;
|
t_stat cond;
|
||||||
|
|
||||||
*stat = SCPE_ARG;
|
*stat = SCPE_ARG;
|
||||||
cptr = get_glyph (cptr, gbuf, 0);
|
cptr = get_glyph (cptr, gbuf, 0);
|
||||||
|
@ -13547,8 +13565,10 @@ for (cond=0; cond <= (SCPE_MAX_ERR-SCPE_BASE); cond++)
|
||||||
if (0 == strcmp(gbuf, "OK"))
|
if (0 == strcmp(gbuf, "OK"))
|
||||||
cond = SCPE_OK;
|
cond = SCPE_OK;
|
||||||
if (cond == (1+SCPE_MAX_ERR-SCPE_BASE)) { /* not found? */
|
if (cond == (1+SCPE_MAX_ERR-SCPE_BASE)) { /* not found? */
|
||||||
if (0 == (cond = strtol(gbuf, NULL, 0))) /* try explicit number */
|
unsigned long numeric_cond = strtol(gbuf, NULL, 0);
|
||||||
|
if (0 == numeric_cond) /* try explicit number */
|
||||||
return SCPE_ARG;
|
return SCPE_ARG;
|
||||||
|
cond = (t_stat) numeric_cond;
|
||||||
}
|
}
|
||||||
*stat = cond;
|
*stat = cond;
|
||||||
if (cond > SCPE_MAX_ERR)
|
if (cond > SCPE_MAX_ERR)
|
||||||
|
@ -13961,9 +13981,9 @@ sim_printf ("%s: %s\n", msg, strerror (saved_errno));
|
||||||
t_stat sim_messagef (t_stat stat, const char* fmt, ...)
|
t_stat sim_messagef (t_stat stat, const char* fmt, ...)
|
||||||
{
|
{
|
||||||
char stackbuf[STACKBUFSIZE];
|
char stackbuf[STACKBUFSIZE];
|
||||||
int32 bufsize = sizeof(stackbuf);
|
size_t bufsize = sizeof(stackbuf);
|
||||||
char *buf = stackbuf;
|
char *buf = stackbuf;
|
||||||
int32 len;
|
size_t len;
|
||||||
va_list arglist;
|
va_list arglist;
|
||||||
t_bool inhibit_message = (!sim_show_message || (stat & SCPE_NOMESSAGE));
|
t_bool inhibit_message = (!sim_show_message || (stat & SCPE_NOMESSAGE));
|
||||||
char msg_prefix[32] = "";
|
char msg_prefix[32] = "";
|
||||||
|
@ -13988,7 +14008,7 @@ while (1) { /* format passed string, arg
|
||||||
|
|
||||||
/* If the formatted result didn't fit into the buffer, then grow the buffer and try again */
|
/* If the formatted result didn't fit into the buffer, then grow the buffer and try again */
|
||||||
|
|
||||||
if ((len < 0) || (len >= bufsize-1)) {
|
if (len >= bufsize-1) {
|
||||||
if (buf != stackbuf)
|
if (buf != stackbuf)
|
||||||
free (buf);
|
free (buf);
|
||||||
bufsize = bufsize * 2;
|
bufsize = bufsize * 2;
|
||||||
|
@ -14162,7 +14182,7 @@ void sim_data_trace(DEVICE *dptr, UNIT *uptr, const uint8 *data, const char *pos
|
||||||
if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) {
|
if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) {
|
||||||
_sim_debug_unit (reason, uptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, (unsigned int)len);
|
_sim_debug_unit (reason, uptr, "%s %s %slen: %08X\n", sim_uname(uptr), txt, position, (unsigned int)len);
|
||||||
if (data && len) {
|
if (data && len) {
|
||||||
unsigned int i, same, group, sidx, oidx, ridx, eidx, soff;
|
size_t i, same, group, sidx, oidx, ridx, eidx, soff;
|
||||||
char outbuf[80], strbuf[28], rad50buf[36], ebcdicbuf[32];
|
char outbuf[80], strbuf[28], rad50buf[36], ebcdicbuf[32];
|
||||||
static char hex[] = "0123456789ABCDEF";
|
static char hex[] = "0123456789ABCDEF";
|
||||||
static char rad50[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ$._0123456789";
|
static char rad50[] = " ABCDEFGHIJKLMNOPQRSTUVWXYZ$._0123456789";
|
||||||
|
@ -14207,7 +14227,8 @@ if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (same > 0) {
|
if (same > 0) {
|
||||||
_sim_debug_unit (reason, uptr, "%04X thru %04X same as above\n", i-(16*same), i-1);
|
_sim_debug_unit (reason, uptr, "%04" SIZE_T_FMT "X thru %04" SIZE_T_FMT "X same as above\n",
|
||||||
|
i-(16*same), i - 1);
|
||||||
same = 0;
|
same = 0;
|
||||||
}
|
}
|
||||||
group = (((len - i) > 16) ? 16 : (len - i));
|
group = (((len - i) > 16) ? 16 : (len - i));
|
||||||
|
@ -14255,10 +14276,11 @@ if (sim_deb && ((dptr->dctrl | (uptr ? uptr->dctrl : 0)) & reason)) {
|
||||||
strbuf[soff+sidx] = '\0';
|
strbuf[soff+sidx] = '\0';
|
||||||
ebcdicbuf[eidx] = '\0';
|
ebcdicbuf[eidx] = '\0';
|
||||||
rad50buf[ridx] = '\0';
|
rad50buf[ridx] = '\0';
|
||||||
_sim_debug_unit (reason, uptr, "%04X%-48s %s%s%s\n", i, outbuf, strbuf, ebcdicbuf, rad50buf);
|
_sim_debug_unit (reason, uptr, "%04" SIZE_T_FMT "X%-48s %s%s%s\n", i, outbuf, strbuf, ebcdicbuf, rad50buf);
|
||||||
}
|
}
|
||||||
if (same > 0) {
|
if (same > 0) {
|
||||||
_sim_debug_unit (reason, uptr, "%04X thru %04X same as above\n", i-(16*same), (unsigned int)(len-1));
|
_sim_debug_unit (reason, uptr, "%04" SIZE_T_FMT "X thru %04" SIZE_T_FMT "X same as above\n",
|
||||||
|
(i-(16*same)), len - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14385,7 +14407,7 @@ return _process_cmd ("curl", cptr);
|
||||||
#define blankch(x) ((x) == ' ' || (x) == '\t')
|
#define blankch(x) ((x) == ' ' || (x) == '\t')
|
||||||
|
|
||||||
typedef struct topic {
|
typedef struct topic {
|
||||||
uint32 level;
|
size_t level;
|
||||||
char *title;
|
char *title;
|
||||||
char *label;
|
char *label;
|
||||||
struct topic *parent;
|
struct topic *parent;
|
||||||
|
@ -14394,7 +14416,7 @@ typedef struct topic {
|
||||||
char *text;
|
char *text;
|
||||||
size_t len;
|
size_t len;
|
||||||
uint32 flags;
|
uint32 flags;
|
||||||
uint32 kidwid;
|
size_t kidwid;
|
||||||
#define HLP_MAGIC_TOPIC 1
|
#define HLP_MAGIC_TOPIC 1
|
||||||
} TOPIC;
|
} TOPIC;
|
||||||
|
|
||||||
|
@ -14600,7 +14622,7 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
topic = topic->parent;
|
topic = topic->parent;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (n > topic->level +1) { /* Skipping down more than 1 */
|
if (n > topic->level + 1) { /* Skipping down more than 1 */
|
||||||
FAIL (SCPE_ARG, Level not contiguous, htext); /* E.g. 1 3, not reasonable */
|
FAIL (SCPE_ARG, Level not contiguous, htext); /* E.g. 1 3, not reasonable */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14652,7 +14674,7 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
|
|
||||||
children = (TOPIC **) realloc (topic->children,
|
children = (TOPIC **) realloc (topic->children,
|
||||||
(topic->kids +1) * sizeof (TOPIC *));
|
(topic->kids +1) * sizeof (TOPIC *));
|
||||||
if (!children) {
|
if (NULL == children) {
|
||||||
free (newt->title);
|
free (newt->title);
|
||||||
free (newt);
|
free (newt);
|
||||||
FAIL (SCPE_MEM, No memory, NULL);
|
FAIL (SCPE_MEM, No memory, NULL);
|
||||||
|
@ -14667,7 +14689,7 @@ for (hblock = astrings; (htext = *hblock) != NULL; hblock++) {
|
||||||
sprintf (nbuf, ".%u", topic->kids);
|
sprintf (nbuf, ".%u", topic->kids);
|
||||||
n = strlen (topic->label) + strlen (nbuf) + 1;
|
n = strlen (topic->label) + strlen (nbuf) + 1;
|
||||||
newt->label = (char *) malloc (n);
|
newt->label = (char *) malloc (n);
|
||||||
if (!newt->label) {
|
if (NULL == newt->label) {
|
||||||
free (newt->title);
|
free (newt->title);
|
||||||
topic->children[topic->kids -1] = NULL;
|
topic->children[topic->kids -1] = NULL;
|
||||||
free (newt);
|
free (newt);
|
||||||
|
@ -15029,7 +15051,7 @@ while (TRUE) {
|
||||||
w = 4 + topic->kidwid;
|
w = 4 + topic->kidwid;
|
||||||
fputc ('\n', st);
|
fputc ('\n', st);
|
||||||
}
|
}
|
||||||
fprintf (st, " %-*s", topic->kidwid, tbuf);
|
fprintf (st, " %-*s", (int) topic->kidwid, tbuf);
|
||||||
}
|
}
|
||||||
fprintf (st, "\n\n");
|
fprintf (st, "\n\n");
|
||||||
if (flag & SCP_HELP_ONECMD) {
|
if (flag & SCP_HELP_ONECMD) {
|
||||||
|
@ -15836,7 +15858,7 @@ if (sim_isalpha (*data) || (*data == '_')) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
gptr = _sim_get_env_special (data, string, string_size - 1);
|
gptr = _sim_get_env_special (data, string, string_size - 1);
|
||||||
if (gptr) {
|
if (NULL != gptr) {
|
||||||
*svalue = strtotsv(string, &gptr, 0);
|
*svalue = strtotsv(string, &gptr, 0);
|
||||||
sprint_val (string, *svalue, 10, string_size - 1, PV_LEFTSIGN);
|
sprint_val (string, *svalue, 10, string_size - 1, PV_LEFTSIGN);
|
||||||
sim_debug (SIM_DBG_EXP_EVAL, &sim_scp_dev, "[Value: %s=%s]\n", data, string);
|
sim_debug (SIM_DBG_EXP_EVAL, &sim_scp_dev, "[Value: %s=%s]\n", data, string);
|
||||||
|
@ -16041,10 +16063,13 @@ MFlush (MFILE *f)
|
||||||
f->pos = 0;
|
f->pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FMwrite() returns 1 (TRUE) if all data was writting, 0 (FALSE) indicates
|
||||||
|
fewer than the requested number of bytes were written. N.B. this function
|
||||||
|
is only called in one place and its return value isn't checked.*/
|
||||||
static int
|
static int
|
||||||
FMwrite (FILE *fout, MFILE *fdata)
|
FMwrite (FILE *fout, MFILE *fdata)
|
||||||
{
|
{
|
||||||
int ret = fwrite (fdata->buf, 1, fdata->pos, fout);
|
int ret = fwrite (fdata->buf, 1, fdata->pos, fout) == fdata->pos;
|
||||||
|
|
||||||
MFlush (fdata);
|
MFlush (fdata);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -16067,7 +16092,7 @@ free (f);
|
||||||
static t_stat sim_sanity_check_register_declarations (DEVICE **devices)
|
static t_stat sim_sanity_check_register_declarations (DEVICE **devices)
|
||||||
{
|
{
|
||||||
t_stat stat = SCPE_OK;
|
t_stat stat = SCPE_OK;
|
||||||
int i;
|
size_t i;
|
||||||
DEVICE *dptr;
|
DEVICE *dptr;
|
||||||
MFILE *f = MOpen ();
|
MFILE *f = MOpen ();
|
||||||
|
|
||||||
|
@ -16078,8 +16103,8 @@ for (i = 0; (dptr = devices[i]) != NULL; i++) {
|
||||||
REG *rptr;
|
REG *rptr;
|
||||||
|
|
||||||
for (rptr = dptr->registers; (rptr != NULL) && (rptr->name != NULL); rptr++) {
|
for (rptr = dptr->registers; (rptr != NULL) && (rptr->name != NULL); rptr++) {
|
||||||
uint32 rsz = SZ_R(rptr);
|
size_t rsz = SZ_R(rptr);
|
||||||
uint32 memsize = ((rptr->flags & REG_FIT) || (rptr->depth > 1)) ? rptr->depth * rsz : 4;
|
size_t memsize = ((rptr->flags & REG_FIT) || (rptr->depth > 1)) ? rptr->depth * rsz : 4;
|
||||||
t_bool Bad;
|
t_bool Bad;
|
||||||
|
|
||||||
if (((rptr->width + rptr->offset + CHAR_BIT - 1) / CHAR_BIT) >= sizeof(size_map) / sizeof(size_map[0])) {
|
if (((rptr->width + rptr->offset + CHAR_BIT - 1) / CHAR_BIT) >= sizeof(size_map) / sizeof(size_map[0])) {
|
||||||
|
@ -16092,8 +16117,8 @@ for (i = 0; (dptr = devices[i]) != NULL; i++) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sim_switches & SWMASK ('R')) /* Debug output */
|
if (sim_switches & SWMASK ('R')) /* Debug output */
|
||||||
sim_printf ("%5s:%-9.9s %s(rdx=%u, wd=%u, off=%u, dep=%u, strsz=%u, objsz=%u, elesz=%u, rsz=%u, %s %s%s membytes=%u, macro=%s)\n", dptr->name, rptr->name, rptr->macro,
|
sim_printf ("%5s:%-9.9s %s(rdx=%u, wd=%u, off=%u, dep=%u, strsz=%" SIZE_T_FMT "u, objsz=%" SIZE_T_FMT "u, elesz=%" SIZE_T_FMT "u, rsz=%" SIZE_T_FMT "u, %s %s%s membytes=%" SIZE_T_FMT "u, macro=%s)\n", dptr->name, rptr->name, rptr->macro,
|
||||||
rptr->radix, rptr->width, rptr->offset, rptr->depth, (uint32)rptr->stride, (uint32)rptr->obj_size, (uint32)rptr->size, rsz, rptr->desc ? rptr->desc : "",
|
rptr->radix, rptr->width, rptr->offset, rptr->depth, rptr->stride, rptr->obj_size, rptr->size, rsz, rptr->desc ? rptr->desc : "",
|
||||||
(rptr->flags & REG_FIT) ? "REG_FIT" : "", (rptr->flags & REG_VMIO) ? " REG_VMIO" : "",
|
(rptr->flags & REG_FIT) ? "REG_FIT" : "", (rptr->flags & REG_VMIO) ? " REG_VMIO" : "",
|
||||||
memsize, rptr->macro ? rptr->macro : "");
|
memsize, rptr->macro ? rptr->macro : "");
|
||||||
|
|
||||||
|
|
6
scp.h
6
scp.h
|
@ -184,8 +184,8 @@ CONST char *get_range (DEVICE *dptr, CONST char *cptr, t_addr *lo, t_addr *hi,
|
||||||
uint32 rdx, t_addr max, char term);
|
uint32 rdx, t_addr max, char term);
|
||||||
t_stat sim_set_environment (int32 flag, CONST char *cptr);
|
t_stat sim_set_environment (int32 flag, CONST char *cptr);
|
||||||
t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
|
t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
|
||||||
char *sim_encode_quoted_string (const uint8 *iptr, uint32 size);
|
char *sim_encode_quoted_string (const uint8 *iptr, size_t size);
|
||||||
void fprint_buffer_string (FILE *st, const uint8 *buf, uint32 size);
|
void fprint_buffer_string (FILE *st, const uint8 *buf, size_t size);
|
||||||
t_value strtotv (CONST char *cptr, CONST char **endptr, uint32 radix);
|
t_value strtotv (CONST char *cptr, CONST char **endptr, uint32 radix);
|
||||||
t_svalue strtotsv (CONST char *inptr, CONST char **endptr, uint32 radix);
|
t_svalue strtotsv (CONST char *inptr, CONST char **endptr, uint32 radix);
|
||||||
int Fprintf (FILE *f, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
|
int Fprintf (FILE *f, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
|
||||||
|
@ -196,7 +196,7 @@ int Fprintf (FILE *f, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
|
||||||
t_stat sim_set_memory_load_file (const unsigned char *data, size_t size);
|
t_stat sim_set_memory_load_file (const unsigned char *data, size_t size);
|
||||||
int Fgetc (FILE *f);
|
int Fgetc (FILE *f);
|
||||||
t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
|
t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
|
||||||
t_stat sprint_val (char *buf, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
|
t_stat sprint_val (char *buf, t_value val, uint32 rdx, size_t wid, uint32 fmt);
|
||||||
t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format);
|
t_stat sim_print_val (t_value val, uint32 radix, uint32 width, uint32 format);
|
||||||
const char *sim_fmt_secs (double seconds);
|
const char *sim_fmt_secs (double seconds);
|
||||||
const char *sim_fmt_numeric (double number);
|
const char *sim_fmt_numeric (double number);
|
||||||
|
|
22
sim_card.c
22
sim_card.c
|
@ -250,7 +250,10 @@ static const uint16 ascii_to_dec_029[128] = {
|
||||||
0x604, 0x602, 0x601, 0xA00, 0xC00, 0x600, 0x700,0xf000
|
0x604, 0x602, 0x601, 0xA00, 0xC00, 0x600, 0x700,0xf000
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if SIMH_EVER_USES_THIS
|
||||||
|
/* This is a static const that isn't referenced in this code.
|
||||||
|
* Kept for historical refernce.
|
||||||
|
*/
|
||||||
static const uint16 ascii_to_hol_ebcdic[128] = {
|
static const uint16 ascii_to_hol_ebcdic[128] = {
|
||||||
/* Control */
|
/* Control */
|
||||||
0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000, /*0-37*/
|
0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000,0xf000, /*0-37*/
|
||||||
|
@ -294,6 +297,7 @@ static const uint16 ascii_to_hol_ebcdic[128] = {
|
||||||
/* X18 X78 Y18 XYT18 */
|
/* X18 X78 Y18 XYT18 */
|
||||||
0x604, 0x602, 0x601, 0x902, 0x806, 0x502, 0xF02,0xf000
|
0x604, 0x602, 0x601, 0x902, 0x806, 0x502, 0xF02,0xf000
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
const char sim_ascii_to_six[128] = {
|
const char sim_ascii_to_six[128] = {
|
||||||
/* Control */
|
/* Control */
|
||||||
|
@ -662,8 +666,8 @@ sim_card_eof(UNIT *uptr)
|
||||||
|
|
||||||
struct _card_buffer {
|
struct _card_buffer {
|
||||||
uint8 buffer[8192+500]; /* Buffer data */
|
uint8 buffer[8192+500]; /* Buffer data */
|
||||||
int len; /* Amount of data in buffer */
|
size_t len; /* Amount of data in buffer */
|
||||||
int size; /* Size of last card read */
|
size_t size; /* Size of last card read */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int _cmpcard(const uint8 *p, const char *s) {
|
static int _cmpcard(const uint8 *p, const char *s) {
|
||||||
|
@ -681,9 +685,9 @@ t_stat
|
||||||
_sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*image)[80]) {
|
_sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*image)[80]) {
|
||||||
unsigned int mode;
|
unsigned int mode;
|
||||||
uint16 temp;
|
uint16 temp;
|
||||||
int i;
|
size_t i;
|
||||||
char c;
|
char c;
|
||||||
int col;
|
size_t col;
|
||||||
|
|
||||||
sim_debug(DEBUG_CARD, dptr, "Read card ");
|
sim_debug(DEBUG_CARD, dptr, "Read card ");
|
||||||
memset(image, 0, 160);
|
memset(image, 0, 160);
|
||||||
|
@ -836,7 +840,7 @@ _sim_parse_card(UNIT *uptr, DEVICE *dptr, struct _card_buffer *buf, uint16 (*ima
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end_card:
|
end_card:
|
||||||
sim_debug(DEBUG_CARD, dptr, "-%d-", i);
|
sim_debug(DEBUG_CARD, dptr, "-%" SIZE_T_FMT "u-", i);
|
||||||
|
|
||||||
/* Scan to end of line, ignore anything after last column */
|
/* Scan to end of line, ignore anything after last column */
|
||||||
while (buf->buffer[i] != '\n' && buf->buffer[i] != '\r' && i < buf->len) {
|
while (buf->buffer[i] != '\n' && buf->buffer[i] != '\r' && i < buf->len) {
|
||||||
|
@ -969,9 +973,9 @@ _sim_read_deck(UNIT * uptr, int eof)
|
||||||
struct _card_buffer buf;
|
struct _card_buffer buf;
|
||||||
struct card_context *data;
|
struct card_context *data;
|
||||||
DEVICE *dptr;
|
DEVICE *dptr;
|
||||||
int i;
|
size_t i;
|
||||||
int j;
|
size_t j;
|
||||||
int l;
|
size_t l;
|
||||||
int cards = 0;
|
int cards = 0;
|
||||||
t_stat r = SCPE_OK;
|
t_stat r = SCPE_OK;
|
||||||
|
|
||||||
|
|
|
@ -530,8 +530,8 @@ struct BITSAMPLE_REG {
|
||||||
};
|
};
|
||||||
typedef struct REMOTE REMOTE;
|
typedef struct REMOTE REMOTE;
|
||||||
struct REMOTE {
|
struct REMOTE {
|
||||||
int32 buf_size;
|
size_t buf_size;
|
||||||
int32 buf_ptr;
|
size_t buf_ptr;
|
||||||
char *buf;
|
char *buf;
|
||||||
char *act_buf;
|
char *act_buf;
|
||||||
size_t act_buf_size;
|
size_t act_buf_size;
|
||||||
|
@ -908,7 +908,7 @@ if ((!sim_oline) && (sim_log)) {
|
||||||
sim_oline = NULL;
|
sim_oline = NULL;
|
||||||
if ((rem->act == NULL) &&
|
if ((rem->act == NULL) &&
|
||||||
(!tmxr_input_pending_ln (lp))) {
|
(!tmxr_input_pending_ln (lp))) {
|
||||||
int32 unwritten;
|
size_t unwritten;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
unwritten = tmxr_send_buffered_data (lp);
|
unwritten = tmxr_send_buffered_data (lp);
|
||||||
|
@ -952,7 +952,7 @@ sim_switches = saved_switches; /* restore original switches */
|
||||||
|
|
||||||
/* Clear pending actions */
|
/* Clear pending actions */
|
||||||
|
|
||||||
static char *sim_rem_clract (int32 line)
|
static char *sim_rem_clract (size_t line)
|
||||||
{
|
{
|
||||||
REMOTE *rem = &sim_rem_consoles[line];
|
REMOTE *rem = &sim_rem_consoles[line];
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ return rem->act = NULL;
|
||||||
|
|
||||||
/* Set up pending actions */
|
/* Set up pending actions */
|
||||||
|
|
||||||
static void sim_rem_setact (int32 line, const char *action)
|
static void sim_rem_setact (size_t line, const char *action)
|
||||||
{
|
{
|
||||||
if (action) {
|
if (action) {
|
||||||
size_t act_size = strlen (action) + 1;
|
size_t act_size = strlen (action) + 1;
|
||||||
|
@ -981,7 +981,7 @@ else
|
||||||
|
|
||||||
/* Get next pending action, if any */
|
/* Get next pending action, if any */
|
||||||
|
|
||||||
static char *sim_rem_getact (int32 line, char *buf, int32 size)
|
static char *sim_rem_getact (size_t line, char *buf, size_t size)
|
||||||
{
|
{
|
||||||
char *ep;
|
char *ep;
|
||||||
size_t lnt;
|
size_t lnt;
|
||||||
|
@ -1296,10 +1296,10 @@ return stat;
|
||||||
|
|
||||||
t_stat sim_rem_con_repeat_svc (UNIT *uptr)
|
t_stat sim_rem_con_repeat_svc (UNIT *uptr)
|
||||||
{
|
{
|
||||||
int line = uptr - rem_con_repeat_units;
|
size_t line = uptr - rem_con_repeat_units;
|
||||||
REMOTE *rem = &sim_rem_consoles[line];
|
REMOTE *rem = &sim_rem_consoles[line];
|
||||||
|
|
||||||
sim_debug (DBG_REP, &sim_remote_console, "sim_rem_con_repeat_svc(line=%d) - interval=%d usecs\n", line, rem->repeat_interval);
|
sim_debug (DBG_REP, &sim_remote_console, "sim_rem_con_repeat_svc(line=%" SIZE_T_FMT "u) - interval=%d usecs\n", line, rem->repeat_interval);
|
||||||
if (rem->repeat_interval) {
|
if (rem->repeat_interval) {
|
||||||
rem->repeat_pending = TRUE;
|
rem->repeat_pending = TRUE;
|
||||||
sim_activate_after (uptr, rem->repeat_interval); /* reschedule */
|
sim_activate_after (uptr, rem->repeat_interval); /* reschedule */
|
||||||
|
@ -1362,10 +1362,10 @@ for (line = 0; line < sim_rem_con_tmxr.lines; line++)
|
||||||
|
|
||||||
t_stat sim_rem_con_smp_collect_svc (UNIT *uptr)
|
t_stat sim_rem_con_smp_collect_svc (UNIT *uptr)
|
||||||
{
|
{
|
||||||
int line = uptr - rem_con_smp_smpl_units;
|
size_t line = uptr - rem_con_smp_smpl_units;
|
||||||
REMOTE *rem = &sim_rem_consoles[line];
|
REMOTE *rem = &sim_rem_consoles[line];
|
||||||
|
|
||||||
sim_debug (DBG_SAM, &sim_remote_console, "sim_rem_con_smp_collect_svc(line=%d) - interval=%d, dither=%d%%\n", line, rem->smp_sample_interval, rem->smp_sample_dither_pct);
|
sim_debug (DBG_SAM, &sim_remote_console, "sim_rem_con_smp_collect_svc(line=%" SIZE_T_FMT "u) - interval=%d, dither=%d%%\n", line, rem->smp_sample_interval, rem->smp_sample_dither_pct);
|
||||||
if (rem->smp_sample_interval && (rem->smp_reg_count != 0)) {
|
if (rem->smp_sample_interval && (rem->smp_reg_count != 0)) {
|
||||||
int32 event_time = rem->smp_sample_interval;
|
int32 event_time = rem->smp_sample_interval;
|
||||||
|
|
||||||
|
|
34
sim_defs.h
34
sim_defs.h
|
@ -274,11 +274,9 @@ typedef uint32 t_value;
|
||||||
#if defined (USE_INT64) && defined (USE_ADDR64) /* 64b address */
|
#if defined (USE_INT64) && defined (USE_ADDR64) /* 64b address */
|
||||||
typedef t_uint64 t_addr;
|
typedef t_uint64 t_addr;
|
||||||
#define T_ADDR_W 64
|
#define T_ADDR_W 64
|
||||||
#define T_ADDR_FMT LL_FMT
|
|
||||||
#else /* 32b address */
|
#else /* 32b address */
|
||||||
typedef uint32 t_addr;
|
typedef uint32 t_addr;
|
||||||
#define T_ADDR_W 32
|
#define T_ADDR_W 32
|
||||||
#define T_ADDR_FMT ""
|
|
||||||
#endif /* end 64b address */
|
#endif /* end 64b address */
|
||||||
|
|
||||||
#if defined (_WIN32)
|
#if defined (_WIN32)
|
||||||
|
@ -294,14 +292,11 @@ typedef uint32 t_addr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (_WIN32) /* Actually, a GCC issue */
|
#if defined (_WIN32) /* Actually, a GCC issue */
|
||||||
#define LL_FMT "I64"
|
|
||||||
#define LL_TYPE long long
|
#define LL_TYPE long long
|
||||||
#else
|
#else
|
||||||
#if defined (__VAX) /* No 64 bit ints on VAX */
|
#if defined (__VAX) /* No 64 bit ints on VAX */
|
||||||
#define LL_FMT "l"
|
|
||||||
#define LL_TYPE long
|
#define LL_TYPE long
|
||||||
#else
|
#else
|
||||||
#define LL_FMT "ll"
|
|
||||||
#define LL_TYPE long long
|
#define LL_TYPE long long
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -615,7 +610,7 @@ struct UNIT {
|
||||||
uint16 us10; /* device specific */
|
uint16 us10; /* device specific */
|
||||||
uint32 disk_type; /* Disk specific info */
|
uint32 disk_type; /* Disk specific info */
|
||||||
void *tmxr; /* TMXR linkage */
|
void *tmxr; /* TMXR linkage */
|
||||||
uint32 recsize; /* Tape specific info */
|
size_t recsize; /* Tape specific info */
|
||||||
t_addr tape_eom; /* Tape specific info */
|
t_addr tape_eom; /* Tape specific info */
|
||||||
t_bool (*cancel)(UNIT *);
|
t_bool (*cancel)(UNIT *);
|
||||||
double usecs_remaining; /* time balance for long delays */
|
double usecs_remaining; /* time balance for long delays */
|
||||||
|
@ -800,8 +795,8 @@ struct MTAB {
|
||||||
/* Search table */
|
/* Search table */
|
||||||
|
|
||||||
struct SCHTAB {
|
struct SCHTAB {
|
||||||
int32 logic; /* logical operator */
|
size_t logic; /* logical operator */
|
||||||
int32 boolop; /* boolean operator */
|
size_t boolop; /* boolean operator */
|
||||||
uint32 count; /* value count in mask and comp arrays */
|
uint32 count; /* value count in mask and comp arrays */
|
||||||
t_value *mask; /* mask for logical */
|
t_value *mask; /* mask for logical */
|
||||||
t_value *comp; /* comparison for boolean */
|
t_value *comp; /* comparison for boolean */
|
||||||
|
@ -836,7 +831,7 @@ struct BRKTYPTAB {
|
||||||
|
|
||||||
struct EXPTAB {
|
struct EXPTAB {
|
||||||
uint8 *match; /* match string */
|
uint8 *match; /* match string */
|
||||||
uint32 size; /* match string size */
|
size_t size; /* match string size */
|
||||||
char *match_pattern; /* match pattern for format */
|
char *match_pattern; /* match pattern for format */
|
||||||
int32 cnt; /* proceed count */
|
int32 cnt; /* proceed count */
|
||||||
uint32 after; /* delay before halting */
|
uint32 after; /* delay before halting */
|
||||||
|
@ -859,11 +854,11 @@ struct EXPECT {
|
||||||
DEVICE *dptr; /* Device (for Debug) */
|
DEVICE *dptr; /* Device (for Debug) */
|
||||||
uint32 dbit; /* Debugging Bit */
|
uint32 dbit; /* Debugging Bit */
|
||||||
EXPTAB *rules; /* match rules */
|
EXPTAB *rules; /* match rules */
|
||||||
int32 size; /* count of match rules */
|
size_t size; /* count of match rules */
|
||||||
uint8 *buf; /* buffer of output data which has produced */
|
uint8 *buf; /* buffer of output data which has produced */
|
||||||
uint32 buf_ins; /* buffer insertion point for the next output data */
|
size_t buf_ins; /* buffer insertion point for the next output data */
|
||||||
uint32 buf_size; /* buffer size */
|
size_t buf_size; /* buffer size */
|
||||||
uint32 buf_data; /* count of data in buffer */
|
size_t buf_data; /* count of data in buffer */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Send Context */
|
/* Send Context */
|
||||||
|
@ -877,8 +872,8 @@ struct SEND {
|
||||||
double next_time; /* execution time when next data can be sent */
|
double next_time; /* execution time when next data can be sent */
|
||||||
uint8 *buffer; /* buffer */
|
uint8 *buffer; /* buffer */
|
||||||
size_t bufsize; /* buffer size */
|
size_t bufsize; /* buffer size */
|
||||||
int32 insoff; /* insert offset */
|
size_t insoff; /* insert offset */
|
||||||
int32 extoff; /* extra offset */
|
size_t extoff; /* extra offset */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Debug table */
|
/* Debug table */
|
||||||
|
@ -1137,6 +1132,15 @@ struct MEMFILE {
|
||||||
#include "sim_console.h"
|
#include "sim_console.h"
|
||||||
#include "sim_timer.h"
|
#include "sim_timer.h"
|
||||||
#include "sim_fio.h"
|
#include "sim_fio.h"
|
||||||
|
#include "sim_printf_fmts.h"
|
||||||
|
|
||||||
|
/* General-purpose error value for size_t types; check using
|
||||||
|
equality.*/
|
||||||
|
|
||||||
|
#define GENERIC_SIZE_T_ERROR ((size_t) -1)
|
||||||
|
|
||||||
|
#define SIZE_T_IO_ERROR GENERIC_SIZE_T_ERROR
|
||||||
|
#define IS_SIZE_T_IO_ERROR(thing) ((thing) == GENERIC_SIZE_T_ERROR)
|
||||||
|
|
||||||
/* Macro to ALWAYS execute the specified expression and fail if it evaluates to false. */
|
/* Macro to ALWAYS execute the specified expression and fail if it evaluates to false. */
|
||||||
/* This replaces any references to "assert()" which should never be invoked */
|
/* This replaces any references to "assert()" which should never be invoked */
|
||||||
|
|
13
sim_fio.c
13
sim_fio.c
|
@ -161,8 +161,7 @@ return c;
|
||||||
|
|
||||||
void sim_buf_copy_swapped (void *dbuf, const void *sbuf, size_t size, size_t count)
|
void sim_buf_copy_swapped (void *dbuf, const void *sbuf, size_t size, size_t count)
|
||||||
{
|
{
|
||||||
size_t j;
|
size_t j, k;
|
||||||
int32 k;
|
|
||||||
const unsigned char *sptr = (const unsigned char *)sbuf;
|
const unsigned char *sptr = (const unsigned char *)sbuf;
|
||||||
unsigned char *dptr = (unsigned char *)dbuf;
|
unsigned char *dptr = (unsigned char *)dbuf;
|
||||||
|
|
||||||
|
@ -171,8 +170,12 @@ if (sim_end || (size == sizeof (char))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (j = 0; j < count; j++) { /* loop on items */
|
for (j = 0; j < count; j++) { /* loop on items */
|
||||||
for (k = (int32)(size - 1); k >= 0; k--)
|
/* Unsigned countdown loop. Predecrement k before it's used inside the
|
||||||
*(dptr + k) = *sptr++;
|
loop so that k == 0 in the loop body to process the last item, then
|
||||||
|
terminate. Initialize k to size for the same reason: the predecrement
|
||||||
|
gives us size - 1 in the loop body. */
|
||||||
|
for (k = size; k > 0; /* empty */)
|
||||||
|
*(dptr + --k) = *sptr++;
|
||||||
dptr = dptr + size;
|
dptr = dptr + size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -953,6 +956,8 @@ char *sim_getcwd (char *buf, size_t buf_size)
|
||||||
{
|
{
|
||||||
#if defined (VMS)
|
#if defined (VMS)
|
||||||
return getcwd (buf, buf_size, 0);
|
return getcwd (buf, buf_size, 0);
|
||||||
|
#elif defined(__MINGW64__) ||defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
|
return _getcwd (buf, (int) buf_size);
|
||||||
#else
|
#else
|
||||||
return getcwd (buf, buf_size);
|
return getcwd (buf, buf_size);
|
||||||
#endif
|
#endif
|
||||||
|
|
11
sim_imd.c
11
sim_imd.c
|
@ -123,7 +123,8 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose)
|
||||||
uint8 sectorHeadMap[256];
|
uint8 sectorHeadMap[256];
|
||||||
uint8 sectorCylMap[256];
|
uint8 sectorCylMap[256];
|
||||||
uint32 sectorSize, sectorHeadwithFlags, sectRecordType;
|
uint32 sectorSize, sectorHeadwithFlags, sectRecordType;
|
||||||
uint32 hdrBytes, i;
|
size_t hdrBytes;
|
||||||
|
uint32 i;
|
||||||
uint8 start_sect;
|
uint8 start_sect;
|
||||||
|
|
||||||
uint32 TotalSectorCount = 0;
|
uint32 TotalSectorCount = 0;
|
||||||
|
@ -160,7 +161,7 @@ static t_stat diskParse(DISK_INFO *myDisk, uint32 isVerbose)
|
||||||
break; /* detected end of IMD file */
|
break; /* detected end of IMD file */
|
||||||
|
|
||||||
if (hdrBytes != 5) {
|
if (hdrBytes != 5) {
|
||||||
sim_printf("SIM_IMD: Header read returned %d bytes instead of 5.\n", hdrBytes);
|
sim_printf("SIM_IMD: Header read returned %" SIZE_T_FMT "u bytes instead of 5.\n", hdrBytes);
|
||||||
return (SCPE_OPENERR);
|
return (SCPE_OPENERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +362,8 @@ t_stat diskCreate(FILE *fileref, const char *ctlr_comment)
|
||||||
char *curptr;
|
char *curptr;
|
||||||
char *result;
|
char *result;
|
||||||
uint8 answer;
|
uint8 answer;
|
||||||
int32 len, remaining;
|
size_t len;
|
||||||
|
size_t remaining;
|
||||||
|
|
||||||
if(fileref == NULL) {
|
if(fileref == NULL) {
|
||||||
return (SCPE_OPENERR);
|
return (SCPE_OPENERR);
|
||||||
|
@ -386,7 +388,8 @@ t_stat diskCreate(FILE *fileref, const char *ctlr_comment)
|
||||||
remaining = MAX_COMMENT_LEN;
|
remaining = MAX_COMMENT_LEN;
|
||||||
do {
|
do {
|
||||||
sim_printf("IMD> ");
|
sim_printf("IMD> ");
|
||||||
result = fgets(curptr, remaining - 3, stdin);
|
/* ISO C says that the 2nd argument is an int, not size_t. */
|
||||||
|
result = fgets(curptr, (int) (remaining - 3), stdin);
|
||||||
if ((result == NULL) || (strcmp(curptr, ".\n") == 0)) {
|
if ((result == NULL) || (strcmp(curptr, ".\n") == 0)) {
|
||||||
remaining = 0;
|
remaining = 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
94
sim_printf_fmts.h
Normal file
94
sim_printf_fmts.h
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
|
||||||
|
* sim_printf_fmts.h
|
||||||
|
*
|
||||||
|
* Cross-platform printf() formats for simh data types. Refactored out to
|
||||||
|
* this header so that these formats are avaiable to more than SCP.
|
||||||
|
*
|
||||||
|
* Author: B. Scott Michel
|
||||||
|
*
|
||||||
|
* "scooter me fecit"
|
||||||
|
*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#if !defined(SIM_PRINTF_H)
|
||||||
|
|
||||||
|
/* cross-platform printf() format specifiers:
|
||||||
|
*
|
||||||
|
* Note: MS apparently does recognize "ll" as "l" in its printf() routines, but "I64" is
|
||||||
|
* preferred for 64-bit types.
|
||||||
|
*
|
||||||
|
* MinGW note: __MINGW64__ and __MINGW32__ are both defined by 64-bit gcc. Check
|
||||||
|
* for __MINGW64__ before __MINGW32__.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* LL_FMT: long long format modifier, e.g. "%016" LL_FMT "x"
|
||||||
|
* SIZE_T: size_t format modifier, e.g., "%" SIZE_T_FMT "u" (can use "d", but you will
|
||||||
|
* probably get a warning.)
|
||||||
|
* T_UINT64_FMT: t_uint64 format modifier, e.g. "%016" T_UINT64_FMT "x"
|
||||||
|
* T_INT64_FMT: t_int64 format modifier, e.g., "%" T_INT64_FMT "d"
|
||||||
|
* POINTER_FMT: Format modifier for pointers, e.g. "%08" POINTER_FMT "X"
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined (_WIN32) || defined(_WIN64)
|
||||||
|
|
||||||
|
# if defined(__MINGW64__)
|
||||||
|
# define LL_FMT "I64"
|
||||||
|
# define SIZE_T_FMT "I64"
|
||||||
|
# elif defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
|
# define LL_FMT "ll"
|
||||||
|
# define SIZE_T_FMT "z"
|
||||||
|
# else
|
||||||
|
/* Graceful fail -- shouldn't ever default to this on a Windows platform. */
|
||||||
|
# define LL_FMT "ll"
|
||||||
|
# define SIZE_T_FMT "I32"
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define T_UINT64_FMT "I64"
|
||||||
|
# define T_INT64_FMT "I64"
|
||||||
|
# define POINTER_FMT "p"
|
||||||
|
|
||||||
|
#elif defined(__GNU_LIBRARY__) || defined(__GLIBC__) || defined(__GLIBC_MINOR__) || \
|
||||||
|
defined(__APPLE__)
|
||||||
|
|
||||||
|
/* GNU libc (Linux) and macOS */
|
||||||
|
# define LL_FMT "ll"
|
||||||
|
# define SIZE_T_FMT "z"
|
||||||
|
# define T_UINT64_FMT "ll"
|
||||||
|
# define T_INT64_FMT "ll"
|
||||||
|
# define POINTER_FMT "p"
|
||||||
|
|
||||||
|
#elif defined(__VAX)
|
||||||
|
|
||||||
|
/* No 64 bit ints on VAX, nothing special about size_t */
|
||||||
|
# define LL_FMT "l"
|
||||||
|
# define SIZE_T_FMT ""
|
||||||
|
# define T_UINT64_FMT ""
|
||||||
|
# define T_INT64_FMT ""
|
||||||
|
# define POINTER_FMT ""
|
||||||
|
|
||||||
|
#else
|
||||||
|
/* Defaults. */
|
||||||
|
# define LL_FMT "ll"
|
||||||
|
# define SIZE_T_FMT ""
|
||||||
|
# define T_UINT64_FMT ""
|
||||||
|
# define T_INT64_FMT ""
|
||||||
|
# define POINTER_FMT ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined (USE_INT64) && defined (USE_ADDR64)
|
||||||
|
# define T_ADDR_FMT T_UINT64_FMT
|
||||||
|
#else
|
||||||
|
# define T_ADDR_FMT ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined (USE_INT64)
|
||||||
|
# define T_VALUE_FMT T_UINT64_FMT
|
||||||
|
# define T_SVALUE_FMT T_INT64_FMT
|
||||||
|
#else
|
||||||
|
# define T_VALUE_FMT ""
|
||||||
|
# define T_SVALUE_FMT ""
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define SIM_PRINTF_H
|
||||||
|
#endif
|
69
sim_tape.c
69
sim_tape.c
|
@ -439,7 +439,7 @@ typedef struct HDR4 { /* Also EOF4, EOV4 */
|
||||||
} HDR4;
|
} HDR4;
|
||||||
|
|
||||||
typedef struct TAPE_RECORD {
|
typedef struct TAPE_RECORD {
|
||||||
uint32 size;
|
size_t size;
|
||||||
uint8 data[1];
|
uint8 data[1];
|
||||||
} TAPE_RECORD;
|
} TAPE_RECORD;
|
||||||
|
|
||||||
|
@ -448,7 +448,7 @@ typedef struct MEMORY_TAPE {
|
||||||
uint32 file_count; /* number of labeled files */
|
uint32 file_count; /* number of labeled files */
|
||||||
uint32 record_count; /* number of entries in the record array */
|
uint32 record_count; /* number of entries in the record array */
|
||||||
uint32 array_size; /* allocated size of records array */
|
uint32 array_size; /* allocated size of records array */
|
||||||
uint32 block_size; /* tape block size */
|
size_t block_size; /* tape block size */
|
||||||
TAPE_RECORD **records;
|
TAPE_RECORD **records;
|
||||||
VOL1 vol1;
|
VOL1 vol1;
|
||||||
} MEMORY_TAPE;
|
} MEMORY_TAPE;
|
||||||
|
@ -505,7 +505,7 @@ static struct ansi_tape_parameters {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static MEMORY_TAPE *ansi_create_tape (const char *label, uint32 block_size, uint32 ansi_type);
|
static MEMORY_TAPE *ansi_create_tape (const char *label, size_t block_size, uint32 ansi_type);
|
||||||
static MEMORY_TAPE *memory_create_tape (void);
|
static MEMORY_TAPE *memory_create_tape (void);
|
||||||
static void memory_free_tape (void *vtape);
|
static void memory_free_tape (void *vtape);
|
||||||
static void sim_tape_add_ansi_entry (const char *directory,
|
static void sim_tape_add_ansi_entry (const char *directory,
|
||||||
|
@ -513,7 +513,7 @@ static void sim_tape_add_ansi_entry (const char *directory,
|
||||||
t_offset FileSize,
|
t_offset FileSize,
|
||||||
const struct stat *filestat,
|
const struct stat *filestat,
|
||||||
void *context);
|
void *context);
|
||||||
static t_bool memory_tape_add_block (MEMORY_TAPE *tape, uint8 *block, uint32 size);
|
static t_bool memory_tape_add_block (MEMORY_TAPE *tape, uint8 *block, size_t size);
|
||||||
|
|
||||||
typedef struct DOS11_HDR {
|
typedef struct DOS11_HDR {
|
||||||
uint16 fname[2]; /* File name (RAD50 - 6 characters) */
|
uint16 fname[2]; /* File name (RAD50 - 6 characters) */
|
||||||
|
@ -810,7 +810,8 @@ switch (MT_GET_FMT (uptr)) {
|
||||||
tape->block_size = uptr->recsize;
|
tape->block_size = uptr->recsize;
|
||||||
block = (uint8 *)calloc (1, tape->block_size + 3);
|
block = (uint8 *)calloc (1, tape->block_size + 3);
|
||||||
while (!feof (f) && !error) {
|
while (!feof (f) && !error) {
|
||||||
if (fgets ((char *)block, tape->block_size + 3, f)) {
|
/* fgest() read size is int, cast accordingly. */
|
||||||
|
if (fgets ((char *)block, (int) (tape->block_size + 3), f)) {
|
||||||
size_t len = strlen ((char *)block);
|
size_t len = strlen ((char *)block);
|
||||||
|
|
||||||
while ((len > 0) &&
|
while ((len > 0) &&
|
||||||
|
@ -890,7 +891,7 @@ switch (MT_GET_FMT (uptr)) {
|
||||||
if (uptr->recsize == 0)
|
if (uptr->recsize == 0)
|
||||||
uptr->recsize = TAR_DFLT_RECSIZE; /* Apply default block size */
|
uptr->recsize = TAR_DFLT_RECSIZE; /* Apply default block size */
|
||||||
if ((uptr->recsize % 512) != 0)
|
if ((uptr->recsize % 512) != 0)
|
||||||
return sim_messagef (SCPE_ARG, "TAR format block size of %u is not a multiple of 512\n", uptr->recsize);
|
return sim_messagef (SCPE_ARG, "TAR format block size of %" SIZE_T_FMT "u is not a multiple of 512\n", uptr->recsize);
|
||||||
sim_switches |= SWMASK ('E'); /* The TAR file must exist */
|
sim_switches |= SWMASK ('E'); /* The TAR file must exist */
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
|
@ -1228,7 +1229,7 @@ t_awshdr awshdr;
|
||||||
size_t rdcnt;
|
size_t rdcnt;
|
||||||
t_mtrlnt buffer [256]; /* local tape buffer */
|
t_mtrlnt buffer [256]; /* local tape buffer */
|
||||||
t_addr saved_pos = uptr->pos;
|
t_addr saved_pos = uptr->pos;
|
||||||
uint32 bufcntr, bufcap; /* buffer counter and capacity */
|
size_t bufcntr, bufcap; /* buffer counter and capacity */
|
||||||
int32 runaway_counter, sizeof_gap; /* bytes remaining before runaway and bytes per gap */
|
int32 runaway_counter, sizeof_gap; /* bytes remaining before runaway and bytes per gap */
|
||||||
t_stat status = MTSE_OK;
|
t_stat status = MTSE_OK;
|
||||||
|
|
||||||
|
@ -1524,7 +1525,8 @@ switch (f) { /* otherwise the read method
|
||||||
if (tape->records[uptr->pos]->size == 0)
|
if (tape->records[uptr->pos]->size == 0)
|
||||||
status = MTSE_TMK;
|
status = MTSE_TMK;
|
||||||
else
|
else
|
||||||
*bc = tape->records[uptr->pos]->size;
|
/* Should check range here. */
|
||||||
|
*bc = (t_mtrlnt) tape->records[uptr->pos]->size;
|
||||||
++uptr->pos;
|
++uptr->pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1602,7 +1604,7 @@ t_tpclnt tpcbc;
|
||||||
t_awshdr awshdr;
|
t_awshdr awshdr;
|
||||||
size_t rdcnt;
|
size_t rdcnt;
|
||||||
t_mtrlnt buffer [256]; /* local tape buffer */
|
t_mtrlnt buffer [256]; /* local tape buffer */
|
||||||
uint32 bufcntr, bufcap; /* buffer counter and capacity */
|
size_t bufcntr, bufcap; /* buffer counter and capacity */
|
||||||
int32 runaway_counter, sizeof_gap; /* bytes remaining before runaway and bytes per gap */
|
int32 runaway_counter, sizeof_gap; /* bytes remaining before runaway and bytes per gap */
|
||||||
t_stat status = MTSE_OK;
|
t_stat status = MTSE_OK;
|
||||||
|
|
||||||
|
@ -1643,7 +1645,7 @@ switch (f) { /* otherwise the read me
|
||||||
bufcap = 1; /* then start with just one marker */
|
bufcap = 1; /* then start with just one marker */
|
||||||
|
|
||||||
else if (uptr->pos < sizeof (buffer)) /* otherwise if less than a full buffer remains */
|
else if (uptr->pos < sizeof (buffer)) /* otherwise if less than a full buffer remains */
|
||||||
bufcap = (uint32) uptr->pos /* then reduce the capacity accordingly */
|
bufcap = (size_t) uptr->pos /* then reduce the capacity accordingly */
|
||||||
/ sizeof (t_mtrlnt);
|
/ sizeof (t_mtrlnt);
|
||||||
|
|
||||||
else /* otherwise reset the capacity */
|
else /* otherwise reset the capacity */
|
||||||
|
@ -1859,7 +1861,8 @@ switch (f) { /* otherwise the read me
|
||||||
if (tape->records[uptr->pos]->size == 0)
|
if (tape->records[uptr->pos]->size == 0)
|
||||||
status = MTSE_TMK;
|
status = MTSE_TMK;
|
||||||
else
|
else
|
||||||
*bc = tape->records[uptr->pos]->size;
|
/* Should check range here. */
|
||||||
|
*bc = (t_mtrlnt) tape->records[uptr->pos]->size;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -2152,7 +2155,7 @@ if (bc)
|
||||||
(void)sim_fwrite (buf, sizeof (uint8), bc, uptr->fileref);
|
(void)sim_fwrite (buf, sizeof (uint8), bc, uptr->fileref);
|
||||||
uptr->pos += sizeof (awshdr) + bc;
|
uptr->pos += sizeof (awshdr) + bc;
|
||||||
if ((!replacing_record) || (bc == 0)) {
|
if ((!replacing_record) || (bc == 0)) {
|
||||||
awshdr.prelen = bc;
|
awshdr.prelen = (t_awslnt) bc;
|
||||||
awshdr.nxtlen = 0;
|
awshdr.nxtlen = 0;
|
||||||
awshdr.rectyp = AWS_TMK;
|
awshdr.rectyp = AWS_TMK;
|
||||||
(void)sim_fwrite (&awshdr, sizeof (t_awslnt), 3, uptr->fileref);
|
(void)sim_fwrite (&awshdr, sizeof (t_awslnt), 3, uptr->fileref);
|
||||||
|
@ -2178,13 +2181,13 @@ if (ctx == NULL) /* if not properly attac
|
||||||
if (sim_tape_wrp (uptr)) /* write prot? */
|
if (sim_tape_wrp (uptr)) /* write prot? */
|
||||||
return MTSE_WRP;
|
return MTSE_WRP;
|
||||||
(void)sim_tape_seek (uptr, uptr->pos); /* set pos */
|
(void)sim_tape_seek (uptr, uptr->pos); /* set pos */
|
||||||
(void)sim_fwrite (&dat, sizeof (t_mtrlnt), 1, uptr->fileref);
|
(void)sim_fwrite (&dat, sizeof (uint32), 1, uptr->fileref);
|
||||||
if (ferror (uptr->fileref)) { /* error? */
|
if (ferror (uptr->fileref)) { /* error? */
|
||||||
MT_SET_PNU (uptr);
|
MT_SET_PNU (uptr);
|
||||||
return sim_tape_ioerr (uptr);
|
return sim_tape_ioerr (uptr);
|
||||||
}
|
}
|
||||||
sim_debug_unit (MTSE_DBG_STR, uptr, "wr_lnt: lnt: %d, pos: %" T_ADDR_FMT "u\n", dat, uptr->pos);
|
sim_debug_unit (MTSE_DBG_STR, uptr, "wr_lnt: lnt: %d, pos: %" T_ADDR_FMT "u\n", dat, uptr->pos);
|
||||||
uptr->pos = uptr->pos + sizeof (t_mtrlnt); /* move tape */
|
uptr->pos = uptr->pos + sizeof (uint32); /* move tape */
|
||||||
if (uptr->pos > uptr->tape_eom)
|
if (uptr->pos > uptr->tape_eom)
|
||||||
uptr->tape_eom = uptr->pos; /* update EOM */
|
uptr->tape_eom = uptr->pos; /* update EOM */
|
||||||
return MTSE_OK;
|
return MTSE_OK;
|
||||||
|
@ -3503,7 +3506,7 @@ return msgbuf;
|
||||||
static t_stat sim_tape_validate_tape (UNIT *uptr)
|
static t_stat sim_tape_validate_tape (UNIT *uptr)
|
||||||
{
|
{
|
||||||
t_addr saved_pos = uptr->pos;
|
t_addr saved_pos = uptr->pos;
|
||||||
uint32 data_total = 0;
|
size_t data_total = 0;
|
||||||
uint32 tapemark_total = 0;
|
uint32 tapemark_total = 0;
|
||||||
uint32 record_total = 0;
|
uint32 record_total = 0;
|
||||||
uint32 unique_record_sizes = 0;
|
uint32 unique_record_sizes = 0;
|
||||||
|
@ -3638,7 +3641,7 @@ if (!stop_cpu) { /* if SIGINT didn't interrupt the scan */
|
||||||
if ((r != MTSE_EOM) || (sim_switches & SWMASK ('V')) || (sim_switches & SWMASK ('L')) ||
|
if ((r != MTSE_EOM) || (sim_switches & SWMASK ('V')) || (sim_switches & SWMASK ('L')) ||
|
||||||
(remaining_data > 0) ||
|
(remaining_data > 0) ||
|
||||||
(unique_record_sizes > 2 * tapemark_total)) {
|
(unique_record_sizes > 2 * tapemark_total)) {
|
||||||
sim_messagef (SCPE_OK, "%s %u bytes of tape data (%u record%s, %u tapemark%s)\n",
|
sim_messagef (SCPE_OK, "%s %" SIZE_T_FMT "u bytes of tape data (%u record%s, %u tapemark%s)\n",
|
||||||
(r != MTSE_EOM) ? "After processing" : "contains", data_total,
|
(r != MTSE_EOM) ? "After processing" : "contains", data_total,
|
||||||
record_total, (record_total == 1) ? "" : "s",
|
record_total, (record_total == 1) ? "" : "s",
|
||||||
tapemark_total, (tapemark_total == 1) ? "" : "s");
|
tapemark_total, (tapemark_total == 1) ? "" : "s");
|
||||||
|
@ -3889,7 +3892,8 @@ FILE *fTAR2 = NULL;
|
||||||
FILE *fBIN = NULL;
|
FILE *fBIN = NULL;
|
||||||
FILE *fTXT = NULL;
|
FILE *fTXT = NULL;
|
||||||
FILE *fVAR = NULL;
|
FILE *fVAR = NULL;
|
||||||
int i, j, k;
|
int i;
|
||||||
|
size_t j, k;
|
||||||
t_tpclnt tpclnt;
|
t_tpclnt tpclnt;
|
||||||
t_mtrlnt mtrlnt;
|
t_mtrlnt mtrlnt;
|
||||||
t_awslnt awslnt;
|
t_awslnt awslnt;
|
||||||
|
@ -3986,13 +3990,16 @@ if (aws_stat != MTSE_OK) {
|
||||||
sim_switches = saved_switches;
|
sim_switches = saved_switches;
|
||||||
stat = SCPE_OK;
|
stat = SCPE_OK;
|
||||||
for (i=0; i<files; i++) {
|
for (i=0; i<files; i++) {
|
||||||
int rec_size = 1 + (rand () % max_size);
|
size_t rec_size = 1 + (rand () % max_size);
|
||||||
|
|
||||||
awslnt = mtrlnt = tpclnt = rec_size;
|
awslnt = (t_awslnt) rec_size;
|
||||||
for (j=0; j<records; j++) {
|
mtrlnt = (t_mtrlnt) rec_size;
|
||||||
|
tpclnt = (t_tpclnt) rec_size;
|
||||||
|
/* records: should ensure that records > 0, otherwise, this test becomes interesting. */
|
||||||
|
for (j=0; j < (size_t) records; j++) {
|
||||||
awsrec_typ = AWS_REC;
|
awsrec_typ = AWS_REC;
|
||||||
if (sim_switches & SWMASK ('V'))
|
if (sim_switches & SWMASK ('V'))
|
||||||
sim_printf ("Writing %d byte record\n", rec_size);
|
sim_printf ("Writing %" SIZE_T_FMT "u byte record\n", rec_size);
|
||||||
for (k=0; k<rec_size; k++)
|
for (k=0; k<rec_size; k++)
|
||||||
buf[k] = rand () & 0xFF;
|
buf[k] = rand () & 0xFF;
|
||||||
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, fSIMH);
|
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, fSIMH);
|
||||||
|
@ -4013,7 +4020,7 @@ for (i=0; i<files; i++) {
|
||||||
(void)sim_fwrite (buf, 1, rec_size, fAWS);
|
(void)sim_fwrite (buf, 1, rec_size, fAWS);
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
(void)sim_fwrite (buf, 1, rec_size, fAWS3);
|
(void)sim_fwrite (buf, 1, rec_size, fAWS3);
|
||||||
stat = sim_tape_wrrecf (uptr, buf, rec_size);
|
stat = sim_tape_wrrecf (uptr, buf, (t_mtrlnt) rec_size);
|
||||||
if (MTSE_OK != stat)
|
if (MTSE_OK != stat)
|
||||||
goto Done_Files;
|
goto Done_Files;
|
||||||
if (rec_size & 1) {
|
if (rec_size & 1) {
|
||||||
|
@ -4080,7 +4087,7 @@ mtrlnt = 25;
|
||||||
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
||||||
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
||||||
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
(void)sim_fwrite (&mtrlnt, sizeof (mtrlnt), 1, uptr->fileref);
|
||||||
for (j=0; j<records; j++) {
|
for (j=0; j < (size_t) records; j++) {
|
||||||
memset (buf, j, 10240);
|
memset (buf, j, 10240);
|
||||||
(void)sim_fwrite (buf, 1, 10240, fTAR);
|
(void)sim_fwrite (buf, 1, 10240, fTAR);
|
||||||
(void)sim_fwrite (buf, 1, 10240, fTAR2);
|
(void)sim_fwrite (buf, 1, 10240, fTAR2);
|
||||||
|
@ -4530,7 +4537,8 @@ static void ansi_fill_text_buffer (FILE *f, char *buf, size_t buf_size, size_t r
|
||||||
start = ftell (f);
|
start = ftell (f);
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
break;
|
break;
|
||||||
if (!fgets (tmp, buf_size, f))
|
/* Note: fgets() uses int for number of chars to read, cast accordingly. */
|
||||||
|
if (!fgets (tmp, (int) buf_size, f))
|
||||||
break;
|
break;
|
||||||
rec_size = strlen (tmp);
|
rec_size = strlen (tmp);
|
||||||
if (!fixed_text) {
|
if (!fixed_text) {
|
||||||
|
@ -4561,7 +4569,8 @@ static void ansi_fill_text_buffer (FILE *f, char *buf, size_t buf_size, size_t r
|
||||||
memcpy (buf + offset, tmp, move_size);
|
memcpy (buf + offset, tmp, move_size);
|
||||||
offset += move_size;
|
offset += move_size;
|
||||||
if (offset == buf_size) {
|
if (offset == buf_size) {
|
||||||
(void)fseek (f, start + move_size, SEEK_SET);
|
/* fseek() uses long for offsets, cast accordingly. */
|
||||||
|
(void)fseek (f, start + (long) move_size, SEEK_SET);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4575,7 +4584,7 @@ static void ansi_fill_text_buffer (FILE *f, char *buf, size_t buf_size, size_t r
|
||||||
free (tmp);
|
free (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static t_bool memory_tape_add_block (MEMORY_TAPE *tape, uint8 *block, uint32 size)
|
static t_bool memory_tape_add_block (MEMORY_TAPE *tape, uint8 *block, size_t size)
|
||||||
{
|
{
|
||||||
TAPE_RECORD *rec;
|
TAPE_RECORD *rec;
|
||||||
|
|
||||||
|
@ -4630,9 +4639,9 @@ static uint16 dos11_ascR50(char *inbuf)
|
||||||
{
|
{
|
||||||
uint16 value;
|
uint16 value;
|
||||||
|
|
||||||
value = (strchr (rad50, *inbuf++) - rad50) * 03100;
|
value = (uint16) (strchr (rad50, *inbuf++) - rad50) * 03100;
|
||||||
value += (strchr (rad50, *inbuf++) - rad50) * 050;
|
value += (uint16) (strchr (rad50, *inbuf++) - rad50) * 050;
|
||||||
value += (strchr (rad50, *inbuf++) - rad50);
|
value += (uint16) (strchr (rad50, *inbuf++) - rad50);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -4887,7 +4896,7 @@ else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_TAPE *ansi_create_tape (const char *label, uint32 block_size, uint32 ansi_type)
|
MEMORY_TAPE *ansi_create_tape (const char *label, size_t block_size, uint32 ansi_type)
|
||||||
{
|
{
|
||||||
MEMORY_TAPE *tape = memory_create_tape ();
|
MEMORY_TAPE *tape = memory_create_tape ();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue