From: Chris Hanson Date: Tue, 21 Mar 1995 22:13:56 +0000 (+0000) Subject: Changes to get bchscheme running under OS/2. X-Git-Tag: 20090517-FFI~6517 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=e0503750fe3fb2d2bb91e1155e7fc074ece69680;p=mit-scheme.git Changes to get bchscheme running under OS/2. --- diff --git a/v7/src/microcode/bchdmp.c b/v7/src/microcode/bchdmp.c index 8402e0dda..6ce3dfe77 100644 --- a/v7/src/microcode/bchdmp.c +++ b/v7/src/microcode/bchdmp.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchdmp.c,v 9.78 1994/01/30 03:32:11 gjr Exp $ +$Id: bchdmp.c,v 9.79 1995/03/21 22:12:50 cph Exp $ -Copyright (c) 1987-1994 Massachusetts Institute of Technology +Copyright (c) 1987-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -94,6 +94,58 @@ static char FASDUMP_FILENAME[] = "\\tmp\\faXXXXXX"; #endif /* WINNT */ +#ifdef _OS2 +#include "os2.h" + +#ifdef __IBMC__ +#include +#include +#include +#endif + +#ifndef F_OK +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#endif + +char * +DEFUN (mktemp, (fname), unsigned char * fname) +{ + /* This assumes that fname ends in at least 3 Xs. + tmpname seems too random to use. + This, of course, has a window in which another program can + create the file. + */ + + int posn = ((strlen (fname)) - 3); + int counter; + + for (counter = 0; counter < 1000; counter++) + { + sprintf (&fname[posn], "%03d", counter); + if ((access (fname, F_OK)) != 0) + { + int fid = (open (fname, + (O_CREAT | O_EXCL | O_RDWR), + (S_IREAD | S_IWRITE))); + if (fid < 0) + continue; + close (fid); + break; + } + } + if (counter >= 1000) + return ((char *) NULL); + + return ((char *) fname); +} + +#define FASDUMP_FILENAME_DEFINED +static char FASDUMP_FILENAME[] = "\\tmp\\faXXXXXX"; +#endif /* _OS2 */ + #ifndef FASDUMP_FILENAME_DEFINED /* Assume Unix */ diff --git a/v7/src/microcode/bchdrn.h b/v7/src/microcode/bchdrn.h index f79c822dd..5085a9c8f 100644 --- a/v7/src/microcode/bchdrn.h +++ b/v7/src/microcode/bchdrn.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchdrn.h,v 1.6 1993/11/22 00:32:47 gjr Exp $ +$Id: bchdrn.h,v 1.7 1995/03/21 22:12:41 cph Exp $ -Copyright (c) 1991-1993 Massachusetts Institute of Technology +Copyright (c) 1991-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -35,7 +35,6 @@ MIT in each case. */ /* Header file for overlapped I/O in bchscheme. */ #ifndef _BCHDRN_H_INCLUDED - #define _BCHDRN_H_INCLUDED #include "ansidecl.h" @@ -47,10 +46,12 @@ MIT in each case. */ # include #else #ifndef DOS386 +#ifndef _OS2 extern int EXFUN (read, (int, PTR, unsigned int)); extern int EXFUN (write, (int, PTR, unsigned int)); #endif #endif +#endif #if defined(HAVE_POSIX_SIGNALS) && defined(HAVE_BSD_SIGNALS) # define RE_INSTALL_HANDLER(signum,handler) do { } while (0) diff --git a/v7/src/microcode/bchgcc.h b/v7/src/microcode/bchgcc.h index 1f048430b..9c2d0221b 100644 --- a/v7/src/microcode/bchgcc.h +++ b/v7/src/microcode/bchgcc.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchgcc.h,v 9.57 1993/12/07 20:35:51 gjr Exp $ +$Id: bchgcc.h,v 9.58 1995/03/21 22:12:15 cph Exp $ -Copyright (c) 1987-1993 Massachusetts Institute of Technology +Copyright (c) 1987-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -53,6 +53,9 @@ MIT in each case. */ #ifdef WINNT # define IO_PAGE_SIZE 4096 #endif +#ifdef _OS2 +# define IO_PAGE_SIZE 4096 +#endif #ifndef IO_PAGE_SIZE # include #endif diff --git a/v7/src/microcode/bchmmg.c b/v7/src/microcode/bchmmg.c index 2ee646af1..558101b96 100644 --- a/v7/src/microcode/bchmmg.c +++ b/v7/src/microcode/bchmmg.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchmmg.c,v 9.86 1994/01/30 03:31:48 gjr Exp $ +$Id: bchmmg.c,v 9.87 1995/03/21 22:12:32 cph Exp $ -Copyright (c) 1987-1994 Massachusetts Institute of Technology +Copyright (c) 1987-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -49,6 +49,23 @@ MIT in each case. */ #ifdef WINNT # include "nt.h" # define SUB_DIRECTORY_DELIMITER '\\' +# define ASSUME_NORMAL_GC_FILE +#endif + +#ifdef _OS2 +#include "os2.h" +#define SUB_DIRECTORY_DELIMITER '\\' +#define ASSUME_NORMAL_GC_FILE +#ifdef __IBMC__ +#include +#include +#endif +#ifndef F_OK +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 +#endif #endif #ifndef SUB_DIRECTORY_DELIMITER @@ -207,7 +224,64 @@ DEFUN (io_error_always_abort, (operation_name, noise), return (1); } -#ifndef WINNT +#ifdef WINNT +#include + +int +DEFUN (io_error_retry_p, (operation_name, noise), + char * operation_name AND char * noise) +{ + char buf[512]; + extern HANDLE master_tty_window; + + sprintf (&buf[0], + "%s: GC file error (code = %d) when manipulating %s.\n" + "Choose an option (Cancel = Exit Scheme)", + operation_name, (GetLastError ()), noise); + switch (MessageBox (master_tty_window, + &buf[0], + "MIT Scheme garbage-collection problem description", + (MB_ICONSTOP | MB_ABORTRETRYIGNORE | MB_APPLMODAL))) + { + case IDABORT: + return (1); + + case IDRETRY: + return (0); + + case IDIGNORE: + Microcode_Termination (TERM_EXIT); + } +} + +#else /* not WINNT */ +#ifdef _OS2 + +#define INCL_WIN +#include + +int +io_error_retry_p (char * operation_name, char * noise) +{ + char buf [512]; + sprintf ((&buf[0]), + "%s: GC file error (code = %d) when manipulating %s.\n" + "Choose an option (Cancel = Exit Scheme)", + operation_name, errno, noise); + switch (WinMessageBox (HWND_DESKTOP, + NULLHANDLE, + (&buf[0]), + "MIT Scheme garbage-collection problem description", + 0, + (MB_ICONHAND | MB_ABORTRETRYIGNORE | MB_APPLMODAL))) + { + case MBID_ABORT: return (1); + case MBID_RETRY: return (0); + case MBID_IGNORE: Microcode_Termination (TERM_EXIT); + } +} + +#else /* not _OS2 */ extern char EXFUN (userio_choose_option, (CONST char *, CONST char *, CONST char **)); @@ -265,37 +339,9 @@ DEFUN (io_error_retry_p, (operation_name, noise), } } } - -#else /* WINNT */ -#include -int -DEFUN (io_error_retry_p, (operation_name, noise), - char * operation_name AND char * noise) -{ - char buf[512]; - extern HANDLE master_tty_window; - - sprintf (&buf[0], - "%s: GC file error (code = %d) when manipulating %s.\n" - "Choose an option (Cancel = Exit Scheme)", - operation_name, (GetLastError ()), noise); - switch (MessageBox (master_tty_window, - &buf[0], - "MIT Scheme garbage-collection problem description", - (MB_ICONSTOP | MB_ABORTRETRYIGNORE | MB_APPLMODAL))) - { - case IDABORT: - return (1); - - case IDRETRY: - return (0); - - case IDIGNORE: - Microcode_Termination (TERM_EXIT); - } -} -#endif /* WINNT */ +#endif /* not _OS2 */ +#endif /* not WINNT */ static int DEFUN (verify_write, (position, size, success), @@ -1936,9 +1982,8 @@ DEFUN (open_gc_file, (size, unlink_p), } else { -#ifdef WINNT - /* SRA: for NT, for the time being, we just assume that it will be a - normal file */ +#ifdef ASSUME_NORMAL_GC_FILE + /* Assume that it will be a normal file. */ exists_p = true; can_dump_directly_p = true; #else @@ -1968,14 +2013,14 @@ DEFUN (open_gc_file, (size, unlink_p), } else can_dump_directly_p = true; -#endif +#endif /* not ASSUME_NORMAL_GC_FILE */ } gc_file = (open (gc_file_name, flags, GC_FILE_MASK)); if (gc_file == -1) { -#if defined(DOS386) || defined(WINNT) - /* Under DOS and Windows, errno does not give sufficient information. */ +#if defined(DOS386) || defined(WINNT) || defined(_OS2) + /* errno does not give sufficient information except under unix. */ int saved_errno = errno; char @@ -2003,7 +2048,7 @@ DEFUN (open_gc_file, (size, unlink_p), } else errno = saved_errno; -#endif /* defined(DOS386) || defined(WINNT) */ +#endif /* defined(DOS386) || defined(WINNT) || defined(_OS2) */ termination_open_gc_file ("open", ((char *) NULL)); } @@ -2040,8 +2085,8 @@ DEFUN (open_gc_file, (size, unlink_p), gc_file_current_position = -1; /* Unknown position */ +#ifndef ASSUME_NORMAL_GC_FILE /* Determine whether it is a seekable file. */ - if (exists_p && ((file_info.st_mode & S_IFMT) == S_IFCHR)) { #if defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) @@ -2084,6 +2129,7 @@ DEFUN (open_gc_file, (size, unlink_p), (void) (fcntl (gc_file, F_SETFL, (flags | O_NONBLOCK))); #endif } +#endif /* not ASSUME_NORMAL_GC_FILE */ return; } diff --git a/v7/src/microcode/bchutl.c b/v7/src/microcode/bchutl.c index 800b62449..c4949b3e6 100644 --- a/v7/src/microcode/bchutl.c +++ b/v7/src/microcode/bchutl.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: bchutl.c,v 1.4 1993/11/11 20:18:41 cph Exp $ +$Id: bchutl.c,v 1.5 1995/03/21 22:12:45 cph Exp $ -Copyright (c) 1991-1993 Massachusetts Institute of Technology +Copyright (c) 1991-95 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -32,6 +32,9 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ +#include "oscond.h" +#include "ansidecl.h" + #include #ifndef EINTR #define EINTR 1999 @@ -39,13 +42,13 @@ MIT in each case. */ #ifndef DOS386 #ifndef WINNT +#ifndef _OS2 #ifndef _NEXTOS #include #endif #endif #endif - -#include "ansidecl.h" +#endif extern char * EXFUN (error_name, (int)); extern int EXFUN (retrying_file_operation, @@ -67,6 +70,21 @@ DEFUN (error_name, (code), int code) } #else /* not WINNT */ +#ifdef _OS2 + +#ifdef __IBMC__ +#include +#endif + +char * +DEFUN (error_name, (code), int code) +{ + static char buf [512]; + sprintf ((&buf[0]), "%d, unknown error", code); + return (&buf[0]); +} + +#else /* not _OS2 */ char * DEFUN (error_name, (code), int code) @@ -82,7 +100,8 @@ DEFUN (error_name, (code), int code) return (&buf[0]); } -#endif /* WINNT */ +#endif /* not _OS2 */ +#endif /* not WINNT */ #ifndef SEEK_SET #define SEEK_SET 0 diff --git a/v7/src/microcode/os2utl/makefile b/v7/src/microcode/os2utl/makefile index 9e0f6341c..1af4664da 100644 --- a/v7/src/microcode/os2utl/makefile +++ b/v7/src/microcode/os2utl/makefile @@ -1,6 +1,6 @@ ### -*- Fundamental -*- ### -### $Id: makefile,v 1.7 1995/03/13 23:20:46 cph Exp $ +### $Id: makefile,v 1.8 1995/03/21 22:13:56 cph Exp $ ### ### Copyright (c) 1994-95 Massachusetts Institute of Technology ### @@ -56,7 +56,7 @@ # assembly language, or even a simple interface library precompiled # with icc. -all: scheme.exe +all: scheme.exe bchschem.exe OBJ = obj # obj for IBM C and GCC/2 @@ -339,8 +339,8 @@ usrdef.c : $(SCHEME_SOURCES) $(SOURCES) $(OS_PRIM_SOURCES) usrdef.tch \ .\findprim $(SCHEME_SOURCES) $(SOURCES) $(OS_PRIM_SOURCES) > usrdef.c bchdef.c : $(SCHEME_SOURCES) $(BCHSOURCES) $(OS_PRIM_SOURCES) usrdef.tch \ - findprim xmkfile - .\findprim $(SCHEME_SOURCES) $(BCHSOURCES) $(OS_PRIM_SOURCES) \ + findprim.exe + .\findprim.exe $(SCHEME_SOURCES) $(BCHSOURCES) $(OS_PRIM_SOURCES) \ > bchdef.c COMMON_OBJECTS = $(CORE_OBJECTS) $(STD_GC_OBJECTS) $(OS2_OBJECTS) \