/*
- * Project: libFIRM
- * File name: ir/adt/pdeq.h
- * Purpose: Declarations for pdeq.
- * Author: Christian von Roques
- * Modified by:
- * Created: 1999 by getting from fiasco
- * CVS-ID: $Id$
- * Copyright: (c) 1995, 1996 Christian von Roques
- * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
+ * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
*/
-#ifndef _PDEQ_H_
-#define _PDEQ_H_
/**
- * @file pdeq.h
- *
- * Declarations for double ended queue/list of generic pointers.
+ * @file
+ * @brief double ended queue of generic pointers.
+ * @author Christian von Roques
+ * @version $Id$
*/
+#ifndef FIRM_ADT_PDEQ_H
+#define FIRM_ADT_PDEQ_H
/**
* The type of the pointer compare function.
* Returns non-zero if a double ended pointer list
* contains a pointer x.
*
- * @param dp The list.
+ * @param dq The list.
* @param x The pointer to be searched for.
*/
int pdeq_contains(pdeq *dq, const void *x);
* Convert the double ended pointer list into a linear array beginning from
* left, the first element in the linear array will be the left one.
*
- * @param dq The list.
+ * @param qp The list.
* @param dst A pointer to a pointer array with must be at least
* pdeq_len(dq) * sizeof(void *)
*
* Convert the double ended pointer list into a linear array beginning from
* right, the first element in the linear array will be the right one.
*
- * @param dq The list.
+ * @param qp The list.
* @param dst A pointer to a pointer array with must be at least
* pdeq_len(dq) * sizeof(void *)
*
void **pdeq_copyr(pdeq *qp, const void **dst);
/**
- * Add a pointer to the left site of a double ended pointer list.
+ * Add a pointer to the left side of a double ended pointer list.
*
* @param dq The list to add a pointer to.
* @param x The pointer element to be added
pdeq *pdeq_putl(pdeq *dq, const void *x);
/**
- * Add a pointer to the right site of a double ended pointer list.
+ * Add a pointer to the right side of a double ended pointer list.
*
* @param dq The list to add a pointer to.
* @param x The pointer element to be added
void _pdeq_vrfy(pdeq *dq);
#endif
-#endif /* _PDEQ_H_ */
+/**
+ * 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()
+
+/**
+ * Delete a wait queue (fifo)
+ *
+ * @param wq The wait queue.
+ */
+#define del_waitq(wq) del_pdeq(wq)
+
+/**
+ * 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)
+
+/**
+ * The pdeq can be used as a stack. A helper
+ * type to support this.
+ */
+typedef pdeq stack;
+
+/**
+ * Creates a new pointer stack (lifo).
+ *
+ * @return A new stack.
+ */
+#define new_stack() new_pdeq()
+
+/**
+ * Pop a pointer from the stack (lifo).
+ *
+ * @param st The stack.
+ *
+ * @return The pointer element.
+ *
+ * @remark This function will fail if the stack is empty.
+ */
+#define stack_pop(st) pdeq_getr(st)
+
+/**
+ * Push a pointer to the stack (lifo).
+ *
+ * @param st The stack.
+ * @param x The pointer element to be added
+ *
+ * @return The stack.
+ */
+#define stack_push(st, x) pdeq_putr((st), (x))
+
+/**
+ * Checks if a stack is empty.
+ *
+ * @param st The stack.
+ *
+ * @return non-zero if the stack is empty.
+ */
+#define stack_empty(st) pdeq_empty(wq)
+
+#endif