diff --git a/include/extern.h b/include/extern.h index f05879cdd..d61dcfac3 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 ### */ diff --git a/include/vmsconf.h b/include/vmsconf.h index 78a7de6f6..ea6ef1af5 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -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 +#include +#include +#include +#include +#include +#include +#include +#endif + #ifdef _DECC_V4_SOURCE /* 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 + +#ifndef VMS9 #if 0 /* is missing for old gcc versions; skip it to save time */ #include #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 diff --git a/src/end.c b/src/end.c index f511bdfb8..ad03e8586 100644 --- a/src/end.c +++ b/src/end.c @@ -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 */ diff --git a/sys/vms/vmsfiles.c b/sys/vms/vmsfiles.c index 6283faac0..faf9c729f 100644 --- a/sys/vms/vmsfiles.c +++ b/sys/vms/vmsfiles.c @@ -10,6 +10,12 @@ #include "config.h" #include +#ifdef VMS9 +#include +#include +#include +#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 */ diff --git a/sys/vms/vmsmail.c b/sys/vms/vmsmail.c index 47085181c..0ef545762 100644 --- a/sys/vms/vmsmail.c +++ b/sys/vms/vmsmail.c @@ -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 +#include +#include +#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 +#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 */ diff --git a/sys/vms/vmsmain.c b/sys/vms/vmsmain.c index 6fe999995..afdadf7d0 100644 --- a/sys/vms/vmsmain.c +++ b/sys/vms/vmsmain.c @@ -7,6 +7,12 @@ #include "hack.h" #include "dlb.h" +#ifdef VMS9 +#include +#include +#include +#endif + #include 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 */ diff --git a/sys/vms/vmsmisc.c b/sys/vms/vmsmisc.c index e0f195ad4..75d00f444 100644 --- a/sys/vms/vmsmisc.c +++ b/sys/vms/vmsmisc.c @@ -4,6 +4,13 @@ #include "config.h" #undef exit + +#ifdef VMS9 +#include +#include +#include +#endif + #include #include @@ -13,7 +20,10 @@ ATTRNORETURN void vms_exit(int); ATTRNORETURN void vms_abort(void); /* first arg should be unsigned long but has unsigned int */ + +#ifndef VMS9 extern void VDECL(lib$signal, (unsigned, ...)); +#endif /* terminate, converting Unix-style exit code into VMS status code */ ATTRNORETURN void diff --git a/sys/vms/vmstty.c b/sys/vms/vmstty.c index a09ae331a..fd8e507c4 100644 --- a/sys/vms/vmstty.c +++ b/sys/vms/vmstty.c @@ -9,6 +9,13 @@ #include "wintty.h" #include "tcap.h" +#ifdef VMS9 +#include +#include +#include +#include +#endif + #include #include #ifndef __GNUC__ @@ -32,11 +39,16 @@ #include #include + +#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 */ + diff --git a/sys/vms/vmsunix.c b/sys/vms/vmsunix.c index 7f840be98..5031e45f0 100644 --- a/sys/vms/vmsunix.c +++ b/sys/vms/vmsunix.c @@ -7,6 +7,14 @@ #include "hack.h" +#ifdef VMS9 +#include +#include +#include +#define sys$imgsta SYS$IMGSTA +#include +#endif + #include #include #include @@ -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 diff --git a/win/tty/wintty.c b/win/tty/wintty.c index b1c48645f..27f171001 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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