Skip to content

Commit

Permalink
CMake: Ibm1130 simulator build updates
Browse files Browse the repository at this point in the history
- Add the missing ibm1130.rc GUI resource file to the Windows build so
  that the GUI renders correctly.

- Add a CMakeLists.txt for the IBM1130 utilities.

  The utilities install in the BIN/ibm1130-utilties subdirectory for
  Linux, macOS, and BIN/ibm1130-utilities/{Release|Debug} for Windows.

  Not currently part of the open-simh packaging.

- Add "TEST_ARGS" argument to CMake's add_simulator function to disable
  the IBM 1130 GUI when running RegisterSanityCheck. This fixes an edge
  case Heisenbug encountered during Github CI/CD tests where ibm1130
  appears to hang indefinitely. The cause is the GUI's Pump() thread
  function being prematurely terminated before all GUI resources are
  acquired. The net result is an infinite loop in the MS C runtime
  trying to exit the process while releasing half acquired resources.

  Note that this never shows up on non-Windows platforms or the SIMH
  makefile.

- Ibm1130/ibm1130_cr.c

  - Fix printf() warnings (format should be long, not int)
  - Signed/unsigned mismatch, size_t for array indexing

- utils:

  - Fix warnings in printf() statements (mostly) that are now errors
    identified by Ubuntu (Linux gcc) build.

  - Assignments to lvalue casts (e.g., "((uint16 *) buf) += nw") are no
    longer legitimate C.

  - Insert const-correctness where suggested, reduce scope on variables
    when possible and fix unsigned comparisons.

  - Make some allowances for MSVCRT deprecated function names.
  • Loading branch information
bscottm committed Mar 2, 2024
1 parent c47e933 commit 6a6cbcd
Show file tree
Hide file tree
Showing 18 changed files with 385 additions and 351 deletions.
9 changes: 7 additions & 2 deletions Ibm1130/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ add_simulator(ibm1130
ibm1130_t2741.c
INCLUDES
${CMAKE_CURRENT_SOURCE_DIR}
TEST_ARGS "-g"
LABEL Ibm1130
PKG_FAMILY ibm_family
TEST ibm1130)

if (WIN32)
## Add GUI support, compile in resources:
target_compile_definitions(ibm1130 PRIVATE GUI_SUPPORT)
## missing source in IBM1130? ## target_sources(ibm1130 PRIVATE ibm1130.c)
endif()
target_sources(ibm1130 PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/ibm1130.rc)
endif()

# IBM 1130 utilities:
add_subdirectory(utils)
18 changes: 10 additions & 8 deletions Ibm1130/ibm1130_cr.c
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ extern int cgi;
static int16 ascii_to_card[256];

static CPCODE *cardcode;
static int ncardcode;
static size_t ncardcode;
static FILE *deckfile = NULL;
static char tempfile[128];
static int any_punched = 0;
Expand Down Expand Up @@ -760,7 +760,7 @@ t_bool program_is_loaded = FALSE;

/* lookup_codetable - use code flag setting to get code table pointer and length */

static t_bool lookup_codetable (int32 match, CPCODE **pcode, int *pncode)
static t_bool lookup_codetable (int32 match, CPCODE **pcode, size_t *pncode)
{
switch (match) {
case CODE_029:
Expand Down Expand Up @@ -793,14 +793,16 @@ static t_bool lookup_codetable (int32 match, CPCODE **pcode, int *pncode)
t_stat set_active_cr_code (int match)
{
CPCODE *code;
int i, ncode;
size_t ncode;

SET_ACTCODE(cr_unit, match);

if (! lookup_codetable(match, &code, &ncode))
return SCPE_ARG;

if (code != NULL) { /* if an ASCII mode was selected */
size_t i;

memset(ascii_to_card, 0, sizeof(ascii_to_card));

for (i = 0; i < ncode; i++) /* set ascii to card code table */
Expand Down Expand Up @@ -881,7 +883,7 @@ static int32 guess_cr_code (void)
static t_stat cp_set_code (UNIT *uptr, int32 match, CONST char *cptr, void *desc)
{
CPCODE *code;
int ncode;
size_t ncode;

if (! lookup_codetable(match, &code, &ncode))
return SCPE_ARG;
Expand Down Expand Up @@ -1020,7 +1022,7 @@ t_stat cr_boot (int32 unitno, DEVICE *dptr)

char card_to_ascii (uint16 hol)
{
int i;
size_t i;

for (i = 0; i < ncardcode; i++)
if (cardcode[i].hollerith == hol)
Expand All @@ -1033,7 +1035,7 @@ char card_to_ascii (uint16 hol)

char hollerith_to_ascii (uint16 hol)
{
int i;
size_t i;

for (i = 0; i < ncardcode; i++)
if (cardcode_029[i].hollerith == hol)
Expand Down Expand Up @@ -2382,7 +2384,7 @@ static DWORD CALLBACK pcr_thread (LPVOID arg)
if (! GetOverlappedResult(hpcr, &ovRd, &nrcvd, TRUE))
report_error("PCR_Read", GetLastError());
else if (cr_unit.flags & UNIT_DEBUG)
printf("PCR_Read: event, %d rcvd\n", nrcvd);
printf("PCR_Read: event, %ld rcvd\n", nrcvd);
break;

case WAIT_OBJECT_0+1: /* write complete */
Expand All @@ -2391,7 +2393,7 @@ static DWORD CALLBACK pcr_thread (LPVOID arg)
if (! GetOverlappedResult(hpcr, &ovWr, &nwritten, TRUE))
report_error("PCR_Write", GetLastError());
else if (cr_unit.flags & UNIT_DEBUG)
printf("PCR_Write: event, %d sent\n", nwritten);
printf("PCR_Write: event, %ld sent\n", nwritten);
continue;

case WAIT_OBJECT_0+2: /* reset request from simulator */
Expand Down
31 changes: 31 additions & 0 deletions Ibm1130/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
## Additional IBM 1130 utilities. Note that these are packaged with the
## ibm1130software.zip file within the ibm1130.zip archive on ibm1130.org.
##
## Where do the resulting executables go?
## Not Windows: BIN/ibm1130-utils
## Windows: BIN/ibm1130-utils/<CONFIG>, where <CONFIG> is Debug, Release
##~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=

set(IBM1130_UTILS asm1130 bindump checkdisk disklist diskview mkboot punches)

## Each utility is created separately -- it could be a foreach loop at the
## risk of reducing future flexibility.

add_executable(asm1130 asm1130.c util_io.c)
add_executable(bindump bindump.c util_io.c)
add_executable(checkdisk checkdisk.c util_io.c)
add_executable(disklist disklist.c util_io.c)
add_executable(diskview diskview.c util_io.c)
add_executable(mkboot mkboot.c util_io.c)
add_executable(punches punches.c util_io.c)

## Set the executable output directory:
foreach(util IN LISTS IBM1130_UTILS)
set_target_properties(${util} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${SIMH_LEGACY_INSTALL}/ibm1130-utils/"
)
endforeach()

## Meta-target to build all of the utilites:
add_custom_target(ibm1130-utils DEPENDS ${IBM1130_UTILS})
Loading

0 comments on commit 6a6cbcd

Please sign in to comment.