chiark
/
gitweb
/
~ian
/
inn-innduct.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
f663bce
)
Get rid of type aliasing
author
Ian Jackson
<ian@liberator.(none)>
Tue, 27 Apr 2010 16:47:38 +0000
(17:47 +0100)
committer
Ian Jackson
<ian@liberator.(none)>
Tue, 27 Apr 2010 16:47:38 +0000
(17:47 +0100)
backends/innduct.c
patch
|
blob
|
history
diff --git
a/backends/innduct.c
b/backends/innduct.c
index 4311dca21299888966a793a2cb0e9d11201f965b..8e5181a84e9fc797684d20b7446f7163ee7f68bb 100644
(file)
--- a/
backends/innduct.c
+++ b/
backends/innduct.c
@@
-205,26
+205,29
@@
perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
/*----- doubly linked lists -----*/
/*----- doubly linked lists -----*/
-#define ISNODE(T) struct { T *succ, *pred; } node /* must be at start */
-#define DEFLIST(T) typedef struct { T *hd, *tl, *tp; int count; } T##List
+#define ISNODE(T) struct node list_node
+#define DEFLIST(T) \
+ typedef struct { \
+ union { struct list li; T *for_type; } u; \
+ int count; \
+ } T##List
-#define NODE(n) (assert((void*)&(n)->node == &(n)), \
- (struct node*)&(n)->node)
+#define NODE(n) (assert((void*)&(n)->list_node == &(n)), &(n)->list_node)
#define LIST_CHECKCANHAVENODE(l,n) \
#define LIST_CHECKCANHAVENODE(l,n) \
- ((void)((n) == ((l).
hd
))) /* just for the type check */
+ ((void)((n) == ((l).
u.for_type
))) /* just for the type check */
-#define LIST_ADDSOMEHOW(l,n,list_addsomehow)
\
- ( LIST_CHECKCANHAVENODE(l,n),
\
- list_addsomehow(
(struct list*)&(l), NODE((n))),
\
- (void)(l).count++
\
+#define LIST_ADDSOMEHOW(l,n,list_addsomehow) \
+ ( LIST_CHECKCANHAVENODE(l,n), \
+ list_addsomehow(
&(l).u.li, NODE((n))),
\
+ (void)(l).count++ \
)
#define LIST_REMSOMEHOW(l,list_remsomehow) \
)
#define LIST_REMSOMEHOW(l,list_remsomehow) \
- ( (typeof((l).
hd))
\
+ ( (typeof((l).
u.for_type))
\
( (l).count \
? ( (l).count--, \
( (l).count \
? ( (l).count--, \
- list_remsomehow(
(struct list*)&(l)) )
\
+ list_remsomehow(
&(l).u.li) )
\
: 0 \
) \
)
: 0 \
) \
)
@@
-235,8
+238,8
@@
perl -ne 'print if m/-8\<-/..m/-\>8-/; print "\f" if m/-\^L-/' backends/innduct.
#define LIST_REMHEAD(l) LIST_REMSOMEHOW((l),list_remhead)
#define LIST_REMTAIL(l) LIST_REMSOMEHOW((l),list_remtail)
#define LIST_REMHEAD(l) LIST_REMSOMEHOW((l),list_remhead)
#define LIST_REMTAIL(l) LIST_REMSOMEHOW((l),list_remtail)
-#define LIST_INIT(l) (
(l).hd, list_new((struct list*)&(l)
))
-#define LIST_HEAD(l) ((typeof((l).
hd
))(list_head((struct list*)&(l))))
+#define LIST_INIT(l) (
list_new(&(l).u.li
))
+#define LIST_HEAD(l) ((typeof((l).
u.for_type
))(list_head((struct list*)&(l))))
#define LIST_NEXT(n) ((typeof(n))list_succ(NODE((n))))
#define LIST_BACK(n) ((typeof(n))list_pred(NODE((n))))
#define LIST_NEXT(n) ((typeof(n))list_succ(NODE((n))))
#define LIST_BACK(n) ((typeof(n))list_pred(NODE((n))))