Merged with HEAD from 8/18 or so. unlabeled-3.24.24
authorcls%seawood.org
Fri, 20 Aug 1999 16:21:35 +0000
branchunlabeled-3.24.24
changeset 770 66373a424c98
parent 572 8805fc0efd8e
push idunknown
push userunknown
push dateunknown
Merged with HEAD from 8/18 or so.
pr/src/linking/prlink.c
--- a/pr/src/linking/prlink.c
+++ b/pr/src/linking/prlink.c
@@ -633,35 +633,16 @@ PR_LoadLibrary(const char *name)
     pr_loadmap = lm;
     }
 #elif defined(XP_MAC) && !GENERATINGCFM
     {
 
     }
 #endif
 
-#ifdef XP_BEOS
-    {
-	image_id h = load_add_on( name );
-
-	if( h == B_ERROR || h <= 0 ) {
-
-	    h = 0;
-	    result = NULL;
-	    PR_DELETE( lm );
-	    lm = NULL;
-	    goto unlock;
-	}
-	lm->name = strdup(name);
-	lm->dlh = (void*)h;
-	lm->next = pr_loadmap;
-	pr_loadmap = lm;
-    }
-#endif
-
 #ifdef XP_UNIX
 #ifdef HAVE_DLL
     {
 #if defined(USE_DLFCN)
     void *h = dlopen(name, _PR_DLOPEN_FLAGS );
 #elif defined(USE_HPSHL)
     shl_t h = shl_load(name, BIND_DEFERRED | DYNAMIC_PATH, 0L);
 #elif defined(USE_MACH_DYLD)
@@ -682,16 +663,46 @@ PR_LoadLibrary(const char *name)
     lm->dlh = h;
     lm->next = pr_loadmap;
     pr_loadmap = lm;
     }
 #endif /* HAVE_DLL */
 #endif /* XP_UNIX */
 
     lm->refCount = 1;
+
+#ifdef XP_BEOS
+    {
+	image_info info;
+	int32 cookie = 0;
+	image_id h = B_ERROR;
+
+	while(get_next_image_info(0, &cookie, &info) == B_OK)
+		if(strcmp(name, info.name + strlen(info.name) - strlen(name)) == 0) {
+			h = info.id;
+			lm->refCount++;	/* it has been already loaded implcitly, so pretend it already had a control structure and ref */
+		}
+
+	if(h == B_ERROR)
+		h = load_add_on( name );
+
+	if( h == B_ERROR || h <= 0 ) {
+	    h = 0;
+	    result = NULL;
+	    PR_DELETE( lm );
+	    lm = NULL;
+	    goto unlock;
+	}
+	lm->name = strdup(name);
+	lm->dlh = (void*)h;
+	lm->next = pr_loadmap;
+	pr_loadmap = lm;
+    }
+#endif
+
     result = lm;    /* success */
     PR_LOG(_pr_linker_lm, PR_LOG_MIN, ("Loaded library %s (load lib)", lm->name));
 
   unlock:
     if (result == NULL) {
         PR_SetError(PR_LOAD_LIBRARY_ERROR, _MD_ERRNO());
         DLLErrorInternal(_MD_ERRNO());  /* sets error text */
     }