1
0
mirror of https://github.com/simh/simh.git synced 2026-01-11 23:52:58 +00:00

simulators with global variables PC, SP and BC: Avoid name space collisions.

Avoid potential name space collision for the global variables PC, SP and BC
when readline is dynamically loaded.  For some unknown reason, ncurses
exports these internal variables which may be needed in the context of
how ncurses is used by readline implementations.  In any case, these
variable names are common in simulators, so there is an undesired
interaction between simulator internal variables and the simplest
solution is to rename these simulator global variables where they exist.
Another alternative is to merely declare these variables static when
they happen to only be referenced in a single simulator source module.
This commit is contained in:
Peter Kooiman 2025-04-09 13:56:27 -10:00 committed by Mark Pizzolato
parent dab8053cf8
commit ef8f4f53a2
8 changed files with 3559 additions and 3540 deletions

View File

@ -40,3 +40,6 @@
#define STOP_IBKPT 3 /* breakpoint */
#define STOP_OPCODE 4
/* Rename of global BC and SP variables to avoid namespace conflicts on some platforms */
#define BC BC_Global
#define SP SP_Global

View File

@ -180,10 +180,10 @@ typedef struct {
/* storage for the rest of the registers */
uint32 PSW = 0; /* program status word */
uint32 A = 0; /* accumulator */
uint32 BC = 0; /* BC register pair */
static uint32 BC = 0; /* BC register pair */
uint32 DE = 0; /* DE register pair */
uint32 HL = 0; /* HL register pair */
uint32 SP = 0; /* Stack pointer */
static uint32 SP = 0; /* Stack pointer */
uint32 saved_PC = 0; /* program counter */
uint32 IM = 0; /* Interrupt Mask Register */
uint8 xack = 0; /* XACK signal */
@ -191,7 +191,7 @@ uint32 int_req = 0; /* Interrupt request */
uint8 INTA = 0; // interrupt acknowledge
uint16 PCX; /* External view of PC */
uint16 PCY; /* Internal view of PC */
uint16 PC;
static uint16 PC;
UNIT *uptr;
uint16 port; //port used in any IN/OUT
uint16 addr; //addr used for operand fetch

View File

@ -71,7 +71,8 @@ uint32 temp1, temp2, temp3, temp4, temp5, temp32, tempaddr32, EA;
int32 result;
uint64 totalexec;
int32 AX, BX, CX, DX, DI, SI, BP, SP, CS, DS, SS, ES, PSW, PCX, SGX, DISP, DATA8, DATA16;
int32 AX, BX, CX, DX, DI, SI, BP, CS, DS, SS, ES, PSW, PCX, SGX, DISP, DATA8, DATA16;
static int32 SP;
//extern uint16 VGA_SC[0x100], VGA_CRTC[0x100], VGA_ATTR[0x100], VGA_GC[0x100];
//extern uint8 updatedscreen;

View File

@ -31,6 +31,10 @@
#include "sim_defs.h" /* simulator defns */
/* Rename of global PC variable to avoid namespace conflicts on some platforms */
#define PC PC_Global
#if defined(USE_INT64) || defined(USE_ADDR64)
#error "LGP-30 does not support 64b values!"
#endif

View File

@ -51,6 +51,9 @@
#include "sim_defs.h" /* simulator defns */
/* Rename of global SP variable to avoid namespace conflicts on some platforms */
#define SP SP_Global
#if (defined(USE_INT64) && !defined(ECLIPSE)) || defined(USE_ADDR64)
#error "Nova does not support 64b values!"
#endif

View File

@ -30,6 +30,9 @@
#include "sim_defs.h" /* simulator defns */
/* Rename of global PC variable to avoid namespace conflicts on some platforms */
#define PC PC_Global
#if defined(USE_ADDR64)
#error "PDP-10 does not support 64b addresses!"
#endif

View File

@ -34,6 +34,10 @@
#include "sim_defs.h" /* simulator defns */
/* Rename of global PC variable to avoid namespace conflicts on some platforms */
#define PC PC_Global
#if defined(USE_INT64) || defined(USE_ADDR64)
#error "Sigma 32b does not support 64b values!"
#endif

View File

@ -27,9 +27,10 @@ Copyright (c) 2005-2012, William Beech
#include <ctype.h>
#include "sim_defs.h" // simulator defs
/* Rename of global PC variable to avoid namespace conflicts on some platforms */
/* Rename of global PC and SP variables to avoid namespace conflicts on some platforms */
#define PC PC_Global
#define SP SP_Global
//#define DONT_USE_INTERNAL_ROM 1