From 6487d319cd70b3d11c0bb676691a4f963ff2cb01 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sat, 9 Dec 2017 11:21:38 -0800 Subject: [PATCH] VMS Build: Restore VAX/VMS host build support The C RTL on the latest VAX/VMS does not provide a snprintf function. We provide a 'basic' one which meets the needs of simh as suggested by Jordi Guillaumes Pons. --- descrip.mms | 2 +- sim_defs.h | 4 ++++ sim_fio.c | 17 +++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/descrip.mms b/descrip.mms index a0283606..f2d38775 100644 --- a/descrip.mms +++ b/descrip.mms @@ -316,7 +316,7 @@ ATT3B2_SOURCE = $(ATT3B2_DIR)3B2_CPU.C,$(ATT3B2_DIR)3B2_DMAC.C,\ $(ATT3B2_DIR)3B2_IO.C,$(ATT3B2_DIR)3B2_IU.C,\ $(ATT3B2_DIR)3B2_MMU.C,$(ATT3B2_DIR)3B2_SYS.C,\ $(ATT3B2_DIR)3B2_SYSDEV.C -ALTAIR_OPTIONS = /INCL=($(SIMH_DIR),$(ATT3B2_DIR))/DEF=($(CC_DEFS)) +ATT3B2_OPTIONS = /INCL=($(SIMH_DIR),$(ATT3B2_DIR))/DEF=($(CC_DEFS)) # MITS Altair Simulator Definitions. # diff --git a/sim_defs.h b/sim_defs.h index e3d09f25..b0129533 100644 --- a/sim_defs.h +++ b/sim_defs.h @@ -115,6 +115,10 @@ #if defined(_MSC_VER) && (_MSC_VER < 1900) #define snprintf _snprintf /* poor man's snprintf which will work most of the time but has different return value */ #endif +#if defined(__VAX) +extern int sim_vax_snprintf(char *buf, size_t buf_size, const char *fmt, ...); +#define snprintf sim_vax_snprintf +#endif #include #include #include diff --git a/sim_fio.c b/sim_fio.c index 2f77b3d8..d05e18f3 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -599,3 +599,20 @@ free (shmem); } #endif + +#if defined(__VAX) +/* + * We privide a 'basic' snprintf, which 'might' overrun a buffer, but + * the actual use cases don't on other platforms and none of the callers + * care about the function return value. + */ +int sim_vax_snprintf(char *buf, size_t buf_size, const char *fmt, ...) +{ +va_list arglist; + +va_start (arglist, fmt); +vsprintf (buf, fmt, arglist); +va_end (arglist); +return 0; +} +#endif