changes to build with VSI C compiler

The changes from past OpenVMS compilers are #ifdef'd VMS9
This commit is contained in:
nhmall
2023-05-22 14:43:10 -04:00
parent 2dfe4c2a27
commit 68b8e84aa3
10 changed files with 145 additions and 9 deletions

View File

@@ -3251,6 +3251,9 @@ ATTRNORETURN extern void error (const char *, ...) PRINTF_F(1, 2) NORETURN;
#ifdef TIMED_DELAY
extern void msleep(unsigned);
#endif
#ifdef ENHANCED_SYMBOLS
extern void tty_utf8graphics_fixup(void);
#endif
/* ### vmsunix.c ### */

View File

@@ -17,7 +17,21 @@
* extra room for patching longer values into an existing executable.
*/
#define Local_WIZARD "NHWIZARD\0\0\0\0"
#define Local_HACKDIR "DISK$USERS:[GAMES.NETHACK.3_5_X.PLAY]\0\0\0\0\0\0\0\0"
#define Local_HACKDIR "DISK$USERS:[GAMES.NETHACK.3_7_X.PLAY]\0\0\0\0\0\0\0\0"
/*
* VMS9 uses a VSI C compiler and supports C99.
* It is the first version available on X86_64 so we can auto-detect it there.
*/
#ifdef __x86_64
#define VMS9
#endif
/* #define VMS9 */
#ifdef VMS9
/* for version.c */
typedef int64_t ssize_t;
#endif
/*
* This section cleans up the stuff done in config.h so that it
@@ -162,9 +176,11 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then
/* config.h defines USE_ISAAC64; we'll use it on Alpha or IA64 but not VAX;
it overrides RANDOM */
#if !defined(VMS9)
#if (defined(VAX) || defined(vax) || defined(__vax)) && defined(USE_ISAAC64)
#undef ISAAC64
#endif
#endif
#define FCMASK 0660 /* file creation mask */
@@ -214,6 +230,20 @@ PANICTRACE_GDB=2 #at conclusion of panic, show a call traceback and then
#endif
#endif
#ifdef VMS9
#define NO_TERMCAP_HEADERS
#undef __HIDE_FORBIDDEN_NAMES
/* C99 */
#include <types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <stat.h>
#include <errno.h>
#include <stsdef.h>
#endif
#ifdef _DECC_V4_SOURCE
/* <types.h> excludes some necessary typedefs when _DECC_V4_SOURCE is defined
*/
@@ -234,9 +264,15 @@ typedef __gid_t gid_t;
#define __MODE_T
typedef __mode_t mode_t;
#endif
#ifndef __OFF_T
#define __OFF_T
typedef int32_t off_t;
#endif
#endif /* _DECC_V4_SOURCE */
#include <time.h>
#ifndef VMS9
#if 0 /* <file.h> is missing for old gcc versions; skip it to save time */
#include <file.h>
#else /* values needed from missing include file */
@@ -246,6 +282,7 @@ typedef __mode_t mode_t;
#define O_CREAT 0x200
#define O_TRUNC 0x400
#endif
#endif
#define tgetch vms_getchar
@@ -272,6 +309,7 @@ typedef __mode_t mode_t;
# endif
#endif
#if !defined(VMS9)
#ifndef __GNUC__
#ifndef bcopy
#define bcopy(s, d, n) memcpy((d), (s), (n)) /* vaxcrtl */
@@ -290,12 +328,16 @@ typedef __mode_t mode_t;
#else
#define unlink(f0) remove(f0) /* vaxcrtl, decc$shr */
#endif
#endif /* VMS9 */
#define C$$TRANSLATE(n) c__translate(n) /* vmsfiles.c */
#if !defined(VMS9)
/* VMS global names are case insensitive... */
#define An vms_an
#define The vms_the
#define Shk_Your vms_shk_your
#endif /* VMS9 */
/* avoid global symbol in Alpha/VMS V1.5 STARLET library (link trouble) */
#define ospeed vms_ospeed

View File

@@ -382,7 +382,9 @@ done_intr(int sig_unused UNUSED)
done_stopprint++;
(void) signal(SIGINT, SIG_IGN);
#if defined(UNIX) || defined(VMS)
#ifndef VMS9
(void) signal(SIGQUIT, SIG_IGN);
#endif
#endif
return;
}
@@ -1389,7 +1391,9 @@ really_done(int how)
#ifndef NO_SIGNAL
(void) signal(SIGINT, (SIG_RET_TYPE) done_intr);
#if defined(UNIX) || defined(VMS) || defined(__EMX__)
#ifndef VMS9
(void) signal(SIGQUIT, (SIG_RET_TYPE) done_intr);
#endif
sethanguphandler(done_hangup);
#endif
#endif /* NO_SIGNAL */

View File

@@ -10,6 +10,12 @@
#include "config.h"
#include <ctype.h>
#ifdef VMS9
#include <descrip.h>
#include <lib$routines.h>
#include <starlet.h>
#endif
/* lint supression due to lack of extern.h */
int vms_link(const char *, const char *);
int vms_unlink(const char *);
@@ -27,8 +33,11 @@ int c__translate(int);
#ifndef C$$TRANSLATE /* don't rely on VAXCRTL's internal routine */
#define C$$TRANSLATE(status) (errno = EVMSERR, vaxc$errno = (status))
#endif
#ifndef VMS9
extern unsigned long sys$parse(), sys$search(), sys$enter(), sys$remove();
extern int VDECL(lib$match_cond, (int, int, ...));
#endif
#define vms_success(sts) ((sts) & 1) /* odd, */
#define vms_failure(sts) (!vms_success(sts)) /* even */

View File

@@ -11,6 +11,12 @@ unsigned long enable_broadcast_trapping(void);
unsigned long disable_broadcast_trapping(void);
struct mail_info *parse_next_broadcast(void);
#ifdef VMS9
#include <descrip.h>
#include <lib$routines.h>
#include <starlet.h>
#endif
#ifdef MAIL
#include "wintype.h"
#include "winprocs.h"
@@ -39,8 +45,13 @@ extern size_t strspn(const char *, const char *);
#ifndef __DECC
extern int VDECL(sscanf, (const char *, const char *, ...));
#endif
#ifdef VMS9
#include <smg$routines.h>
#else
extern unsigned long smg$create_pasteboard(), smg$get_broadcast_message(),
smg$set_broadcast_trapping(), smg$disable_broadcast_trapping();
#endif
extern volatile int broadcasts; /* defining declaration in mail.c */

View File

@@ -7,6 +7,12 @@
#include "hack.h"
#include "dlb.h"
#ifdef VMS9
#include <descrip.h>
#include <lib$routines.h>
#include <starlet.h>
#endif
#include <signal.h>
static void whoami(void);
@@ -389,7 +395,9 @@ byebye(void)
void (*hup)(int) ;
#ifdef SHELL
extern unsigned long dosh_pid, mail_pid;
#ifndef VMS9
extern unsigned long sys$delprc(unsigned long *, const genericptr_t);
#endif
/* clean up any subprocess we've spawned that may still be hanging around
*/

View File

@@ -4,6 +4,13 @@
#include "config.h"
#undef exit
#ifdef VMS9
#include <descrip.h>
#include <lib$routines.h>
#include <starlet.h>
#endif
#include <ssdef.h>
#include <stsdef.h>
@@ -13,7 +20,10 @@ ATTRNORETURN void vms_exit(int);
ATTRNORETURN void vms_abort(void);
/* first arg should be unsigned long but <lib$routines.h> has unsigned int */
#ifndef VMS9
extern void VDECL(lib$signal, (unsigned, ...));
#endif
/* terminate, converting Unix-style exit code into VMS status code */
ATTRNORETURN void

View File

@@ -9,6 +9,13 @@
#include "wintty.h"
#include "tcap.h"
#ifdef VMS9
#include <lib$routines.h>
#include <smg$routines.h>
#include <starlet.h>
#include <elfdef.h>
#endif
#include <descrip.h>
#include <iodef.h>
#ifndef __GNUC__
@@ -32,11 +39,16 @@
#include <errno.h>
#include <signal.h>
#ifndef VMS9
unsigned long lib$disable_ctrl(), lib$enable_ctrl();
unsigned long sys$assign(), sys$dassgn(), sys$qiow();
#endif
#ifndef USE_QIO_INPUT
#ifndef VMS9
unsigned long smg$create_virtual_keyboard(), smg$delete_virtual_keyboard(),
smg$read_keystroke(), smg$cancel_input();
#endif
#else
static short parse_function_key(int);
#endif
@@ -171,16 +183,16 @@ vms_getchar(void)
} else if (kb_buf == ESC || kb_buf == CSI || kb_buf == SS3) {
switch (parse_function_key((int) kb_buf)) {
case SMG$K_TRM_UP:
key = gc.Cmd.move_N;
key = gc.Cmd.dirchars[2];
break;
case SMG$K_TRM_DOWN:
key = gc.Cmd.move_S;
key = gc.Cmd.dirchars[6];
break;
case SMG$K_TRM_LEFT:
key = gc.Cmd.move_W;
key = gc.Cmd.dirchars[0];
break;
case SMG$K_TRM_RIGHT:
key = gc.Cmd.move_E;
key = gc.Cmd.dirchars[4];
break;
default:
key = ESC;
@@ -521,9 +533,11 @@ introff(void)
#ifdef TIMED_DELAY
#ifndef VMS9
extern unsigned long lib$emul(const long *, const long *, const long *,
long *);
extern unsigned long sys$schdwk(), sys$hiber();
#endif
#define VMS_UNITS_PER_SECOND 10000000L /* hundreds of nanoseconds, 1e-7 */
/* constant for conversion from milliseconds to VMS delta time (negative) */
@@ -563,7 +577,21 @@ VA_DECL(const char *, s)
VA_END();
#ifndef SAVE_ON_FATAL_ERROR
/* prevent vmsmain's exit handler byebye() from calling hangup() */
sethanguphandler((void (*)(int) )) SIG_DFL;
/* sethanguphandler((void (*)(int) )) SIG_DFL; */
sethanguphandler((SIG_RET_TYPE) SIG_DFL);
#endif
exit(EXIT_FAILURE);
}
#ifdef ENHANCED_SYMBOLS
/*
* set in tty_start_screen() and allows
* OS-specific changes that may be
* required for support of utf8.
* Currently a placeholder for VMS.
*/
void
tty_utf8graphics_fixup(void)
{
}
#endif /* ENHANCED_SYMBOLS */

View File

@@ -7,6 +7,14 @@
#include "hack.h"
#ifdef VMS9
#include <lib$routines.h>
#include <smg$routines.h>
#include <starlet.h>
#define sys$imgsta SYS$IMGSTA
#include <unixio.h>
#endif
#include <descrip.h>
#include <dvidef.h>
#include <jpidef.h>
@@ -25,10 +33,13 @@
extern int debuggable; /* defined in vmsmisc.c */
#ifndef VMS9
extern void VDECL(lib$signal, (unsigned, ...));
extern unsigned long sys$setprv();
extern unsigned long lib$getdvi(), lib$getjpi(), lib$spawn(), lib$attach();
extern unsigned long smg$init_term_table_by_type(), smg$del_term_table();
#endif
#define vms_ok(sts) ((sts) & 1) /* odd => success */
/* this could be static; it's only used within this file;
@@ -216,7 +227,10 @@ vms_define(const char *name, const char *value, int flag)
};
static struct itm3 itm_lst[] = { { 0, LNM$_STRING, 0, 0 }, { 0, 0 } };
struct dsc nam_dsc, val_dsc, tbl_dsc;
unsigned long result, sys$crelnm(), lib$set_logical();
unsigned long result;
#ifndef VMS9
unsigned long sys$crelnm(), lib$set_logical();
#endif
/* set up string descriptors */
nam_dsc.mbz = val_dsc.mbz = tbl_dsc.mbz = 0;
@@ -581,8 +595,11 @@ struct dsc {
char *adr;
}; /* descriptor */
typedef unsigned long vmscond; /* vms condition value */
#ifndef VMS9
vmscond lib$find_file(const struct dsc *, struct dsc *, genericptr *);
vmscond lib$find_file_end(void **);
#endif
/* collect a list of character names from all save files for this player */
int

View File

@@ -377,7 +377,9 @@ winch_handler(int sig_unused UNUSED)
#undef WINCH_MESSAGE
}
#endif
#ifndef VMS
getwindowsz();
#endif
/* For long running events such as multi-page menus and
* display_file(), we note the signal's occurance and
* hope the code there decides to handle the situation
@@ -3383,7 +3385,8 @@ g_putch(int in_ch)
}
#endif /* !WIN32CON */
#if defined(ENHANCED_SYMBOLS) && defined(UNIX)
#if defined(UNIX) || defined(VMS)
#if defined(ENHANCED_SYMBOLS)
void
g_pututf8(uint8 *utf8str)
{
@@ -3394,7 +3397,8 @@ g_pututf8(uint8 *utf8str)
}
return;
}
#endif /* ENHANCED_SYMBOLS && UNIX */
#endif /* ENHANCED_SYMBOLS */
#endif /* UNIX || VMS */
#ifdef CLIPPING
void