[project @ 2000-02-01 14:02:02 by sewardj]
[ghc-hetmet.git] / ghc / interpreter / machdep.c
index ace1420..f8536ca 100644 (file)
@@ -13,8 +13,8 @@
  * included in the distribution.
  *
  * $RCSfile: machdep.c,v $
- * $Revision: 1.15 $
- * $Date: 1999/12/03 12:39:42 $
+ * $Revision: 1.18 $
+ * $Date: 1999/12/20 16:55:27 $
  * ------------------------------------------------------------------------*/
 
 #ifdef HAVE_SIGNAL_H
@@ -681,9 +681,11 @@ Bool findFilesForModule (
    strcat(augdPath, hugsPath);
    strcat(augdPath, PATHSEP_STR);
 
-   strcat(augdPath, installDir);
-   strcat(augdPath, "GhcPrel");
-   strcat(augdPath, PATHSEP_STR);
+   if (combined) {
+      strcat(augdPath, installDir);
+      strcat(augdPath, "GhcPrel");
+      strcat(augdPath, PATHSEP_STR);
+   }
 
    strcat(augdPath, installDir);
    strcat(augdPath, "lib");
@@ -769,6 +771,43 @@ Bool findFilesForModule (
 }
 
 
+/* If the primaryObjectName for is (eg)
+     /foo/bar/PrelSwamp.o
+   and the extraFileName is (eg)
+     swampy_cbits
+   and DLL_ENDING is set to .o
+   return
+     /foo/bar/swampy_cbits.o
+     and set *extraFileSize to its size, or -1 if not avail
+*/
+String getExtraObjectInfo ( String primaryObjectName,
+                            String extraFileName,
+                            Int*   extraFileSize )
+{
+   Time   xTime;
+   Long   xSize;
+   String xtra;
+
+   Int i = strlen(primaryObjectName)-1;
+   while (i >= 0 && primaryObjectName[i] != SLASH) i--;
+   if (i == -1) return extraFileName;
+   i++;
+   xtra = malloc ( i+3+strlen(extraFileName)+strlen(DLL_ENDING) );
+   if (!xtra) internal("deriveExtraObjectName: malloc failed");
+   strncpy ( xtra, primaryObjectName, i );
+   xtra[i] = 0;
+   strcat ( xtra, extraFileName );
+   strcat ( xtra, DLL_ENDING );
+
+   *extraFileSize = -1;
+   if (readable(xtra)) {
+      getFileInfo ( xtra, &xTime, &xSize );
+      *extraFileSize = xSize;
+   }
+   return xtra;
+}
+
+
 /* --------------------------------------------------------------------------
  * Substitute old value of path into empty entries in new path
  * eg substPath("a:b:c::d:e","x:y:z") = "a:b:c:x:y:z:d:e"
@@ -1541,7 +1580,8 @@ Void machdep(what)                      /* Handle machine specific         */
 Int what; {                             /* initialisation etc..            */
     switch (what) {
         case MARK    : break;
-        case INSTALL : installHandlers();
+        case POSTPREL: break;
+        case PREPREL : installHandlers();
                        break;
         case RESET   :
         case BREAK   :