diff options
| author | rmind <rmind@NetBSD.org> | 2009-10-05 23:33:48 +0000 |
|---|---|---|
| committer | rmind <rmind@NetBSD.org> | 2009-10-05 23:33:48 +0000 |
| commit | 81bc3e51a5d8693d60fdbd1f800dfa02107bc009 (patch) | |
| tree | 2545c09de04664f44a00adbca630edeb22de2025 /lib/libpthread | |
| parent | ecabea58c703236c8a6a4c3ebd0409d60b02a548 (diff) | |
Add check to avoid multiple inclusions and redefinitions.
KNF while here.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread_queue.h | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/libpthread/pthread_queue.h b/lib/libpthread/pthread_queue.h index f1f0c38ed2a..d3f6cf2a0ee 100644 --- a/lib/libpthread/pthread_queue.h +++ b/lib/libpthread/pthread_queue.h @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_queue.h,v 1.4 2008/04/28 20:23:01 martin Exp $ */ +/* $NetBSD: pthread_queue.h,v 1.5 2009/10/05 23:33:48 rmind Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -29,18 +29,20 @@ * POSSIBILITY OF SUCH DAMAGE. */ -/* pthread_queue.h +#ifndef _LIB_PTHREAD_QUEUE_H +#define _LIB_PTHREAD_QUEUE_H + +/* * Definition of a queue interface for the pthread library. * Style modeled on the sys/queue.h macros; implementation taken from * the tail queue, with the added property of static initializability * (and a corresponding extra cost in the _INSERT_TAIL() function. */ - - /* * Queue definitions. */ + #define PTQ_HEAD(name, type) \ struct name { \ struct type *ptqh_first;/* first element */ \ @@ -48,9 +50,8 @@ struct name { \ } #define PTQ_HEAD_INITIALIZER { NULL, NULL } - -#define PTQ_ENTRY(type) \ +#define PTQ_ENTRY(type) \ struct { \ struct type *ptqe_next; /* next element */ \ struct type **ptqe_prev;/* address of previous next element */ \ @@ -65,7 +66,7 @@ struct { \ (head)->ptqh_last = &(head)->ptqh_first; \ } while (/*CONSTCOND*/0) -#define PTQ_INSERT_HEAD(head, elm, field) do { \ +#define PTQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.ptqe_next = (head)->ptqh_first) != NULL) \ (head)->ptqh_first->field.ptqe_prev = \ &(elm)->field.ptqe_next; \ @@ -75,7 +76,7 @@ struct { \ (elm)->field.ptqe_prev = &(head)->ptqh_first; \ } while (/*CONSTCOND*/0) -#define PTQ_INSERT_TAIL(head, elm, field) do { \ +#define PTQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.ptqe_next = NULL; \ if ((head)->ptqh_last == NULL) \ (head)->ptqh_last = &(head)->ptqh_first; \ @@ -84,7 +85,7 @@ struct { \ (head)->ptqh_last = &(elm)->field.ptqe_next; \ } while (/*CONSTCOND*/0) -#define PTQ_INSERT_AFTER(head, listelm, elm, field) do { \ +#define PTQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.ptqe_next = (listelm)->field.ptqe_next) != NULL)\ (elm)->field.ptqe_next->field.ptqe_prev = \ &(elm)->field.ptqe_next; \ @@ -101,7 +102,7 @@ struct { \ (listelm)->field.ptqe_prev = &(elm)->field.ptqe_next; \ } while (/*CONSTCOND*/0) -#define PTQ_REMOVE(head, elm, field) do { \ +#define PTQ_REMOVE(head, elm, field) do { \ if (((elm)->field.ptqe_next) != NULL) \ (elm)->field.ptqe_next->field.ptqe_prev = \ (elm)->field.ptqe_prev; \ @@ -113,21 +114,24 @@ struct { \ /* * Queue access methods. */ -#define PTQ_EMPTY(head) ((head)->ptqh_first == NULL) -#define PTQ_FIRST(head) ((head)->ptqh_first) + +#define PTQ_EMPTY(head) ((head)->ptqh_first == NULL) +#define PTQ_FIRST(head) ((head)->ptqh_first) #define PTQ_NEXT(elm, field) ((elm)->field.ptqe_next) -#define PTQ_LAST(head, headname) \ +#define PTQ_LAST(head, headname) \ (*(((struct headname *)(void *)((head)->ptqh_last))->ptqh_last)) -#define PTQ_PREV(elm, headname, field) \ +#define PTQ_PREV(elm, headname, field) \ (*(((struct headname *)(void *)((elm)->field.ptqe_prev))->ptqh_last)) -#define PTQ_FOREACH(var, head, field) \ +#define PTQ_FOREACH(var, head, field) \ for ((var) = ((head)->ptqh_first); \ (var); \ (var) = ((var)->field.ptqe_next)) -#define PTQ_FOREACH_REVERSE(var, head, headname, field) \ +#define PTQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = (*(((struct headname *)(void *)((head)->ptqh_last))->ptqh_last)); \ (var); \ (var) = (*(((struct headname *)(void *)((var)->field.ptqe_prev))->ptqh_last))) + +#endif /* _LIB_PTHREAD_QUEUE_H */ |
