From: Chris Hanson Date: Tue, 24 Oct 1995 05:11:33 +0000 (+0000) Subject: Changes to allow Win32 microcode to be compiled by the Watcom C X-Git-Tag: 20090517-FFI~5876 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=77b8e3c4d67d28e09d06bcd6e8a2f2a1765556f1;p=mit-scheme.git Changes to allow Win32 microcode to be compiled by the Watcom C compiler. --- diff --git a/v7/src/microcode/ntgui.c b/v7/src/microcode/ntgui.c index a87c61f15..da0f163f9 100644 --- a/v7/src/microcode/ntgui.c +++ b/v7/src/microcode/ntgui.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ntgui.c,v 1.14 1994/11/02 20:35:27 adams Exp $ +$Id: ntgui.c,v 1.15 1995/10/24 05:04:18 cph Exp $ -Copyright (c) 1993-1994 Massachusetts Institute of Technology +Copyright (c) 1993-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -97,7 +97,7 @@ WinMain (HANDLE hInst, HANDLE hPrevInst, LPSTR lpCmdLine, int nCmdShow) if (!InitInstance(ghInstance, nCmdShow)) return FALSE; - return (main (argc, argv)); + return (scheme_main (argc, argv)); } #endif @@ -708,7 +708,8 @@ DEFINE_PRIMITIVE ("NT:SEND-MESSAGE", Prim_send_message, 4, 4, // PRIMITIVE_RETURN (long_to_integer (result)); //} -static SCHEME_OBJECT call_ff_really() +static SCHEME_OBJECT +call_ff_really (void) { { @@ -754,6 +755,7 @@ static SCHEME_OBJECT call_ff_really() arg_sp = &local.c_args[10]; local.old_esp = saved_esp; +#ifdef CL386 __asm { // Important: The order of these instructions guards against @@ -765,6 +767,22 @@ static SCHEME_OBJECT call_ff_really() mov esp, dword ptr [saved_esp] mov dword ptr [result], eax } +#else /* not CL386 */ +#ifdef __WATCOMC__ + { + extern void call_ff_really_1 (void); +#pragma aux call_ff_really_1 = \ + "mov eax,function_address" \ + "mov saved_esp,esp" \ + "mov esp,arg_sp" \ + "call eax" \ + "mov esp,saved_esp" \ + "mov result,eax" \ + modify [eax edx ecx]; + call_ff_really_1 (); + } +#endif /* __WATCOMC__ */ +#endif /* not CL386 */ saved_esp = local.old_esp; return long_to_integer (result); } diff --git a/v7/src/microcode/ntio.c b/v7/src/microcode/ntio.c index b6d4ce34f..383b8279a 100644 --- a/v7/src/microcode/ntio.c +++ b/v7/src/microcode/ntio.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ntio.c,v 1.10 1994/11/14 00:53:40 cph Exp $ +$Id: ntio.c,v 1.11 1995/10/24 05:05:08 cph Exp $ -Copyright (c) 1992-94 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -516,7 +516,7 @@ DEFUN_VOID (OS_have_ptys_p) int OS_have_select_p = 0; extern HANDLE master_tty_window; -extern BOOL win32_under_win32s_p (void); +extern BOOL __cdecl win32_under_win32s_p (void); extern void EXFUN (NT_initialize_channels, (void)); extern void EXFUN (NT_reset_channels, (void)); extern void EXFUN (NT_restore_channels, (void)); diff --git a/v7/src/microcode/ntscreen.h b/v7/src/microcode/ntscreen.h index 648d89a01..ca56862d9 100644 --- a/v7/src/microcode/ntscreen.h +++ b/v7/src/microcode/ntscreen.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ntscreen.h,v 1.10 1994/11/02 20:27:05 adams Exp $ +$Id: ntscreen.h,v 1.11 1995/10/24 05:05:32 cph Exp $ -Copyright (c) 1993-1994 Massachusetts Institute of Technology +Copyright (c) 1993-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -154,6 +154,10 @@ extern HWND ScreenCurrentFocus(); extern BOOL Screen_SetPosition (SCREEN, int, int); +#ifdef __WATCOMC__ +#define _fastcall +#endif + extern VOID _fastcall clear_screen_rectangle (SCREEN, int, int, int, int); extern VOID Screen_CR_to_RECT (RECT *, SCREEN, int, int, int, int); extern VOID _fastcall scroll_screen_vertically (SCREEN, int, int, int, int, int); diff --git a/v7/src/microcode/nttrap.c b/v7/src/microcode/nttrap.c index 91f495670..b635bb3e3 100644 --- a/v7/src/microcode/nttrap.c +++ b/v7/src/microcode/nttrap.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: nttrap.c,v 1.10 1993/12/07 20:36:02 gjr Exp $ +$Id: nttrap.c,v 1.11 1995/10/24 05:07:05 cph Exp $ -Copyright (c) 1992-1993 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -489,9 +489,8 @@ DEFUN_VOID (WinntExceptionTransferHook) return (PRIM_APPLY); } -extern unsigned short EXFUN (getCS, (void)); -extern unsigned short EXFUN (getDS, (void)); -extern unsigned short EXFUN (getSS, (void)); +extern unsigned short __cdecl EXFUN (getCS, (void)); +extern unsigned short __cdecl EXFUN (getDS, (void)); /* Needed because Stack_Check checks for <= instead of < when pushing */ @@ -1330,15 +1329,19 @@ DEFUN (WinntEnterHook, (enter_interpreter), { do { +#ifdef CL386 try +#endif { (* enter_interpreter) (); } +#ifdef CL386 except (WinntException ((GetExceptionCode ()), (GetExceptionInformation ()))) { outf_fatal ("Exception!\n"); termination_trap (); } +#endif } while (1); } diff --git a/v7/src/microcode/nttty.c b/v7/src/microcode/nttty.c index b93b745bf..a86b60687 100644 --- a/v7/src/microcode/nttty.c +++ b/v7/src/microcode/nttty.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: nttty.c,v 1.4 1993/08/21 03:51:19 gjr Exp $ +$Id: nttty.c,v 1.5 1995/10/24 05:07:31 cph Exp $ -Copyright (c) 1992-1993 Massachusetts Institute of Technology +Copyright (c) 1992-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -131,7 +131,7 @@ tputs (string, nlines, outfun) register int padcount = 0; if (string == (char *) 0) - return; + return (0); while (*string >= '0' && *string <= '9') { padcount += *string++ - '0'; diff --git a/v7/src/microcode/oscond.h b/v7/src/microcode/oscond.h index b18011a09..1b450f6ce 100644 --- a/v7/src/microcode/oscond.h +++ b/v7/src/microcode/oscond.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: oscond.h,v 1.20 1995/10/15 00:39:20 cph Exp $ +$Id: oscond.h,v 1.21 1995/10/24 05:08:19 cph Exp $ Copyright (c) 1990-95 Massachusetts Institute of Technology @@ -160,6 +160,10 @@ MIT in each case. */ #include "error: can't define both _BSD and _SYSV" #endif +#if (defined(_M_I386) || defined(M_I386)) && !defined(i386) +#define i386 +#endif + #if defined(DOS386) # define _DOS386 # define _DOS386_VERSION 50 @@ -169,13 +173,14 @@ MIT in each case. */ #define _OS2 /* Don't really know the version but this is correct for my machine. */ #define _OS2_VERSION 211 -#if defined(_M_I386) || defined(M_I386) +#ifdef i386 #define _OS2386 -#ifndef i386 -#define i386 -#endif /* i386 */ -#endif /* _M_I386 or M_I386 */ -#endif /* __OS2__ */ +#endif +#endif + +#if defined(__NT__) && !defined(WINNT) +#define WINNT +#endif #if defined(_BSD) || defined(_SYSV) || defined(_PIXEL) # define _UNIX diff --git a/v7/src/microcode/osio.h b/v7/src/microcode/osio.h index aef510429..822e049de 100644 --- a/v7/src/microcode/osio.h +++ b/v7/src/microcode/osio.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: osio.h,v 1.10 1994/11/14 00:53:17 cph Exp $ +$Id: osio.h,v 1.11 1995/10/24 05:08:52 cph Exp $ -Copyright (c) 1990-94 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -88,6 +88,10 @@ extern int EXFUN (OS_channel_nonblocking_p, (Tchannel channel)); extern void EXFUN (OS_channel_nonblocking, (Tchannel channel)); extern void EXFUN (OS_channel_blocking, (Tchannel channel)); +#ifdef WINNT +extern int OS_have_select_p; +#else extern CONST int OS_have_select_p; +#endif #endif /* SCM_OSIO_H */ diff --git a/v7/src/microcode/outf.c b/v7/src/microcode/outf.c index cf03dcdd7..bdb0d025a 100644 --- a/v7/src/microcode/outf.c +++ b/v7/src/microcode/outf.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: outf.c,v 1.8 1995/10/08 15:30:29 cph Exp $ +$Id: outf.c,v 1.9 1995/10/24 05:09:21 cph Exp $ Copyright (c) 1993-95 Massachusetts Institute of Technology @@ -121,11 +121,21 @@ DEFUN (outf_channel_to_FILE, (chan), outf_channel chan) static int max_fatal_buf = 1000; static char fatal_buf[1000+1] = {0}; +#ifdef CL386 +#define VSNPRINTF(buffer,length,format,args) \ + _vsnprintf ((buffer), (length), (format), (args)) +#else +#ifdef __WATCOMC__ +#define VSNPRINTF(buffer,length,format,args) \ + vsprintf ((buffer), (format), (args)) +#endif +#endif + void DEFUN (voutf_fatal, (format, args), CONST char *format AND va_list args) { int end = strlen(fatal_buf); - _vsnprintf (&fatal_buf[end], max_fatal_buf - end, format, args); + VSNPRINTF (&fatal_buf[end], max_fatal_buf - end, format, args); } void @@ -144,7 +154,7 @@ DEFUN (voutf_master_tty, (chan, format, args), char buf[1000]; if (master_tty_window) { - _vsnprintf (buf, 1000, format, args); + VSNPRINTF (buf, 1000, format, args); Screen_WriteText (master_tty_window, buf); } else { vfprintf (outf_channel_to_FILE(chan), format, args); diff --git a/v7/src/microcode/posixtyp.h b/v7/src/microcode/posixtyp.h index c74d9b880..ceb5d690c 100644 --- a/v7/src/microcode/posixtyp.h +++ b/v7/src/microcode/posixtyp.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: posixtyp.h,v 1.12 1995/10/15 00:39:32 cph Exp $ +$Id: posixtyp.h,v 1.13 1995/10/24 05:10:00 cph Exp $ -Copyright (c) 1990-1994 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -90,8 +90,11 @@ MIT in each case. */ #endif #ifdef WINNT + #include #include + +#ifdef CL386 /*#define _MODE_T*/ #define _NLINK_T #define _PID_T @@ -103,6 +106,15 @@ MIT in each case. */ /*#define _CC_T*/ #endif +#ifdef __WATCOMC__ +#define _TIME_T +#define _OFF_T +#define _SIZE_T +#define _CLOCK_T +#endif + +#endif + #ifdef _OS2 #if defined(__IBMC__) || defined(__WATCOMC__) diff --git a/v7/src/microcode/prntfs.c b/v7/src/microcode/prntfs.c index de00d9cf5..9fba863f5 100644 --- a/v7/src/microcode/prntfs.c +++ b/v7/src/microcode/prntfs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: prntfs.c,v 1.2 1993/08/21 04:00:47 gjr Exp $ +$Id: prntfs.c,v 1.3 1995/10/24 05:10:35 cph Exp $ -Copyright (c) 1993 Massachusetts Institute of Technology +Copyright (c) 1993-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -219,8 +219,7 @@ DEFUN (file_type_letter, (s), struct stat * s) return ('d'); case S_IFCHR: return ('c'); -#ifndef NT386CL -/* S_IFBLK seems not to exist*/ +#ifdef S_IFBLK case S_IFBLK: return ('b'); #endif diff --git a/v7/src/microcode/term.c b/v7/src/microcode/term.c index 23e37176d..67e594034 100644 --- a/v7/src/microcode/term.c +++ b/v7/src/microcode/term.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: term.c,v 1.11 1994/12/19 22:29:05 cph Exp $ +$Id: term.c,v 1.12 1995/10/24 05:11:10 cph Exp $ -Copyright (c) 1990-94 Massachusetts Institute of Technology +Copyright (c) 1990-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -41,7 +41,7 @@ extern char * Term_Messages []; extern void EXFUN (get_band_parameters, (long * heap_size, long * const_size)); extern void EXFUN (Reset_Memory, (void)); -#if WINNT || defined(_OS2) +#if defined(WINNT) || defined(_OS2) #define USING_MESSAGE_BOX_FOR_FATAL_OUTPUT #endif @@ -150,7 +150,7 @@ DEFUN (termination_suffix, (code, value, abnormal_p), if (code != TERM_HALT) #endif outf_flush_fatal(); -#if WINNT +#ifdef WINNT winnt_deallocate_registers(); #endif Reset_Memory (); diff --git a/v7/src/microcode/utils.c b/v7/src/microcode/utils.c index 3bb86b62b..5192b3c06 100644 --- a/v7/src/microcode/utils.c +++ b/v7/src/microcode/utils.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: utils.c,v 9.68 1995/09/18 22:33:04 cph Exp $ +$Id: utils.c,v 9.69 1995/10/24 05:11:33 cph Exp $ Copyright (c) 1987-95 Massachusetts Institute of Technology @@ -1119,9 +1119,9 @@ DEFUN (C_call_scheme, (proc, nargs, argvec), cfp = C_Frame_Pointer; csp = C_Stack_Pointer; -#ifdef WINNT +#ifdef NT386CL try -#endif /* WINNT */ +#endif /* NT386CL */ #endif /* i386 */ { primitive = (Regs [REGBLOCK_PRIMITIVE]); @@ -1162,9 +1162,9 @@ DEFUN (C_call_scheme, (proc, nargs, argvec), Regs [REGBLOCK_PRIMITIVE] = primitive; } #ifdef i386 -#ifdef WINNT +#ifdef NT386CL finally -#endif /* WINNT */ +#endif /* NT386CL */ { C_Frame_Pointer = cfp; C_Stack_Pointer = csp;