Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Add check to avoid multiple inclusions and re...



details:   https://anonhg.NetBSD.org/src/rev/ffc56169c75d
branches:  trunk
changeset: 747922:ffc56169c75d
user:      rmind <rmind%NetBSD.org@localhost>
date:      Mon Oct 05 23:33:48 2009 +0000

description:
Add check to avoid multiple inclusions and redefinitions.
KNF while here.

diffstat:

 lib/libpthread/pthread_queue.h |  36 ++++++++++++++++++++----------------
 1 files changed, 20 insertions(+), 16 deletions(-)

diffs (111 lines):

diff -r 6fd84a2ed82a -r ffc56169c75d lib/libpthread/pthread_queue.h
--- a/lib/libpthread/pthread_queue.h    Mon Oct 05 23:31:16 2009 +0000
+++ b/lib/libpthread/pthread_queue.h    Mon Oct 05 23:33:48 2009 +0000
@@ -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 @@
 }
 
 #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 @@
        (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 @@
        (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 @@
        (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 @@
        (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 @@
 /*
  * 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 */



Home | Main Index | Thread Index | Old Index