2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
14 #include <rx/rx_queue.h>
17 struct rx_queue queue_header;
22 qprint(char *s, struct myq *qe)
24 printf("%s/%x: next:%x, prev:%x, value=%d\n", s, qe, queue_Next(qe, myq),
25 queue_Prev(qe, myq), qe->value);
29 qremove(char *s, struct myq *q)
34 for (queue_Scan(q, qe, nqe, myq)) {
42 /* Separate test for the splice macros */
49 q = (struct rx_queue *)malloc(sizeof(struct rx_queue));
51 for (i = 0; i < 3; i++) {
52 qe = (struct myq *)malloc(sizeof(struct myq));
53 qe->value = n * 1000 + i;
62 struct rx_queue *q[10];
65 for (i = 0; i < 10; i++)
66 q[i] = createQueue(i);
67 for (i = 0; i < 9; i++) {
69 queue_SplicePrepend(q[0], q[i + 1]);
71 queue_SpliceAppend(q[0], q[i + 1]);
73 /* Move the queue to the middle (splice non-empty onto empty) */
74 queue_SpliceAppend(q[7], q[0]);
75 queue_SplicePrepend(q[6], q[0]);
76 /* Splice some empty&non-empty queues onto empty&non-empty queues */
77 for (i = 0; i < 9; i++)
78 queue_SpliceAppend(q[i], q[i + 1]);
79 for (i = 0; i < 9; i++)
80 queue_SplicePrepend(q[i], q[i + 1]);
81 printf("All queues except 5 should be empty\n");
82 for (i = 0; i < 10; i++) {
83 printf("Forwards, i=%d:", i);
84 for (queue_Scan(q[i], qe, nqe, myq))
85 printf(" %d", qe->value);
88 for (i = 0; i < 10; i++) {
89 printf("Backwards, i=%d:", i);
90 for (queue_ScanBackwards(q[i], qe, nqe, myq))
91 printf(" %d", qe->value);
107 for (i = 0; i < 20; i++)
108 queue_Prepend(&x, &xa[i]), xa[i].value = i + 1;
111 for (i = 0; i < 20; i++)
112 queue_Append(&y, &ya[i]), ya[i].value = i + 1;
113 qremove("x, first pass", &x);
114 qremove("x, later", &x);
115 qremove("y, first pass", &y);
116 qremove("y, later", &y);
120 main(int argc, char **argv)