aboutsummaryrefslogtreecommitdiff
path: root/support/tools/Burg/queue.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-09-17 23:03:30 +0000
committerChris Lattner <sabre@nondot.org>2002-09-17 23:03:30 +0000
commit633a5b1aacb135957b20e5f11e779ea23ccb9619 (patch)
tree3ddd35119d12cadf13e31f3cae9f67b057332440 /support/tools/Burg/queue.c
parent24b70926d5750dacadc3252f8fbcc964b369e2af (diff)
Initial checkin of burg files
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3785 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'support/tools/Burg/queue.c')
-rw-r--r--support/tools/Burg/queue.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/support/tools/Burg/queue.c b/support/tools/Burg/queue.c
new file mode 100644
index 0000000000..76e5ea9b57
--- /dev/null
+++ b/support/tools/Burg/queue.c
@@ -0,0 +1,64 @@
+char rcsid_queue[] = "$Id$";
+
+#include "b.h"
+#include <stdio.h>
+
+Queue globalQ;
+
+Queue
+newQ()
+{
+ Queue q;
+
+ q = (Queue) zalloc(sizeof(struct queue));
+ assert(q);
+ q->head = 0;
+ q->tail = 0;
+
+ return q;
+}
+
+void
+addQ(q, ts) Queue q; Item_Set ts;
+{
+ List qe;
+
+ assert(q);
+ assert(ts);
+
+ qe = newList(ts, 0);
+ if (q->head) {
+ assert(q->tail);
+ q->tail->next = qe;
+ q->tail = qe;
+ } else {
+ q->head = q->tail = qe;
+ }
+}
+
+Item_Set
+popQ(q) Queue q;
+{
+ List qe;
+ Item_Set ts;
+
+ assert(q);
+
+ if (q->head) {
+ qe = q->head;
+ q->head = q->head->next;
+ ts = (Item_Set) qe->x;
+ zfree(qe);
+ return ts;
+ } else {
+ return 0;
+ }
+}
+
+void
+dumpQ(q) Queue q;
+{
+ printf("Begin Queue\n");
+ foreachList((ListFn)dumpItem_Set, q->head);
+ printf("End Queue\n");
+}