Added llvmgcc version to allow tests to be xfailed by frontend version.
[llvm-complete.git] / utils / Burg / list.c
blobdaa90cfa807975095bc52481809b94f4ec84d982
1 char rcsid_list[] = "$Id$";
3 #include "b.h"
5 IntList
6 newIntList(x, next) int x; IntList next;
8 IntList l;
10 l = (IntList) zalloc(sizeof(*l));
11 assert(l);
12 l->x = x;
13 l->next = next;
15 return l;
18 List
19 newList(x, next) void *x; List next;
21 List l;
23 l = (List) zalloc(sizeof(*l));
24 assert(l);
25 l->x = x;
26 l->next = next;
28 return l;
31 List
32 appendList(x, l) void *x; List l;
34 List last;
35 List p;
37 last = 0;
38 for (p = l; p; p = p->next) {
39 last = p;
41 if (last) {
42 last->next = newList(x, 0);
43 return l;
44 } else {
45 return newList(x, 0);
49 void
50 foreachList(f, l) ListFn f; List l;
52 for (; l; l = l->next) {
53 (*f)(l->x);
57 void
58 reveachList(f, l) ListFn f; List l;
60 if (l) {
61 reveachList(f, l->next);
62 (*f)(l->x);
66 int
67 length(l) List l;
69 int c = 0;
71 for(; l; l = l->next) {
72 c++;
74 return c;