svn commit: trunk/uClibc/libpthread/linuxthreads

vapier at uclibc.org vapier at uclibc.org
Thu Sep 8 03:17:07 UTC 2005


Author: vapier
Date: 2005-09-07 20:17:05 -0700 (Wed, 07 Sep 2005)
New Revision: 11384

Log:
import the helper function pthread_for_each_thread from glibc

Modified:
   trunk/uClibc/libpthread/linuxthreads/internals.h
   trunk/uClibc/libpthread/linuxthreads/manager.c


Changeset:
Modified: trunk/uClibc/libpthread/linuxthreads/internals.h
===================================================================
--- trunk/uClibc/libpthread/linuxthreads/internals.h	2005-09-08 03:14:23 UTC (rev 11383)
+++ trunk/uClibc/libpthread/linuxthreads/internals.h	2005-09-08 03:17:05 UTC (rev 11384)
@@ -201,7 +201,7 @@
   pthread_descr req_thread;     /* Thread doing the request */
   enum {                        /* Request kind */
     REQ_CREATE, REQ_FREE, REQ_PROCESS_EXIT, REQ_MAIN_THREAD_EXIT,
-    REQ_POST, REQ_DEBUG, REQ_KICK
+    REQ_POST, REQ_DEBUG, REQ_KICK, REQ_FOR_EACH_THREAD
   } req_kind;
   union {                       /* Arguments for request */
     struct {                    /* For REQ_CREATE: */
@@ -217,6 +217,10 @@
       int code;                 /*   exit status */
     } exit;
     void * post;                /* For REQ_POST: the semaphore */
+    struct {			/* For REQ_FOR_EACH_THREAD: callback */
+      void (*fn)(void *, pthread_descr);
+      void *arg;
+    } for_each;
   } req_args;
 };
 

Modified: trunk/uClibc/libpthread/linuxthreads/manager.c
===================================================================
--- trunk/uClibc/libpthread/linuxthreads/manager.c	2005-09-08 03:14:23 UTC (rev 11383)
+++ trunk/uClibc/libpthread/linuxthreads/manager.c	2005-09-08 03:17:05 UTC (rev 11384)
@@ -107,13 +107,18 @@
 				 int report_events,
 				 td_thr_events_t *event_maskp);
 static void pthread_handle_free(pthread_t th_id);
-static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode);
+static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)
+     __attribute__ ((noreturn));
 static void pthread_reap_children(void);
 static void pthread_kill_all_threads(int sig, int main_thread_also);
+static void pthread_for_each_thread(void *arg,
+    void (*fn)(void *, pthread_descr));
 
 /* The server thread managing requests for thread creation and termination */
 
-int __pthread_manager(void *arg)
+int
+__attribute__ ((noreturn))
+__pthread_manager(void *arg)
 {
   int reqfd = (int) (long int) arg;
 #ifdef USE_SELECT
@@ -248,6 +253,11 @@
 	/* This is just a prod to get the manager to reap some
 	   threads right away, avoiding a potential delay at shutdown. */
 	break;
+      case REQ_FOR_EACH_THREAD:
+	pthread_for_each_thread(request.req_args.for_each.arg,
+	                        request.req_args.for_each.fn);
+	restart(request.req_thread);
+	break;
       }
     }
   }
@@ -839,6 +849,20 @@
   }
 }
 
+static void pthread_for_each_thread(void *arg,
+    void (*fn)(void *, pthread_descr))
+{
+  pthread_descr th;
+
+  for (th = __pthread_main_thread->p_nextlive;
+       th != __pthread_main_thread;
+       th = th->p_nextlive) {
+    fn(arg, th);
+  }
+
+  fn(arg, __pthread_main_thread);
+}
+
 /* Process-wide exit() */
 
 static void pthread_handle_exit(pthread_descr issuing_thread, int exitcode)




More information about the uClibc-cvs mailing list