]> sourceware.org Git - glibc.git/commitdiff
sem_close: Use __twalk_r
authorFlorian Weimer <fweimer@redhat.com>
Fri, 10 May 2019 12:17:26 +0000 (14:17 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 10 May 2019 12:52:44 +0000 (14:52 +0200)
ChangeLog
nptl/sem_close.c

index 8f6b8c82a65c68acef5507df689ecdf602317919..185730361d79e2c0c0cc5169d4d33eff2260d827 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2019-05-10  Florian Weimer  <fweimer@redhat.com>
+
+       * nptl/sem_close.c (struct walk_closure): Define.
+       (walker): Adjust for __twalk_r.
+       (sem_close): Call __twalk_r.
+
 2019-05-09  Adhemerval Zanella  <adhemerval.zanella@linaro.org>
 
        * support/timespec.c (test_timespec_before_impl,
index b8828cba060436055e6aafc5c1dc109cf9227a2f..8941f111f926b0c15a2f0c2ad9b9f5f087138fa3 100644 (file)
 #include <sys/mman.h>
 #include "semaphoreP.h"
 
-
-/* Global variables to parametrize the walk function.  This works
-   since we always have to use locks.  And we have to use the twalk
-   function since the entries are not sorted wrt the mapping
-   address.  */
-static sem_t *the_sem;
-static struct inuse_sem *rec;
+struct walk_closure
+{
+  sem_t *the_sem;
+  struct inuse_sem *rec;
+};
 
 static void
-walker (const void *inodep, const VISIT which, const int depth)
+walker (const void *inodep, VISIT which, void *closure0)
 {
+  struct walk_closure *closure = closure0;
   struct inuse_sem *nodep = *(struct inuse_sem **) inodep;
 
-  if (nodep->sem == the_sem)
-    rec = nodep;
+  if (nodep->sem == closure->the_sem)
+    closure->rec = nodep;
 }
 
 
@@ -48,9 +47,12 @@ sem_close (sem_t *sem)
   lll_lock (__sem_mappings_lock, LLL_PRIVATE);
 
   /* Locate the entry for the mapping the caller provided.  */
-  rec = NULL;
-  the_sem = sem;
-  __twalk (__sem_mappings, walker);
+  struct inuse_sem *rec;
+  {
+    struct walk_closure closure = { .the_sem = sem, .rec = NULL };
+    __twalk_r (__sem_mappings, walker, &closure);
+    rec = closure.rec;
+  }
   if  (rec != NULL)
     {
       /* Check the reference counter.  If it is going to be zero, free
This page took 0.060201 seconds and 5 git commands to generate.