Changes to get bchscheme running under OS/2.
authorChris Hanson <org/chris-hanson/cph>
Tue, 21 Mar 1995 22:13:56 +0000 (22:13 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 21 Mar 1995 22:13:56 +0000 (22:13 +0000)
v7/src/microcode/bchdmp.c
v7/src/microcode/bchdrn.h
v7/src/microcode/bchgcc.h
v7/src/microcode/bchmmg.c
v7/src/microcode/bchutl.c
v7/src/microcode/os2utl/makefile

index 8402e0dda2067ed8f14dfedc420d4f6209e62289..6ce3dfe77404f493e12e77c8272100b758115938 100644 (file)
@@ -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 <io.h>
+#include <sys\stat.h>
+#include <fcntl.h>
+#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 */
index f79c822dde91ec41588f231f22ab7e8a16663ad1..5085a9c8faba7867cffc4d2c679fe6c39f17177e 100644 (file)
@@ -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 <unistd.h>
 #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)
index 1f048430b2369bed50b05a6a1ceb1e9a6e3a3df7..9c2d0221bd9934e25a9d8fd89263679d2faecb9b 100644 (file)
@@ -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 <sys/param.h>
 #endif
index 2ee646af1e3047a97d47686b6b572fbc9f3b3e40..558101b96f8b1e06fbcc461a537737b5add61690 100644 (file)
@@ -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 <io.h>
+#include <sys\stat.h>
+#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 <windows.h>
+
+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 <os2.h>
+
+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),
     }
   }
 }
-\f
-#else /* WINNT */
-#include <windows.h>
 
-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 */
 \f
 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 */
   }
 \f
   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;
 }
 \f
index 800b62449d3841a4acd7e3a4bba151aef73378bc..c4949b3e63a769e5ab2797d07e89ab38b30c0ad8 100644 (file)
@@ -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 <errno.h>
 #ifndef EINTR
 #define EINTR 1999
@@ -39,13 +42,13 @@ MIT in each case. */
 
 #ifndef DOS386
 #ifndef WINNT
+#ifndef _OS2
 #ifndef _NEXTOS
 #include <unistd.h>
 #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 <io.h>
+#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
index 9e0f6341cef0d841e5777440d0b3d1d2d27c6827..1af4664da0672b9338c1b0dbca4ae5f5464a3dc4 100644 (file)
@@ -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) \