[haiku-commits] r34338 - haiku/trunk/src/system/runtime_loader

  • From: ingo_weinhold@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sun, 29 Nov 2009 10:57:27 +0100 (CET)

Author: bonefish
Date: 2009-11-29 10:57:26 +0100 (Sun, 29 Nov 2009)
New Revision: 34338
Changeset: http://dev.haiku-os.org/changeset/34338/haiku

Modified:
   haiku/trunk/src/system/runtime_loader/Jamfile
   haiku/trunk/src/system/runtime_loader/elf.cpp
Log:
Use the shared recursive lock implementation instead of the home-grown stuff.
The shared implementation is benaphore style, saving unnecessary syscalls.


Modified: haiku/trunk/src/system/runtime_loader/Jamfile
===================================================================
--- haiku/trunk/src/system/runtime_loader/Jamfile       2009-11-29 09:54:58 UTC 
(rev 34337)
+++ haiku/trunk/src/system/runtime_loader/Jamfile       2009-11-29 09:57:26 UTC 
(rev 34338)
@@ -1,6 +1,6 @@
 SubDir HAIKU_TOP src system runtime_loader ;
 
-UsePrivateHeaders runtime_loader ;
+UsePrivateHeaders runtime_loader shared ;
 UsePrivateHeaders kernel ;
        # for <util/KMessage.h>
 UsePrivateSystemHeaders ;
@@ -24,6 +24,7 @@
        kernel_cpp.cpp
        KMessage.cpp
        :
+       <src!system!libroot!os>locks.o
        <src!system!libroot!os>syscalls.o
        <src!system!libroot!os>sem.o
 
@@ -90,6 +91,7 @@
        $(TARGET_STATIC_LIBSUPC++)
        $(TARGET_GCC_LIBGCC)
        : $(HAIKU_TOP)/src/system/ldscripts/$(TARGET_ARCH)/runtime_loader.ld
+       : --no-undefined
 ;
 
 HaikuSubInclude arch $(TARGET_ARCH) ;

Modified: haiku/trunk/src/system/runtime_loader/elf.cpp
===================================================================
--- haiku/trunk/src/system/runtime_loader/elf.cpp       2009-11-29 09:54:58 UTC 
(rev 34337)
+++ haiku/trunk/src/system/runtime_loader/elf.cpp       2009-11-29 09:57:26 UTC 
(rev 34338)
@@ -22,6 +22,8 @@
 #include <syscalls.h>
 #include <util/kernel_cpp.h>
 
+#include <locks.h>
+
 #include "add_ons.h"
 #include "elf_load_image.h"
 #include "elf_symbol_lookup.h"
@@ -45,31 +47,20 @@
 static image_t** sPreloadedImages = NULL;
 static uint32 sPreloadedImageCount = 0;
 
-// a recursive lock
-static sem_id sSem;
-static thread_id sSemOwner;
-static int32 sSemCount;
+static recursive_lock sLock;
 
 
-static void
-rld_unlock()
+static inline void
+rld_lock()
 {
-       if (sSemCount-- == 1) {
-               sSemOwner = -1;
-               release_sem(sSem);
-       }
+       recursive_lock_lock(&sLock);
 }
 
 
-static void
-rld_lock()
+static inline void
+rld_unlock()
 {
-       thread_id self = find_thread(NULL);
-       if (self != sSemOwner) {
-               acquire_sem(sSem);
-               sSemOwner = self;
-       }
-       sSemCount++;
+       recursive_lock_unlock(&sLock);
 }
 
 
@@ -938,9 +929,7 @@
 void
 rldelf_init(void)
 {
-       sSem = create_sem(1, "runtime loader");
-       sSemOwner = -1;
-       sSemCount = 0;
+       recursive_lock_init(&sLock, "runtime loader");
 
        init_add_ons();
 
@@ -974,9 +963,9 @@
 status_t
 elf_reinit_after_fork(void)
 {
-       sSem = create_sem(1, "runtime loader");
-       if (sSem < 0)
-               return sSem;
+       status_t error = recursive_lock_init(&sLock, "runtime loader");
+       if (error != B_OK)
+               return error;
 
        // We also need to update the IDs of our images. We are the child and
        // and have cloned images with different IDs. Since in most cases 
(fork()


Other related posts:

  • » [haiku-commits] r34338 - haiku/trunk/src/system/runtime_loader - ingo_weinhold