Module Name:    src
Committed By:   rmind
Date:           Mon Oct  5 23:33:48 UTC 2009

Modified Files:
        src/lib/libpthread: pthread_queue.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libpthread/pthread_queue.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpthread/pthread_queue.h
diff -u src/lib/libpthread/pthread_queue.h:1.4 src/lib/libpthread/pthread_queue.h:1.5
--- src/lib/libpthread/pthread_queue.h:1.4	Mon Apr 28 20:23:01 2008
+++ src/lib/libpthread/pthread_queue.h	Mon Oct  5 23:33:48 2009
@@ -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 */

Reply via email to