Use list.h in posix-timer code.

This commit is contained in:
Roland McGrath 2014-06-12 14:17:14 -07:00
parent 463dc947b4
commit c5620eb3a3
3 changed files with 41 additions and 43 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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))
{