about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2014-06-12 14:17:14 -0700
committerRoland McGrath <roland@hack.frob.com>2014-06-12 14:17:14 -0700
commitc5620eb3a354ff1a97522cac39badfdec1aed643 (patch)
treedcca8dd5f54f7aa963fb38b340c00d492fba24a3
parent463dc947b4f9bc4137c9919ee72b896403926474 (diff)
downloadglibc-c5620eb3a354ff1a97522cac39badfdec1aed643.tar.gz
glibc-c5620eb3a354ff1a97522cac39badfdec1aed643.tar.xz
glibc-c5620eb3a354ff1a97522cac39badfdec1aed643.zip
Use list.h in posix-timer code.
-rw-r--r--ChangeLog10
-rw-r--r--sysdeps/pthread/posix-timer.h18
-rw-r--r--sysdeps/pthread/timer_routines.c56
3 files changed, 41 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index cff531567b..02e8da3a60 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2014-06-12  Roland McGrath  <roland@hack.frob.com>
 
+	* sysdeps/pthread/posix-timer.h: Include <list.h>.
+	(struct list_links): Type removed.
+	(struct thread_node, struct timer_node): Replace struct list_links
+	with struct list_head.
+	(list_unlink_ip): Likewise.
+	* sysdeps/pthread/timer_routines.c
+	(timer_free_list, thread_free_list, thread_active_list): Likewise.
+	(list_append, list_insbefore): Likewise.
+	(list_init): Function removed.
+	(thread_init, init_module): Use INIT_LIST_HEAD instead.
 	* sysdeps/nptl/Makefile: Move tst-timer bits to ...
 	* sysdeps/pthread/Makefile: ... here, new file.
 
diff --git a/sysdeps/pthread/posix-timer.h b/sysdeps/pthread/posix-timer.h
index 1076110344..76f538b38c 100644
--- a/sysdeps/pthread/posix-timer.h
+++ b/sysdeps/pthread/posix-timer.h
@@ -19,13 +19,7 @@
 
 #include <limits.h>
 #include <signal.h>
-
-/* Double linked list.  */
-struct list_links
-{
-  struct list_links *next;
-  struct list_links *prev;
-};
+#include <list.h>
 
 
 /* Forward declaration.  */
@@ -35,11 +29,11 @@ struct timer_node;
 /* Definitions for an internal thread of the POSIX timer implementation.  */
 struct thread_node
 {
-  struct list_links links;
+  struct list_head links;
   pthread_attr_t attr;
   pthread_t id;
   unsigned int exists;
-  struct list_links timer_queue;
+  struct list_head timer_queue;
   pthread_cond_t cond;
   struct timer_node *current_timer;
   pthread_t captured;
@@ -50,7 +44,7 @@ struct thread_node
 /* Internal representation of a timer.  */
 struct timer_node
 {
-  struct list_links links;
+  struct list_head links;
   struct sigevent event;
   clockid_t clock;
   struct itimerspec value;
@@ -167,9 +161,9 @@ timespec_sub (struct timespec *diff, const struct timespec *left,
 
 /* We need one of the list functions in the other modules.  */
 static inline void
-list_unlink_ip (struct list_links *list)
+list_unlink_ip (struct list_head *list)
 {
-  struct list_links *lnext = list->next, *lprev = list->prev;
+  struct list_head *lnext = list->next, *lprev = list->prev;
 
   lnext->prev = lprev;
   lprev->next = lnext;
diff --git a/sysdeps/pthread/timer_routines.c b/sysdeps/pthread/timer_routines.c
index ce1aa417cd..3ef7c00b56 100644
--- a/sysdeps/pthread/timer_routines.c
+++ b/sysdeps/pthread/timer_routines.c
@@ -54,9 +54,9 @@ int __timer_init_failed;
 struct thread_node __timer_signal_thread_rclk;
 
 /* Lists to keep free and used timers and threads.  */
-struct list_links timer_free_list;
-struct list_links thread_free_list;
-struct list_links thread_active_list;
+struct list_head timer_free_list;
+struct list_head thread_free_list;
+struct list_head thread_active_list;
 
 
 #ifdef __NR_rt_sigqueueinfo
@@ -66,13 +66,7 @@ extern int __syscall_rt_sigqueueinfo (int, int, siginfo_t *);
 
 /* List handling functions.  */
 static inline void
-list_init (struct list_links *list)
-{
-  list->next = list->prev = list;
-}
-
-static inline void
-list_append (struct list_links *list, struct list_links *newp)
+list_append (struct list_head *list, struct list_head *newp)
 {
   newp->prev = list->prev;
   newp->next = list;
@@ -81,7 +75,7 @@ list_append (struct list_links *list, struct list_links *newp)
 }
 
 static inline void
-list_insbefore (struct list_links *list, struct list_links *newp)
+list_insbefore (struct list_head *list, struct list_head *newp)
 {
   list_append (list, newp);
 }
@@ -92,34 +86,34 @@ list_insbefore (struct list_links *list, struct list_links *newp)
  */
 
 static inline void
-list_unlink (struct list_links *list)
+list_unlink (struct list_head *list)
 {
-  struct list_links *lnext = list->next, *lprev = list->prev;
+  struct list_head *lnext = list->next, *lprev = list->prev;
 
   lnext->prev = lprev;
   lprev->next = lnext;
 }
 
-static inline struct list_links *
-list_first (struct list_links *list)
+static inline struct list_head *
+list_first (struct list_head *list)
 {
   return list->next;
 }
 
-static inline struct list_links *
-list_null (struct list_links *list)
+static inline struct list_head *
+list_null (struct list_head *list)
 {
   return list;
 }
 
-static inline struct list_links *
-list_next (struct list_links *list)
+static inline struct list_head *
+list_next (struct list_head *list)
 {
   return list->next;
 }
 
 static inline int
-list_isempty (struct list_links *list)
+list_isempty (struct list_head *list)
 {
   return list->next == list;
 }
@@ -127,14 +121,14 @@ list_isempty (struct list_links *list)
 
 /* Functions build on top of the list functions.  */
 static inline struct thread_node *
-thread_links2ptr (struct list_links *list)
+thread_links2ptr (struct list_head *list)
 {
   return (struct thread_node *) ((char *) list
 				 - offsetof (struct thread_node, links));
 }
 
 static inline struct timer_node *
-timer_links2ptr (struct list_links *list)
+timer_links2ptr (struct list_head *list)
 {
   return (struct timer_node *) ((char *) list
 				- offsetof (struct timer_node, links));
@@ -154,7 +148,7 @@ thread_init (struct thread_node *thread, const pthread_attr_t *attr, clockid_t c
     }
 
   thread->exists = 0;
-  list_init (&thread->timer_queue);
+  INIT_LIST_HEAD (&thread->timer_queue);
   pthread_cond_init (&thread->cond, 0);
   thread->current_timer = 0;
   thread->captured = pthread_self ();
@@ -170,9 +164,9 @@ init_module (void)
 {
   int i;
 
-  list_init (&timer_free_list);
-  list_init (&thread_free_list);
-  list_init (&thread_active_list);
+  INIT_LIST_HEAD (&timer_free_list);
+  INIT_LIST_HEAD (&thread_free_list);
+  INIT_LIST_HEAD (&thread_active_list);
 
   for (i = 0; i < TIMER_MAX; ++i)
     {
@@ -225,7 +219,7 @@ thread_deinit (struct thread_node *thread)
 struct thread_node *
 __timer_thread_alloc (const pthread_attr_t *desired_attr, clockid_t clock_id)
 {
-  struct list_links *node = list_first (&thread_free_list);
+  struct list_head *node = list_first (&thread_free_list);
 
   if (node != list_null (&thread_free_list))
     {
@@ -366,7 +360,7 @@ thread_func (void *arg)
 
   while (1)
     {
-      struct list_links *first;
+      struct list_head *first;
       struct timer_node *timer = NULL;
 
       /* While the timer queue is not empty, inspect the first node.  */
@@ -441,7 +435,7 @@ int
 __timer_thread_queue_timer (struct thread_node *thread,
 			    struct timer_node *insert)
 {
-  struct list_links *iter;
+  struct list_head *iter;
   int athead = 1;
 
   for (iter = list_first (&thread->timer_queue);
@@ -520,7 +514,7 @@ struct thread_node *
 __timer_thread_find_matching (const pthread_attr_t *desired_attr,
 			      clockid_t desired_clock_id)
 {
-  struct list_links *iter = list_first (&thread_active_list);
+  struct list_head *iter = list_first (&thread_active_list);
 
   while (iter != list_null (&thread_active_list))
     {
@@ -542,7 +536,7 @@ __timer_thread_find_matching (const pthread_attr_t *desired_attr,
 struct timer_node *
 __timer_alloc (void)
 {
-  struct list_links *node = list_first (&timer_free_list);
+  struct list_head *node = list_first (&timer_free_list);
 
   if (node != list_null (&timer_free_list))
     {