From b719ba15ad4119f474743595aaa7e22723b06911 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Thu, 18 May 2006 11:47:43 +0000 Subject: [PATCH] Added macros to use a pdeq as a wait queue typos fixed [r7749] --- ir/adt/pdeq.c | 2 +- ir/adt/pdeq.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/ir/adt/pdeq.c b/ir/adt/pdeq.c index 8f679e040..ed3194adb 100644 --- a/ir/adt/pdeq.c +++ b/ir/adt/pdeq.c @@ -186,7 +186,7 @@ int pdeq_empty(pdeq *dq) return dq->l_end->n == 0; } -/* Returns the lenght of a double ended pointer list. */ +/* Returns the length of a double ended pointer list. */ int pdeq_len(pdeq *dq) { int n; diff --git a/ir/adt/pdeq.h b/ir/adt/pdeq.h index e0ff6366d..e2107bc1c 100644 --- a/ir/adt/pdeq.h +++ b/ir/adt/pdeq.h @@ -3,7 +3,7 @@ * File name: ir/adt/pdeq.h * Purpose: Declarations for pdeq. * Author: Christian von Roques - * Modified by: + * Modified by: Michael Beck * Created: 1999 by getting from fiasco * CVS-ID: $Id$ * Copyright: (c) 1995, 1996 Christian von Roques @@ -169,4 +169,47 @@ void *pdeq_getr(pdeq *dq); void _pdeq_vrfy(pdeq *dq); #endif +/** + * The pdeq is often used as a wait queue. A helper + * type to support this. + */ +typedef pdeq waitq; + +/** + * Creates a new pointer wait queue (fifo). + * + * @return A new queue. + */ +#define new_waitq() new_pdeq() + +/** + * Retrieve a pointer from the wait queue (fifo). + * + * @param wq The wait queue. + * + * @return The pointer element. + * + * @remark This function will fail if the queue is empty. + */ +#define waitq_get(wq) pdeq_getl(wq) + +/** + * Add a pointer to the wait queue (fifo). + * + * @param wq The wait queue + * @param x The pointer element to be added + * + * @return The wait queue. + */ +#define waitq_put(wq, x) pdeq_putr((wq), (x)) + +/** + * Checks if a wait queue is empty. + * + * @param wq The wait queue. + * + * @return non-zero if the queue is empty. + */ +#define waitq_empty(wq) pdeq_empty(wq) + #endif /* _PDEQ_H_ */ -- 2.20.1